From 06241259fc87c8370fad866e7265917503ae6506 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Sun, 14 Jan 2018 15:05:48 +0200 Subject: [PATCH 1/2] Failing test case for no-rerun-tests Demonstrates that --no-rerun-tests does not work, and tests are in fact still rerun. --- test/integration/tests/no-rerun-tests/Main.hs | 13 +++++++++++++ .../tests/no-rerun-tests/files/.gitignore | 4 ++++ .../tests/no-rerun-tests/files/package.yaml | 12 ++++++++++++ .../tests/no-rerun-tests/files/stack.yaml | 1 + .../tests/no-rerun-tests/files/test/Spec.hs | 2 ++ 5 files changed, 32 insertions(+) create mode 100644 test/integration/tests/no-rerun-tests/Main.hs create mode 100644 test/integration/tests/no-rerun-tests/files/.gitignore create mode 100644 test/integration/tests/no-rerun-tests/files/package.yaml create mode 100644 test/integration/tests/no-rerun-tests/files/stack.yaml create mode 100644 test/integration/tests/no-rerun-tests/files/test/Spec.hs diff --git a/test/integration/tests/no-rerun-tests/Main.hs b/test/integration/tests/no-rerun-tests/Main.hs new file mode 100644 index 0000000000..39d125ad1a --- /dev/null +++ b/test/integration/tests/no-rerun-tests/Main.hs @@ -0,0 +1,13 @@ +import StackTest +import System.Directory +import Control.Monad + +main :: IO () +main = do + stack ["test"] + exists1 <- doesFileExist "foo" + unless exists1 $ error "exists1 should be True" + removeFile "foo" + stack ["test", "--no-rerun-tests"] + exists2 <- doesFileExist "foo" + when exists2 $ error "exists2 should be False" diff --git a/test/integration/tests/no-rerun-tests/files/.gitignore b/test/integration/tests/no-rerun-tests/files/.gitignore new file mode 100644 index 0000000000..04c6af385a --- /dev/null +++ b/test/integration/tests/no-rerun-tests/files/.gitignore @@ -0,0 +1,4 @@ +.stack-work/ +files.cabal +*~ +foo diff --git a/test/integration/tests/no-rerun-tests/files/package.yaml b/test/integration/tests/no-rerun-tests/files/package.yaml new file mode 100644 index 0000000000..f51d5ebe15 --- /dev/null +++ b/test/integration/tests/no-rerun-tests/files/package.yaml @@ -0,0 +1,12 @@ +name: files + +dependencies: +- base >= 4.7 && < 5 + +library: + source-dirs: src + +tests: + test: + main: Spec.hs + source-dirs: test diff --git a/test/integration/tests/no-rerun-tests/files/stack.yaml b/test/integration/tests/no-rerun-tests/files/stack.yaml new file mode 100644 index 0000000000..a95908b164 --- /dev/null +++ b/test/integration/tests/no-rerun-tests/files/stack.yaml @@ -0,0 +1 @@ +resolver: ghc-8.2.2 diff --git a/test/integration/tests/no-rerun-tests/files/test/Spec.hs b/test/integration/tests/no-rerun-tests/files/test/Spec.hs new file mode 100644 index 0000000000..d030d26e0c --- /dev/null +++ b/test/integration/tests/no-rerun-tests/files/test/Spec.hs @@ -0,0 +1,2 @@ +main :: IO () +main = writeFile "foo" "" From 39ff251f0cee010cfe72388142b05eb3aad8aea6 Mon Sep 17 00:00:00 2001 From: Artyom Date: Wed, 24 Jan 2018 19:54:26 +0300 Subject: [PATCH 2/2] Remember test success for no-rerun-tests --- ChangeLog.md | 4 ++++ src/Stack/Build/Execute.hs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 473d0a3fb2..6309b21956 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -30,6 +30,10 @@ Bug fixes: this bug, you will likely need to delete the binary build cache associated with the relevant custom snapshot. See [#3714](https://github.com/commercialhaskell/stack/issues/3714). +* `--no-rerun-tests` has been fixed. Previously, after running a test + we were forgetting to record the result, which meant that all tests + always ran even if they had already passed before. See + [#3770](https://github.com/commercialhaskell/stack/pull/3770). ## v1.6.3 diff --git a/src/Stack/Build/Execute.hs b/src/Stack/Build/Execute.hs index fca85beb69..8cb55b66c3 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -1735,6 +1735,8 @@ singleTest runInBase topts testsToRun ac ee task installedMap = do (fmap fst mlogFile) bs + setTestSuccess pkgDir + -- | Implements running a package's benchmarks. singleBench :: HasEnvConfig env => (RIO env () -> IO ())