Skip to content

Switch test suite to use tasty#2848

Merged
kritzcreek merged 5 commits intopurescript:masterfrom
kritzcreek:tasty-testsuite
Jan 3, 2018
Merged

Switch test suite to use tasty#2848
kritzcreek merged 5 commits intopurescript:masterfrom
kritzcreek:tasty-testsuite

Conversation

@kritzcreek
Copy link
Copy Markdown
Member

@kritzcreek kritzcreek commented Apr 15, 2017

This is a suggestion, feel free to shoot it down

This switches the test suite to use tasty as its test runner.

The primary benefit this has right now, is that we can run individual tests by running eg: stack test --test-arguments="-p ide". We can also switch off things like colored output with environment variables, which is nice in a CI setting.

I've seen some strange artifacts with Powershell and the compiler test suite:
getConsoleCursorInfo: invalid argument (Invalid handle.)
I can avoid the error with setting --color never but it's not really a solution. (I decided I'll check what happens on AppVeyor before researching further)

Still missing docs and publish tests, since these use a custom test runner mechanism and I couldn't figure out how to make them use hspec in the limited time I invested.

@hdgarrood
Copy link
Copy Markdown
Contributor

Looks good to me! I'll happily continue this for publish and docs when I get a moment.

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented Apr 16, 2017

👍 I like it

@kritzcreek
Copy link
Copy Markdown
Member Author

I don't know what's happening there, but as long as the test suite can't be run properly on Windows this is not ready to go in...

@paf31
Copy link
Copy Markdown
Contributor

paf31 commented Apr 20, 2017

Appveyor doesn't seem to complain?

If you merge with master then Travis should start working too.

@kritzcreek
Copy link
Copy Markdown
Member Author

tasty detects that it's not running inside a tty and turns off colors by default in CI environments. The problem is that if someone with a windows machine clones the repository and runs stack test his tests will fail with the current state of this PR.

hdgarrood added a commit that referenced this pull request Aug 6, 2017
This doesn't have any immediate effects apart from making the output of
the docs tests slightly nicer. It does, however, get us one closer to
switching over to a nicer test runner such as tasty's (see #2848 for
more details).
@hdgarrood hdgarrood mentioned this pull request Aug 6, 2017
hdgarrood added a commit that referenced this pull request Aug 6, 2017
This doesn't have any immediate effects apart from making the output of
the docs tests slightly nicer. It does, however, get us one step closer to
switching over to a nicer test runner such as tasty's (see #2848 for
more details).
Still missing docs and publish tests, since these use a custom test runner mechanism
Instead of using the silently package, which causes trouble in combination with
tasty, since it silences part of its output as well.
@kritzcreek
Copy link
Copy Markdown
Member Author

kritzcreek commented Dec 25, 2017

Okay, so after a long time of letting this sit... I decided to look into it again, and it turns out that the problems on Windows can be fixed by not using silently on the compiler output in the compiler tests. Instead I set the progress function on the MakeActions to not output anything. Was there anything else the silently was supposed to silence?

I've added a bit of documentation on how to run the individual tests to CONTRIBUTING.md but there is probably a place for some more good example invocations.

Copy link
Copy Markdown
Contributor

@hdgarrood hdgarrood left a comment

Choose a reason for hiding this comment

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

I'm not aware of anything else silently was supposed to silence; as long that the output is reasonable (which I'm sure it is) I'm very much in favour of this 👍

@kritzcreek kritzcreek merged commit 8afe8c0 into purescript:master Jan 3, 2018
@kritzcreek
Copy link
Copy Markdown
Member Author

Thanks :)

@kritzcreek kritzcreek deleted the tasty-testsuite branch January 3, 2018 11:06
@parsonsmatt
Copy link
Copy Markdown
Contributor

Eh, can we reconsider this?

Test output is a lot worse with this. Specifically, failing test messages are entirely muted, so we don't get anything more than a red FAIL. There's no way to hide the successful tests (--hide-successes only hides the green OK thing, which doesn't reduce noise at all). tasty isn't reproducing the failing test cases, so it's necessary to scroll up 100s of lines to see what tests failed. It seems to be running slower now, as well.

@kritzcreek
Copy link
Copy Markdown
Member Author

From one the recent CI runs: All 767 tests passed (196.29s)

@garyb and me also see the failing test output just fine (that's how we found the missing error spans)

I'm totally fine with switching back to pure hspec if someone does the work of pulling the different test suites together under a single invocation of hspec so we can use the pattern syntax and hide successes etc.

@parsonsmatt
Copy link
Copy Markdown
Contributor

Ah, I'm seeing the failure messages now. Still, this seems to be worse than hspec to me, so I'm not entirely sure what motivated the change to tasty. If it's just pulling the test suites into a single hspec invocation then I can put that together.

@kritzcreek
Copy link
Copy Markdown
Member Author

Since this is merged I've been using the ability to only run the ide testsuite (which was possible before, but the invocation was hideous and I always forgot it), and more importantly being able to run specific tests from the passing or failing examples like stack test --ta="-p **1110.purs*".

I've previously searched through the docs for hspec, but it seems like the cmdline pattern syntax only allows to restrict the tests to be run to source files not individual tests.

Also I'm not sure in what sense the test output is a lot worse with this, since it print the test names just as hspec.

hdgarrood added a commit to hdgarrood/purescript that referenced this pull request Apr 13, 2021
Tasty and hspec are both testing frameworks: they are meant to satisfy
the same need, and they're not really intended to be used together.
See e.g. this comment from the tasty-hspec Haddocks:

> hspec and tasty serve similar purposes; consider using one or the
> other.
>
> However, in a pinch, this module allows you to run an hspec Spec as a
> tasty TestTree.

I'd like to switch back to using hspec throughout for two reasons:

1. With hspec, failures are summarised at the end of the test output.
   Tasty reports failures inline, which can be very annoying, especially
   in CI, as you then have to search through the logs to find the
   failure. Displaying failures at the end seems like a much more
   sensible default to me.

2. We get to take advantage of HasCallStack in hspec-expectations to
   help narrow down where a failure is coming from. This is particularly
   helpful in tests like the ones in TestMake.hs where we run something
   like ``someAction `shouldReturn` someResult`` more than once in a
   particular test, as without the source location from HasCallStack
   it's not immediately clear which assertion is failing. (This would
   have been useful in purescript#4053).

In purescript#2848, when tasty was first introduced, one of the main benefits we
were getting was that it would let us run individual tests via CLI
options. This is still possible with this PR: hspec has a `--match` CLI
option for this.

There's no `--accept` flag for golden tests, but instead you can set an
`HSPEC_ACCEPT` environment variable, or simply delete the files you want
to regenerate.
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.

4 participants