Skip to content

Commit

Permalink
Implement cleanups from CI
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterRugg authored and gameboo committed Apr 17, 2024
1 parent c85769c commit cc0c883
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/QuickCheckVEngine/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ allTests = [
, ("all", "All Verification", const True, genAll)
, ("random", "Random Template", const True, randomTest)
]
where andPs = foldl (\k p -> (\x -> p x && k x)) (const True)
where andPs = foldl (\k p x -> p x && k x) (const True)

--------------------------------------------------------------------------------
main :: IO ()
Expand All @@ -276,7 +276,7 @@ main = withSocketsDo $ do
rawArgs <- getArgs
(flags, _) <- commandOpts rawArgs
when (optVerbosity flags > 1) $ print flags
let checkRegex incReg excReg str = (str =~ (fromMaybe ".*" incReg)) && (not $ str =~ (fromMaybe "a^" excReg))
let checkRegex incReg excReg str = (str =~ (fromMaybe ".*" incReg)) && (not $ str =~ fromMaybe "a^" excReg)

Check warning on line 279 in src/QuickCheckVEngine/Main.hs

View workflow job for this annotation

GitHub Actions / Run HLint on the QuickCheck Verification Engine codebase

Suggestion in main in module Main: Move brackets to avoid $ ▫︎ Found: "(str =~ (fromMaybe \".*\" incReg))\n && (not $ str =~ fromMaybe \"a^\" excReg)" ▫︎ Perhaps: "(str =~ (fromMaybe \".*\" incReg))\n && not (str =~ fromMaybe \"a^\" excReg)"

Check warning on line 279 in src/QuickCheckVEngine/Main.hs

View workflow job for this annotation

GitHub Actions / Run HLint on the QuickCheck Verification Engine codebase

Suggestion in main in module Main: Redundant bracket ▫︎ Found: "str =~ (fromMaybe \".*\" incReg)" ▫︎ Perhaps: "str =~ fromMaybe \".*\" incReg"
let archDesc = arch flags
let csrFilter idx = checkRegex (csrIncludeRegex flags) (csrExcludeRegex flags) (fromMaybe "reserved" $ csrs_nameFromIndex idx)
let testParams = T.TestParams { T.archDesc = archDesc
Expand All @@ -294,7 +294,7 @@ main = withSocketsDo $ do
quickCheckWithResult (Args Nothing 1 1 len (verbosity > 0) (if doShrink then 1000 else 0))
(prop implA m_implB alive onFail archDesc (timeoutDelay flags) verbosity (optIgnoreAsserts flags) (optPedantic flags) (return test))
let check_mcause_on_trap :: Test TestResult -> Test TestResult
check_mcause_on_trap (trace :: Test TestResult) = if or (hasTrap <$> trace) then (filterTest p trace) <> wrapTest testSuffix else trace
check_mcause_on_trap (trace :: Test TestResult) = if or (hasTrap <$> trace) then filterTest p trace <> wrapTest testSuffix else trace
where hasTrap (_, a, b) = maybe False rvfiIsTrap a || maybe False rvfiIsTrap b
testSuffix = noShrink $ singleSeq [ csrrs 1 (unsafe_csrs_indexFromName "mcause") 0
, csrrs 1 (unsafe_csrs_indexFromName "mtval" ) 0
Expand All @@ -313,7 +313,7 @@ main = withSocketsDo $ do
Nothing -> do
putStrLn "Save this trace (give file name or leave empty to ignore)?"
fileName <- getLine
when (not $ null fileName) $ do
unless (null fileName) $ do
putStrLn "One-line description?"
comment <- getLine
writeFile (fileName ++ ".S")
Expand Down Expand Up @@ -345,15 +345,15 @@ main = withSocketsDo $ do
Nothing -> return mempty
res <- checkSingle (wrapTest $ initTrace <> trace) (optVerbosity flags) (optShrink flags) (testLen flags) (checkTrapAndSave (Just fileName))
case res of Failure {} -> do putStrLn "Failure."
modifyIORef failuresRef ((+) 1)
when (not (optContinueOnFail flags)) $ writeIORef alive False
modifyIORef failuresRef (1 +)
unless (optContinueOnFail flags) $ writeIORef alive False
_ -> putStrLn "No Failure."
isAlive <- readIORef alive
return $ if isAlive then 0 else 1
| otherwise = return $ skipped + 1
--
let doCheck a b = do res <- checkGen a b
case res of Failure {} -> modifyIORef failuresRef ((+) 1)
case res of Failure {} -> modifyIORef failuresRef (1 +)
_ -> return ()
return res
case instTraceFile flags of
Expand Down

0 comments on commit cc0c883

Please sign in to comment.