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

sequentialTestGroup breaks pattern #411

Closed
newhoggy opened this issue Mar 31, 2024 · 1 comment
Closed

sequentialTestGroup breaks pattern #411

newhoggy opened this issue Mar 31, 2024 · 1 comment

Comments

@newhoggy
Copy link

For the following test tree:

tests :: IO TestTree
tests = do
  pure $ T.testGroup "T"
    [ T.testGroup "A"
      [ T.sequentialTestGroup "a" T.AllFinish
        [ emptyTest "1"
        , emptyTest "2"
        ]
      , T.sequentialTestGroup "b" T.AllFinish
        [ emptyTest "1"
        , emptyTest "2"
        ]
      ]
    , T.testGroup "B"
      [ T.sequentialTestGroup "a" T.AllFinish
        [ emptyTest "1"
        , emptyTest "2"
        ]
      , T.sequentialTestGroup "b" T.AllFinish
        [ emptyTest "1"
        , emptyTest "2"
        ]
      ]
    ]

emptyTest :: T.TestName -> TestTree
emptyTest name = T.testCase name (pure ())

I try to filter by pattern:

$ tests --list-tests --pattern /1/
T.A.a.1
T.A.b.1
T.B.a.1
T.B.b.1

Looks good. But then I run a second pattern:

$ tests --list-tests --pattern /2/
T.A.a.1
T.A.a.2
T.A.b.1
T.A.b.2
T.B.a.1
T.B.a.2
T.B.b.1
T.B.b.2

Even though my pattern only specifies tests that contain 2, tests that include 1 are included.

Judging from the behaviour, I think it's because sequentialTestGroup sets up a dependency of each child test tree on its preceding sibling.

Whilst this way of sequentialising tests works for running tests, it breaks the way tests are selected with --pattern causing more tests to run than necessary.

@newhoggy
Copy link
Author

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

1 participant