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

Hspec support request #9343

Open
peterbecich opened this issue Oct 15, 2023 · 6 comments
Open

Hspec support request #9343

peterbecich opened this issue Oct 15, 2023 · 6 comments

Comments

@peterbecich
Copy link
Member

peterbecich commented Oct 15, 2023

Describe the feature request
I have a feature request in Hspec to make it easier to run specific tests with Cabal: hspec/hspec#862

Hspec needs to know if it is run by Cabal.

@sol suggests this can be implemented if cabal test sets the environment variable CABAL_TEST_COMMAND=cabal

Additional context

Currently a failing test will print:

To rerun use: --match "/someFailingTest/"

To use this suggestion with Cabal, it must be modified to this:

cabal test --test-options="--match \"/someFailingTest/\""

With this environment variable, Hspec will print out this feedback for Cabal.

@Bodigrim
Copy link
Collaborator

Why could not hspec determine its parent process? E. g., https://hackage.haskell.org/package/unix-2.8.3.0/docs/System-Posix-Process-ByteString.html#v:getParentProcessID.

@geekosaur
Copy link
Collaborator

Finding its ppid is POSIX-portable; finding out anything about its parent isn't (/proc doesn't always exist and when it does isn't necessarily Linux-compatible).

@geekosaur
Copy link
Collaborator

Also note that Windows is a wildcard here.

@Bodigrim
Copy link
Collaborator

True, and nevertheless pretty much every OS provides means to determine a parent process. We might lack a crossplatform Haskell library to do this reliably, in which case it would be better to write one instead of establishing an ad-hoc communication channel between cabal and hspec. (But I've been just passing by, nevermind)

@gbaz
Copy link
Collaborator

gbaz commented Oct 16, 2023

note that running a testsuite already does affect the environment, in that it ensures datadir is set. Testing for this is slightly ad-hoc as opposed to a distinguished variable, but it has the great advantage of already existing and working!

@andreabedini
Copy link
Collaborator

@peterbecich a totally under-engineered option is to expand the message to the user:

To rerun use: --match "/someFailingTest/".
If you are using cabal use: cabal test --test-options="--match \"/someFailingTest/\""

(maybe --test-options='--match "/someFailingTest/"' would also work?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants