diff --git a/ChangeLog.md b/ChangeLog.md index 1b194fddd0..62aa88ad3d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -42,6 +42,8 @@ Bug fixes: was tried to be registered. This is now fixed by always building internal libraries. See [#3996](https://github.com/commercialhaskell/stack/issues/3996). +* Order of commandline arguments does not matter anymore. + See [#3959](https://github.com/commercialhaskell/stack/issues/3959) * When prompting users about saving their Hackage credentials on upload, flush to stdout before waiting for the response so the prompt actually displays. diff --git a/src/Stack/Options/BenchParser.hs b/src/Stack/Options/BenchParser.hs index d25c0a90d3..d5b751c4a2 100644 --- a/src/Stack/Options/BenchParser.hs +++ b/src/Stack/Options/BenchParser.hs @@ -19,7 +19,7 @@ benchOptsParser hide0 = BenchmarkOptsMonoid help ("Forward BENCH_ARGS to the benchmark suite. " <> "Supports templates from `cabal bench`") <> hide)) - <*> optionalFirst (switch (long "no-run-benchmarks" <> + <*> optionalFirst (flag' True (long "no-run-benchmarks" <> help "Disable running of benchmarks. (Benchmarks will still be built.)" <> hide)) where hide = hideMods hide0 diff --git a/src/Stack/Options/TestParser.hs b/src/Stack/Options/TestParser.hs index 08b3b4bf0b..e5c735edd1 100644 --- a/src/Stack/Options/TestParser.hs +++ b/src/Stack/Options/TestParser.hs @@ -27,12 +27,12 @@ testOptsParser hide0 = help "Arguments passed in to the test suite program" <> hide))) <*> optionalFirst - (switch + (flag' True (long "coverage" <> help "Generate a code coverage report" <> hide)) <*> optionalFirst - (switch + (flag' True (long "no-run-tests" <> help "Disable running of tests. (Tests will still be built.)" <> hide)) diff --git a/test/integration/tests/3959-order-of-flags/Main.hs b/test/integration/tests/3959-order-of-flags/Main.hs new file mode 100644 index 0000000000..650bf92469 --- /dev/null +++ b/test/integration/tests/3959-order-of-flags/Main.hs @@ -0,0 +1,21 @@ +import StackTest + +import Control.Monad (unless) +import Data.List (isInfixOf) + +-- Integration test for https://github.com/commercialhaskell/stack/issues/3959 +main :: IO () +main = do + checkFlagsBeforeCommand + checkFlagsAfterCommand + +checkFlagsBeforeCommand :: IO () +checkFlagsBeforeCommand = stackCheckStderr ["--test", "--no-run-tests", "build"] checker + +checkFlagsAfterCommand :: IO () +checkFlagsAfterCommand = stackCheckStderr ["build", "--test", "--no-run-tests"] checker + +checker :: String -> IO () +checker output = do + let testsAreDisabled = any (\ln -> "Test running disabled by" `isInfixOf` ln) (lines output) + unless testsAreDisabled $ fail "Tests should not be run" diff --git a/test/integration/tests/3959-order-of-flags/files/package.yaml b/test/integration/tests/3959-order-of-flags/files/package.yaml new file mode 100644 index 0000000000..43895dbbda --- /dev/null +++ b/test/integration/tests/3959-order-of-flags/files/package.yaml @@ -0,0 +1,10 @@ +name: issue3959 +version: 0.1.0.0 + +dependencies: +- base + +tests: + test: + main: Spec.hs + source-dirs: test diff --git a/test/integration/tests/3959-order-of-flags/files/stack.yaml b/test/integration/tests/3959-order-of-flags/files/stack.yaml new file mode 100644 index 0000000000..cee3f00b38 --- /dev/null +++ b/test/integration/tests/3959-order-of-flags/files/stack.yaml @@ -0,0 +1 @@ +resolver: lts-11.6 diff --git a/test/integration/tests/3959-order-of-flags/files/test/Spec.hs b/test/integration/tests/3959-order-of-flags/files/test/Spec.hs new file mode 100644 index 0000000000..6efee5cea7 --- /dev/null +++ b/test/integration/tests/3959-order-of-flags/files/test/Spec.hs @@ -0,0 +1,2 @@ +main :: IO () +main = fail "this always fails for the test"