From b60a64f0d259c1a748b817b5bcee07669bd3fa64 Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Fri, 9 Oct 2020 22:00:21 +0200 Subject: [PATCH] Enable test suite for windows, ghc-8.8 and ghc-8.10 (#855) * Remove -f-external-interpreter for 8.10 * Rerun tests in the first step * Rerun tests in the first step for linux * Wait for register caps * Remove -f-external-interpreter for 8.10 * Rerun tests in the first step * Rerun tests in the first step for linux * Wait for register caps * Refactor ignoreInWindows* functions * Ignore test for win and ghc-8.8 * Enable all win jobs (again) * Ignore in win the known broken in nix * Ignore addDependentFile for ghc-8.8 * Ignore findsTHnewNameConstructor for ghc-8.8 * Use --rerun-update in first test execution To make sure it creates/overwrites .tasty-rerun-log --- .azure/linux-stack.yml | 2 +- .azure/windows-stack.yml | 14 +++++--------- test/exe/Main.hs | 31 ++++++++++++++++++++----------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.azure/linux-stack.yml b/.azure/linux-stack.yml index 63a5fbc05..ad007f169 100644 --- a/.azure/linux-stack.yml +++ b/.azure/linux-stack.yml @@ -47,6 +47,6 @@ jobs: displayName: 'stack build --test --only-dependencies' - bash: | export PATH=/opt/cabal/bin:$PATH - stack test --ghc-options=-Werror --stack-yaml=$STACK_YAML || stack test --ghc-options=-Werror --stack-yaml=$STACK_YAML --ta "--rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true stack test --ghc-options=-Werror --stack-yaml=$STACK_YAML --ta "--rerun" + stack test --ghc-options=-Werror --stack-yaml=$STACK_YAML --ta "--rerun-update" || stack test --ghc-options=-Werror --stack-yaml=$STACK_YAML --ta "--rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true stack test --ghc-options=-Werror --stack-yaml=$STACK_YAML --ta "--rerun" # ghcide stack tests are flaky, see https://github.com/digital-asset/daml/issues/2606. displayName: 'stack test --ghc-options=-Werror' diff --git a/.azure/windows-stack.yml b/.azure/windows-stack.yml index 52a92ed95..3acf5e2ea 100644 --- a/.azure/windows-stack.yml +++ b/.azure/windows-stack.yml @@ -5,10 +5,10 @@ jobs: vmImage: 'windows-2019' strategy: matrix: -# stack_810: -# STACK_YAML: "stack8101.yaml" -# stack_88: -# STACK_YAML: "stack88.yaml" + stack_810: + STACK_YAML: "stack8101.yaml" + stack_88: + STACK_YAML: "stack88.yaml" stack_86: STACK_YAML: "stack.yaml" stack_ghc_lib_88: @@ -54,9 +54,5 @@ jobs: fi displayName: 'stack build --only-dependencies' - bash: | - if [ "$STACK_YAML" = "stack8101.yaml" ]; then - stack test --ghc-options="-Werror -fexternal-interpreter" --stack-yaml $STACK_YAML || stack test --ghc-options="-Werror -fexternal-interpreter" --stack-yaml=$STACK_YAML --ta "--rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true stack test --ghc-options="-Werror -fexternal-interpreter" --stack-yaml=$STACK_YAML --ta "--rerun" - else - stack test --ghc-options=-Werror --stack-yaml $STACK_YAML || stack test --ghc-options=-Werror --stack-yaml=$STACK_YAML --ta "--rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true stack test --ghc-options=-Werror --stack-yaml=$STACK_YAML --ta "--rerun" - fi + stack test --ghc-options=-Werror --stack-yaml $STACK_YAML --ta "--rerun-update" || stack test --ghc-options=-Werror --stack-yaml=$STACK_YAML --ta "--rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true stack test --ghc-options=-Werror --stack-yaml=$STACK_YAML --ta "--rerun" displayName: 'stack test --ghc-options=-Werror' diff --git a/test/exe/Main.hs b/test/exe/Main.hs index 2fbc25424..efe26123f 100644 --- a/test/exe/Main.hs +++ b/test/exe/Main.hs @@ -1711,7 +1711,7 @@ addFunctionConstraintTests = let , "eq :: " <> constraint <> " => Pair a b -> Pair a b -> Bool" , "eq (Pair x y) (Pair x' y') = x == x' && y == y'" ] - + incompleteConstraintSourceCodeWithNewlinesInTypeSignature :: T.Text -> T.Text incompleteConstraintSourceCodeWithNewlinesInTypeSignature constraint = T.unlines @@ -2296,7 +2296,7 @@ checkFileCompiles fp = pluginSimpleTests :: TestTree pluginSimpleTests = - ignoreInWindowsAndGHCGreaterThan86 $ testSessionWait "simple plugin" $ do + ignoreInWindowsForGHC88And810 $ testSessionWait "simple plugin" $ do let content = T.unlines [ "{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}" @@ -2319,7 +2319,7 @@ pluginSimpleTests = pluginParsedResultTests :: TestTree pluginParsedResultTests = - ignoreInWindowsAndGHCGreaterThan86 $ testSessionWait "parsedResultAction plugin" $ do + ignoreInWindowsForGHC88And810 $ testSessionWait "parsedResultAction plugin" $ do let content = T.unlines [ "{-# LANGUAGE DuplicateRecordFields, TypeApplications, FlexibleContexts, DataKinds, MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-}" @@ -2468,7 +2468,7 @@ thTests = _ <- createDoc "A.hs" "haskell" sourceA _ <- createDoc "B.hs" "haskell" sourceB return () - , thReloadingTest `xfail` "expect broken (#672)" + , ignoreInWindowsForGHC88 (thReloadingTest `xfail` "expect broken (#672)") -- Regression test for https://github.com/digital-asset/ghcide/issues/614 , testSessionWait "findsTHIdentifiers" $ do let sourceA = @@ -2488,7 +2488,7 @@ thTests = _ <- createDoc "A.hs" "haskell" sourceA _ <- createDoc "B.hs" "haskell" sourceB expectDiagnostics [ ( "B.hs", [(DsWarning, (4, 0), "Top-level binding with no type signature: main :: IO ()")] ) ] - , testCase "findsTHnewNameConstructor" $ withoutStackEnv $ runWithExtraFiles "THNewName" $ \dir -> do + , ignoreInWindowsForGHC88 $ testCase "findsTHnewNameConstructor" $ withoutStackEnv $ runWithExtraFiles "THNewName" $ \dir -> do -- This test defines a TH value with the meaning "data A = A" in A.hs -- Loads and export the template in B.hs @@ -2981,12 +2981,20 @@ expectFailCabal = expectFailBecause ignoreInWindowsBecause :: String -> TestTree -> TestTree ignoreInWindowsBecause = if isWindows then ignoreTestBecause else flip const -ignoreInWindowsAndGHCGreaterThan86 :: TestTree -> TestTree -#if MIN_GHC_API_VERSION(8,8,1) -ignoreInWindowsAndGHCGreaterThan86 = - ignoreInWindowsBecause "tests are unreliable for windows and ghc greater than 8.6.5" +ignoreInWindowsForGHC88And810 :: TestTree -> TestTree +#if MIN_GHC_API_VERSION(8,8,1) && !MIN_GHC_API_VERSION(9,0,0) +ignoreInWindowsForGHC88And810 = + ignoreInWindowsBecause "tests are unreliable in windows for ghc 8.8 and 8.10" +#else +ignoreInWindowsForGHC88And810 = id +#endif + +ignoreInWindowsForGHC88 :: TestTree -> TestTree +#if MIN_GHC_API_VERSION(8,8,1) && !MIN_GHC_API_VERSION(8,10,1) +ignoreInWindowsForGHC88 = + ignoreInWindowsBecause "tests are unreliable in windows for ghc 8.8" #else -ignoreInWindowsAndGHCGreaterThan86 = id +ignoreInWindowsForGHC88 = id #endif data Expect @@ -3095,7 +3103,7 @@ loadCradleOnlyonce = testGroup "load cradle only once" dependentFileTest :: TestTree dependentFileTest = testGroup "addDependentFile" - [testGroup "file-changed" [testSession' "test" test] + [testGroup "file-changed" [ignoreInWindowsForGHC88 $ testSession' "test" test] ] where test dir = do @@ -3477,6 +3485,7 @@ clientSettingsTest = testGroup "client settings handling" logNot <- skipManyTill anyMessage loggingNotification isMessagePresent "Updating Not supported" [getLogMessage logNot] , testSession "ghcide restarts shake session on config changes" $ do + void $ skipManyTill anyMessage $ message @RegisterCapabilityRequest sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (toJSON ("" :: String))) nots <- skipManyTill anyMessage $ count 3 loggingNotification isMessagePresent "Restarting build session" (map getLogMessage nots)