Skip to content

Skip Cabal package tests that cannot run in the current environment #3180

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

Merged
merged 3 commits into from
Feb 22, 2016

Conversation

grayjay
Copy link
Collaborator

@grayjay grayjay commented Feb 22, 2016

There are three commits:

Revert "Add flag to disable Cabal package tests that use shared libraries"

#3146 wasn't flexible enough to allow different tests to be skipped for different reasons.

Use a writer monad to define Cabal package tests

This commit addresses a TODO comment and allows tests to be filtered and grouped more easily.

Skip Cabal package tests that cannot run in the current environment

The functions testWhen and testUnless filter tests in the TestTreeM monad. The option --enable-all-tests ignores filtering. This commit also applies filtering to the existing package tests that cannot run on Windows.

The test suite chooses whether to disable tests that use shared libraries by checking D.System.buildOS and the version of GHC used for --with-ghc. Is that correct?

/cc @ezyang

The functions 'testWhen' and 'testUnless' filter tests in the 'TestTreeM' monad.
The option '--enable-all-tests' ignores filtering.  This commit also applies
filtering to the existing package tests that cannot run on Windows.
@23Skidoo
Copy link
Member

Looks good to me. @ezyang, what do you think?

@ezyang
Copy link
Contributor

ezyang commented Feb 22, 2016

I am not sure if this is better but let me throw this comment out there and see what you think.

At the moment, the writer monad is set up so that you immediately run some code to determine if a test is runnable or not. This means you need a reader monad if you want to override some of the test hiding behavior.

An alternative would be to actually reify the condition tree, so that you can separate into two steps: (1) generating the tree (which would generate everything, and tag every subtree with the condition, either an AST or just a plain old function predicate, saying what needs to be true to run it), and then (2) a prune step, which actually goes ahead and removes tests. This saves you the reader monad, and if you AST-ize the conditions gives you the ability to manually override a condition or another. This also encourages centralization of predicates.

@ezyang
Copy link
Contributor

ezyang commented Feb 22, 2016

Otherwise LGTM. I don't think it's worth bikeshedding this change too much, as long as the tests are still easy to write (looks like it to me) and the interface supports the use cases you need (looks like it to you.) We can refactor more if we need more functionality later.

@23Skidoo
Copy link
Member

OK, I think I'm going to merge this PR now. Further improvements can come as separate PRs.

23Skidoo added a commit that referenced this pull request Feb 22, 2016
Skip Cabal package tests that cannot run in the current environment
@23Skidoo 23Skidoo merged commit 715ce27 into haskell:master Feb 22, 2016
@23Skidoo
Copy link
Member

Merged. Thanks, @grayjay!

@grayjay
Copy link
Collaborator Author

grayjay commented Feb 23, 2016

Thanks!

I am not sure if this is better but let me throw this comment out there and see what you think.

At the moment, the writer monad is set up so that you immediately run some code to determine if a test is runnable or not. This means you need a reader monad if you want to override some of the test hiding behavior.

An alternative would be to actually reify the condition tree, so that you can separate into two steps: (1) generating the tree (which would generate everything, and tag every subtree with the condition, either an AST or just a plain old function predicate, saying what needs to be true to run it), and then (2) a prune step, which actually goes ahead and removes tests. This saves you the reader monad, and if you AST-ize the conditions gives you the ability to manually override a condition or another. This also encourages centralization of predicates.

I was hoping to avoid the reader monad by using Tasty's support for options. It only provides functions like askOption :: IsOption v => (v -> TestTree) -> TestTree, though, which don't allow filtering.

I went with the reader/writer monad because it was easy to apply to the existing tests. I think that a tree with conditions that can be inspected would become more useful as the logic for choosing tests becomes more complex.

@grayjay grayjay deleted the conditional-tests branch February 23, 2016 08:19
grayjay added a commit to grayjay/cabal that referenced this pull request Feb 24, 2016
This reverts commit 727f447.

This comment is unnecessary after haskell#3180. [ci skip]
23Skidoo pushed a commit that referenced this pull request Feb 24, 2016
This reverts commit 727f447.

This comment is unnecessary after #3180. [ci skip]

(cherry picked from commit 89c24c9)
garetxe pushed a commit to garetxe/cabal that referenced this pull request Mar 5, 2016
This reverts commit 727f447.

This comment is unnecessary after haskell#3180. [ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants