Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polysemy-plugin: fix tests #71967

Merged

Conversation

sevanspowell
Copy link
Contributor

@sevanspowell sevanspowell commented Oct 25, 2019

Motivation for this change

polysemy-plugin is broken due to failing tests.

Things done
  • polysemy-plugin was broken due to failing doctests:
    polysemy-plugin: Make plugin available to doctest #71164.
  • I submitted a PR upstream to fix this:
    Use cabal-doctest polysemy-research/polysemy#265.
  • I've applied the patch of the PR here and moved the default polysemy
    attribute to "polysemy_1_2_0_0" because polysemy-plugin requires
    "polysemy >= 1.2.0.0".
  • Move default "polysemy-zoo" attribute to "polysemy-zoo_0_6_0_1"
    because it is fixed by the polysemy-plugin changes and fixes issues
    with building "polysemy-RandomFu" and "knit-haskell".
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @peti

@sevanspowell
Copy link
Contributor Author

sevanspowell commented Oct 25, 2019

Now I've done a couple of things that might be frowned upon, I would love some help with these:

  1. Checked-in a patch file instead of using fetchpatch.
    - The PR diff from github applies to the polysemy project as a whole, but the polysemy-plugin.src only contains the plugin part. As a result the diff is weird and I couldn't get the right fetchpatch setting to make it work.
  2. Manually altered "hackage-packages.nix" to make sure "cabal-doctest" was in the "testToolDepends" of the derivation, is there another way to do this?

No longer broken:

  • polysemy-plugin
  • axel
  • polysemy-zoo_0_6_0_1
  • polysemy-RandomFu
  • knit-haskell

Still broken:

  • co-log-polysemy (polysemy >=0.2.1.0 && <0.3)
  • gamgee (polysemy >=1.0.0.0 && <1.1)

Comment on lines 1278 to 1284
# The polysemy-plugin tests failed because it couldn't find
# the polysemy-plugin package in the doctests:
# https://github.com/NixOS/nixpkgs/issues/71164
# I've addressed this with a PR upstream:
# https://github.com/polysemy-research/polysemy/pull/265
# The patch of which is applied here.
polysemy-plugin = appendPatch super.polysemy-plugin ./patches/polysemy-plugin.patch;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, we don't like to carry around packages in the nixpkgs repo.

Also, it is generally easier for us to just disable the tests with dontCheck instead of trying to patch them.

Please change this to the dontCheck approach (or you could wait until polysemy-research/polysemy#265 is merged and a new release is made).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is generally easier for us to just disable the tests with dontCheck instead of trying to patch them.

That is true, we hardly ever patch test suites simply because that tends to be more effort than just disabling them. There is one argument to favor of patching over disabling, though: When a new version of the package comes out that incorporates the fixes, our patch will fail to apply -- which means that someone notices that the corresponding override can be deleted. That is not true for dontCheck; those overrides won't fail when a new version comes out and therefore we usually don't remove them even though the override has become obsolete.

@@ -185893,7 +185894,7 @@ self: {
base containers doctest ghc ghc-tcplugins-extra hspec
inspection-testing polysemy should-not-typecheck syb transformers
];
testToolDepends = [ hspec-discover ];
testToolDepends = [ hspec-discover cabal-doctest ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct that this file is autogenerated, so it shouldn't be edited by hand.

Above I suggest just using dontCheck for polysemy-plugin, but in case you're curious, you can grep through pkgs/development/haskell-modules/configuration-common.nix to see how people add test tools.

One solution is to use the addBuildTool function. The other solution is to use overrideCabal and explicitly set testToolDepends.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cabal-doctest should probably go into setupHaskellDepends since it's a part of the Setup.hs build. This means that this dependency will be required regardless of whether testing is enabled or disabled.

@cdepillabout
Copy link
Member

@sevanspowell Thanks for taking the time to update this!

There are a couple things above you'll need to change before this can be merged.

Also, polysemy-plugin is marked broken, so you'll have to remove this line as well (otherwise it won't get unmarked broken next time the Haskell package set is regenerated):

@peti
Copy link
Member

peti commented Oct 26, 2019

@sevanspowell,

The PR diff from github applies to the polysemy project as a whole, but the polysemy-plugin.src only contains the plugin part. As a result the diff is weird and I couldn't get the right fetchpatch setting to make it work.

The problem appears to be that the patch containts another directory hierarchy "polysemy-plugin/" that does not exist, obviously, in the checked-out Hackage tarball. There's multiple ways of fixing that, but the easiest one is probably to post-process the patch with stripLen:

polysemy-plugin = appendPatch (addSetupDepend super.polysemy-plugin self.cabal-doctest) (pkgs.fetchpatch {
  url = "https://github.com/polysemy-research/polysemy/pull/265.patch";
  sha256 = "19237js70chq84w7vqgvj49n6bs9lp95k13ia3xzbr1r9yyrfkhq";
  stripLen = 1;
});

Check out pkgs/build-support/fetchpatch/default.nix if you have a minute, there are many cool features that messing with patches before application. Once feature I've sometimes needed is the ability to drop certain files from the patch.

Manually altered "hackage-packages.nix" to make sure "cabal-doctest" was in the "testToolDepends" of the derivation, is there another way to do this?

See the addSetupDepend super.polysemy-plugin self.cabal-doctest bit in the snippet above.

@cdepillabout
Copy link
Member

@peti Thanks for the suggestions here!

@sevanspowell
Copy link
Contributor Author

Thank you @peti amd @cdepillabout. That’s super helpful! I’ll make these changes soon.

@sevanspowell
Copy link
Contributor Author

RE: using fetchpatch.

That's so annoying! fetchpatch was the first tool I reached for and I figured a "stripLen" value of 1 should work. The patch failed to apply though. So I tried a couple of other values then reviewed the fetchpatch source code. I even resorted to trying to sed the patch before application but all my attempts failed. That's when I resorted to including a patch with the commit.

It's very possible I was just pulling the wrong patch from github, I'm unsure at this point. Thanks for being so helpful @peti, your suggestion worked just fine.

- polysemy-plugin was broken due to failing doctests:
  NixOS#71164.
- I submitted a PR upstream to fix this:
  polysemy-research/polysemy#265.
- I've applied the patch of the PR here and moved the default
  "polysemy" attribute to "polysemy_1_2_0_0" because polysemy-plugin
  requires "polysemy >= 1.2.0.0".
- Move default "polysemy-zoo" attribute to "polysemy-zoo_0_6_0_1"
  because it is fixed by the polysemy-plugin changes and fixes issues
  with building "polysemy-RandomFu" and "knit-haskell".
- Removed packages no longer broken from
  "configuration-hackage2nix.yaml".
- Add cabal-doctest to setupDepends of polysemy-plugin.
@peti
Copy link
Member

peti commented Oct 30, 2019

@GrahamcOfBorg build haskellPackages.axel haskellPackages.knit-haskell haskellPackages.polysemy-plugin haskellPackages.polysemy-RandomFu haskellPackages.polysemy-zoo

@sevanspowell
Copy link
Contributor Author

I think we're pretty much ready to go.

@peti, I've followed your video on regenerating the haskell package-set for Nix and used it to mark these now fixed packages as unbroken in hackage-packages.nix. What's the typical workflow for a PR? Do we mark the packages as unbroken in configuration-hackage2nix.yaml and leave it at that, or do we submit a "hackage-packages.nix: automatic Haskell package set update" commit as part of the PR?

@peti
Copy link
Member

peti commented Oct 31, 2019 via email

@peti peti merged commit 9b87ad0 into NixOS:haskell-updates Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants