[Git][ghc/ghc][master] 2 commits: Hadrian: add a --test-accept/-a flag, to mimic 'make accept'

Marge Bot gitlab at gitlab.haskell.org
Fri Apr 12 18:54:04 UTC 2019



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
3c759ced by Alp Mestanogullari at 2019-04-12T18:46:54Z
Hadrian: add a --test-accept/-a flag, to mimic 'make accept'

When -a or --test-accept is passed, and if one runs the 'test' target, then
any test failing because of mismatching output and which is not expected to
fail will have its expected output adjusted by the test driver, effectively
considering the new output correct from now on.

When this flag is passed, hadrian's 'test' target becomes sensitive to the
PLATFORM and OS environment variable, just like the Make build system:
- when the PLATFORM env var is set to "YES", when accepting a result, accept it
  for the current platform;
- when the OS env var is set to "YES", when accepting a result, accept it
  for all wordsizes of the current operating system.

This can all be combined with `--only="..."` and `TEST="..." to only accept
the new output of a subset of tests.

- - - - -
f4b5a6c0 by Alp Mestanogullari at 2019-04-12T18:46:54Z
Hadrian: document -a/--test-accept

- - - - -


4 changed files:

- hadrian/doc/make.md
- hadrian/doc/testsuite.md
- hadrian/src/CommandLine.hs
- hadrian/src/Settings/Builders/RunTest.hs


Changes:

=====================================
hadrian/doc/make.md
=====================================
@@ -123,6 +123,8 @@ time you fire up a build. This is not possible with the Make build system.
   make test                             # (1)
   make test TEST=plugins01              # (2)
   make test TEST="plugins01 plugins02"  # (3)
+  make accept                           # (4)
+  PLATFORM=YES OS=YES make accept       # (5)
 
 
   # Hadrian
@@ -134,6 +136,12 @@ time you fire up a build. This is not possible with the Make build system.
   build test --only="plugins01 plugins02"    # equivalent to (3)
   TEST="plugins01 plugins02" build test      # equivalent to (3)
   TEST=plugins01 build test --only=plugins02 # equivalent to (3)
+
+  build test -a            # equivalent to (4)
+  build test --test-accept # equivalent to (4)
+
+  PLATFORM=YES OS=YES build test -a            # equivalent to (5)
+  PLATFORM=YES OS=YES build test --test-accept # equivalent to (5)
   ```
 
   As illustrated in the examples above, you can use the `TEST` environment


=====================================
hadrian/doc/testsuite.md
=====================================
@@ -40,6 +40,31 @@ TEST="test1 test2" build test
 TEST="test1 test2" build test --only="test3 test4"
 ```
 
+## Accepting new output
+
+You can use the `-a` or `--test-accept` flag to "accept" the new
+output of your tests. This has the effect of updating the expected
+output of all the tests that fail due to mismatching output, so as to
+consider the new output the correct one.
+
+When the `PLATFORM` environment variable is set to `YES`, passing this flag has
+the effect of accepting the new output for the current platform.
+
+When the `OS` environment variable is set to `YES`, passing this flag has the
+effect of accepting the new output for all word sizes on the current OS.
+
+``` sh
+# accept new output for all tests
+build test -a
+
+# just run and accept new output for 'test123' and 'test456'
+build test -a --only="test123 test456"
+
+# accept new output for current platform and all word sizes for
+# the current OS, for all tests
+PLATFORM=YES OS=YES build test -a
+```
+
 ## Performance tests
 
 You can use the `--only-perf` and `--skip-perf` flags to


=====================================
hadrian/src/CommandLine.hs
=====================================
@@ -56,7 +56,8 @@ data TestArgs = TestArgs
     , testSpeed      :: TestSpeed
     , testSummary    :: Maybe FilePath
     , testVerbosity  :: Maybe String
-    , testWays       :: [String] }
+    , testWays       :: [String]
+    , testAccept     :: Bool}
     deriving (Eq, Show)
 
 -- | Default value for `TestArgs`.
@@ -73,7 +74,8 @@ defaultTestArgs = TestArgs
     , testSpeed      = TestNormal
     , testSummary    = Nothing
     , testVerbosity  = Nothing
-    , testWays       = [] }
+    , testWays       = []
+    , testAccept     = False }
 
 readConfigure :: Either String (CommandLineArgs -> CommandLineArgs)
 readConfigure = Right $ \flags -> flags { configure = True }
@@ -124,6 +126,9 @@ readProgressInfo ms =
 readTestKeepFiles :: Either String (CommandLineArgs -> CommandLineArgs)
 readTestKeepFiles = Right $ \flags -> flags { testArgs = (testArgs flags) { testKeepFiles = True } }
 
+readTestAccept :: Either String (CommandLineArgs -> CommandLineArgs)
+readTestAccept = Right $ \flags -> flags { testArgs = (testArgs flags) { testAccept = True } }
+
 readTestCompiler :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
 readTestCompiler compiler = maybe (Left "Cannot parse compiler") (Right . set) compiler
   where
@@ -245,7 +250,8 @@ optDescrs =
     , Option [] ["test-verbose"] (OptArg readTestVerbose "TEST_VERBOSE")
       "A verbosity value between 0 and 5. 0 is silent, 4 and higher activates extra output."
     , Option [] ["test-way"] (OptArg readTestWay "TEST_WAY")
-      "only run these ways" ]
+      "only run these ways"
+    , Option ['a'] ["test-accept"] (NoArg readTestAccept) "Accept new output of tests" ]
 
 -- | A type-indexed map containing Hadrian command line arguments to be passed
 -- to Shake via 'shakeExtra'.


=====================================
hadrian/src/Settings/Builders/RunTest.hs
=====================================
@@ -71,6 +71,11 @@ runTestBuilderArgs = builder RunTest ? do
     debugged            <- read <$> getTestSetting TestGhcDebugged
     keepFiles           <- expr (testKeepFiles <$> userSetting defaultTestArgs)
 
+    accept <- expr (testAccept <$> userSetting defaultTestArgs)
+    (acceptPlatform, acceptOS) <- expr . liftIO $
+        (,) <$> (maybe False (=="YES") <$> lookupEnv "PLATFORM")
+            <*> (maybe False (=="YES") <$> lookupEnv "OS")
+
     windows     <- expr windowsHost
     darwin      <- expr osxHost
     threads     <- shakeThreads <$> expr getShakeOptions
@@ -95,6 +100,9 @@ runTestBuilderArgs = builder RunTest ? do
             , arg "-e", arg $ "darwin=" ++ show darwin
             , arg "-e", arg $ "config.local=False"
             , arg "-e", arg $ "config.cleanup=" ++ show (not keepFiles)
+            , arg "-e", arg $ "config.accept=" ++ show accept
+            , arg "-e", arg $ "config.accept_platform=" ++ show acceptPlatform
+            , arg "-e", arg $ "config.accept_os=" ++ show acceptOS
             , arg "-e", arg $ "config.exeext=" ++ quote exe
             , arg "-e", arg $ "config.compiler_debugged=" ++ quote (yesNo debugged)
             , arg "-e", arg $ "ghc_debugged=" ++ quote (yesNo debugged)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/885d2e04854f038fbb899ab545df2b57d9b8bba4...f4b5a6c040abb492367fdfe18c4f2ebf03c0d084

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/885d2e04854f038fbb899ab545df2b57d9b8bba4...f4b5a6c040abb492367fdfe18c4f2ebf03c0d084
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190412/1c498ff6/attachment-0001.html>


More information about the ghc-commits mailing list