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

Ignore commented out tests #10

Open
dcastro opened this issue Jul 21, 2021 · 1 comment
Open

Ignore commented out tests #10

dcastro opened this issue Jul 21, 2021 · 1 comment

Comments

@dcastro
Copy link

dcastro commented Jul 21, 2021

At the moment, tasty-discover ignores tests that have been commented out using --, e.g.:

-- test_Repro :: TestTree
-- test_Repro = 
--   testCase do
--      ...

However, if I comment out the test using {- -}, tasty-discover will still find the test, include it in the tree, but then fail to compile:

{-

test_Repro :: TestTree
test_Repro = 
  testCase do
     ...

-}
/home/dc/dev/demo/test/Tree.hs:91:34: error:
    Not in scope: ‘Demo.test_Repro’
    Module ‘Demo’ does not export ‘test_Repro’.

This seems to stem from the fact that tasty-discover simply reads the entire file and looks for lines starting with one of the supported prefixes (e.g. test_).

Another manifestation of this issue is when a test is wrapped in a CPP-style #if. For example, a test might not work on Windows, so a user might wrap it in #if !defined(mingw32_HOST_OS).

A more robust solution might be to use ghc-lib-parser or ghc-exactprint to parse the file and then extract top-level definitions that start with one of the supported prefixes.

I'd be willing to submit a PR, if the maintainers agree with the change.

@newhoggy
Copy link
Member

Sorry, for getting back to you late. Yes. I accept PRs. 😁

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

No branches or pull requests

2 participants