From 2c7a19640b4e3ddc89e91ba1e38c29e8bea31638 Mon Sep 17 00:00:00 2001 From: Raimo Radczewski Date: Thu, 23 May 2024 15:45:38 +0200 Subject: [PATCH 1/8] Add support for environment variables --- spec/environment.yaml | 8 ++++++++ src/lib/Test/Smoke/Assert.hs | 2 +- src/lib/Test/Smoke/Executable.hs | 10 +++++++--- src/lib/Test/Smoke/Execution.hs | 4 ++-- src/lib/Test/Smoke/Filters.hs | 2 +- src/lib/Test/Smoke/Plan.hs | 1 + src/lib/Test/Smoke/Types/Base.hs | 6 ++++++ src/lib/Test/Smoke/Types/Plans.hs | 1 + src/lib/Test/Smoke/Types/Tests.hs | 2 ++ 9 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 spec/environment.yaml diff --git a/spec/environment.yaml b/spec/environment.yaml new file mode 100644 index 0000000..b60f58f --- /dev/null +++ b/spec/environment.yaml @@ -0,0 +1,8 @@ +tests: + - name: shell + environment: + TEST_ENV: "test-value" + command: | + echo $TEST_ENV + stdout: | + test-value diff --git a/src/lib/Test/Smoke/Assert.hs b/src/lib/Test/Smoke/Assert.hs index 6486808..266b0b3 100644 --- a/src/lib/Test/Smoke/Assert.hs +++ b/src/lib/Test/Smoke/Assert.hs @@ -23,7 +23,7 @@ assertResult location testPlan@TestPlan {planTest = test} (ExecutionSucceeded ac either (TestErrored test . AssertionError) (TestFinished testPlan) <$> runExceptT (processOutputs location testPlan actualOutputs) processOutputs :: Path Resolved Dir -> TestPlan -> ActualOutputs -> Asserting FinishedTest -processOutputs location (TestPlan _ _ fallbackShell _ _ _ expectedStatus expectedStdOuts expectedStdErrs expectedFiles _) (ActualOutputs actualStatus actualStdOut actualStdErr actualFiles) = do +processOutputs location (TestPlan _ _ fallbackShell _ _ _ _ expectedStatus expectedStdOuts expectedStdErrs expectedFiles _) (ActualOutputs actualStatus actualStdOut actualStdErr actualFiles) = do let statusResult = assertEqual expectedStatus actualStatus stdOutResult <- assertAll (defaultIfEmpty expectedStdOuts) actualStdOut stdErrResult <- assertAll (defaultIfEmpty expectedStdErrs) actualStdErr diff --git a/src/lib/Test/Smoke/Executable.hs b/src/lib/Test/Smoke/Executable.hs index 17d798c..8b42ff3 100644 --- a/src/lib/Test/Smoke/Executable.hs +++ b/src/lib/Test/Smoke/Executable.hs @@ -1,6 +1,7 @@ module Test.Smoke.Executable where import Control.Monad.Trans.Except (ExceptT) +import Data.Map.Strict qualified as Map import Data.Text (Text) import Data.Text.IO qualified as Text.IO import Data.Vector qualified as Vector @@ -17,19 +18,21 @@ runExecutable :: Executable -> Args -> StdIn -> + Maybe EnvVars -> Maybe WorkingDirectory -> IO (ExitCode, Text, Text) -runExecutable (ExecutableProgram executablePath executableArgs) args (StdIn stdIn) workingDirectory = +runExecutable (ExecutableProgram executablePath executableArgs) args (StdIn stdIn) env workingDirectory = readCreateProcessWithExitCode ( ( proc (toFilePath executablePath) (Vector.toList (unArgs (executableArgs <> args))) ) - { cwd = toFilePath . unWorkingDirectory <$> workingDirectory + { cwd = toFilePath . unWorkingDirectory <$> workingDirectory, + env = fmap Map.toList (unEnvVars <$> env) } ) stdIn -runExecutable (ExecutableScript (Shell shellPath shellArgs) (Script script)) args stdIn workingDirectory = +runExecutable (ExecutableScript (Shell shellPath shellArgs) (Script script)) args stdIn env workingDirectory = withSystemTempFile defaultShellScriptName $ \scriptPath scriptHandle -> do Text.IO.hPutStr scriptHandle script hClose scriptHandle @@ -38,6 +41,7 @@ runExecutable (ExecutableScript (Shell shellPath shellArgs) (Script script)) arg (ExecutableProgram shellPath executableArgs) args stdIn + env workingDirectory convertCommandToExecutable :: diff --git a/src/lib/Test/Smoke/Execution.hs b/src/lib/Test/Smoke/Execution.hs index 3b4f2f9..f8bf60d 100644 --- a/src/lib/Test/Smoke/Execution.hs +++ b/src/lib/Test/Smoke/Execution.hs @@ -31,7 +31,7 @@ runTest location testPlan = else either ExecutionFailed ExecutionSucceeded <$> runExceptT (executeTest location testPlan) executeTest :: Path Resolved Dir -> TestPlan -> Execution ActualOutputs -executeTest location (TestPlan _ workingDirectory _ executable args processStdIn _ _ _ files revert) = do +executeTest location (TestPlan _ workingDirectory _ executable args env processStdIn _ _ _ files revert) = do let workingDirectoryFilePath = toFilePath $ unWorkingDirectory workingDirectory workingDirectoryExists <- liftIO $ doesDirectoryExist workingDirectoryFilePath @@ -41,7 +41,7 @@ executeTest location (TestPlan _ workingDirectory _ executable args processStdIn revertingDirectories revert $ do (exitCode, processStdOut, processStdErr) <- tryIO (CouldNotExecuteCommand executable) $ - runExecutable executable args processStdIn (Just workingDirectory) + runExecutable executable args processStdIn env (Just workingDirectory) actualFiles <- Map.fromList <$> mapM (liftIO . readTestFile) (Map.keys files) pure $ ActualOutputs (convertExitCode exitCode) (StdOut processStdOut) (StdErr processStdErr) actualFiles where diff --git a/src/lib/Test/Smoke/Filters.hs b/src/lib/Test/Smoke/Filters.hs index 4f5ac93..4b4d1e6 100644 --- a/src/lib/Test/Smoke/Filters.hs +++ b/src/lib/Test/Smoke/Filters.hs @@ -17,7 +17,7 @@ applyFilters fallbackShell (Filter command) value = do withExceptT (CouldNotExecuteFilter executable) $ ExceptT $ tryIOError $ - runExecutable executable mempty (StdIn (serializeFixture value)) Nothing + runExecutable executable mempty (StdIn (serializeFixture value)) Nothing Nothing case exitCode of ExitSuccess -> pure $ deserializeFixture processStdOut ExitFailure code -> diff --git a/src/lib/Test/Smoke/Plan.hs b/src/lib/Test/Smoke/Plan.hs index c667c55..093d6dc 100644 --- a/src/lib/Test/Smoke/Plan.hs +++ b/src/lib/Test/Smoke/Plan.hs @@ -85,6 +85,7 @@ readTest location fallbackWorkingDirectory fallbackShell fallbackCommand test = planShell = fallbackShell, planExecutable = executable, planArgs = args, + planEnvironment = testEnvironment test, planStdIn = stdIn, planStatus = status, planStdOut = stdOut, diff --git a/src/lib/Test/Smoke/Types/Base.hs b/src/lib/Test/Smoke/Types/Base.hs index 77bfbfc..8eece25 100644 --- a/src/lib/Test/Smoke/Types/Base.hs +++ b/src/lib/Test/Smoke/Types/Base.hs @@ -8,6 +8,7 @@ import Control.Monad (when) import Data.Aeson import Data.Aeson.Types (Parser, typeMismatch) import Data.Default +import Data.Map.Strict (Map) import Data.String (IsString) import Data.Text (Text) import Data.Text qualified as Text @@ -55,6 +56,11 @@ instance FromFixture Args where fixtureName = "args" serializeFixture = Text.unlines . Vector.toList . Vector.map Text.pack . unArgs +newtype EnvVars = EnvVars + { unEnvVars :: Map String String + } + deriving (FromJSON) + newtype Script = Script { unScript :: Text } diff --git a/src/lib/Test/Smoke/Types/Plans.hs b/src/lib/Test/Smoke/Types/Plans.hs index cb82e55..8d393a1 100644 --- a/src/lib/Test/Smoke/Types/Plans.hs +++ b/src/lib/Test/Smoke/Types/Plans.hs @@ -26,6 +26,7 @@ data TestPlan = TestPlan planShell :: Maybe Shell, planExecutable :: Executable, planArgs :: Args, + planEnvironment :: Maybe EnvVars, planStdIn :: StdIn, planStatus :: Status, planStdOut :: Vector (Assert StdOut), diff --git a/src/lib/Test/Smoke/Types/Tests.hs b/src/lib/Test/Smoke/Types/Tests.hs index a8ace22..5576927 100644 --- a/src/lib/Test/Smoke/Types/Tests.hs +++ b/src/lib/Test/Smoke/Types/Tests.hs @@ -45,6 +45,7 @@ data Test = Test testWorkingDirectory :: Maybe (Path Relative Dir), testCommand :: Maybe Command, testArgs :: Maybe Args, + testEnvironment :: Maybe EnvVars, testStdIn :: Maybe (TestInput StdIn), testStatus :: Status, testStdOut :: Vector (TestOutput StdOut), @@ -62,6 +63,7 @@ instance FromJSON Test where <*> (v .:? "working-directory") <*> (v .:? "command") <*> (v .:? "args") + <*> (v .:? "environment") <*> (v .:? "stdin") <*> (v .:? "exit-status" .!= def) <*> (manyMaybe <$> (v .:? "stdout")) From afd2d60a0dea9dd37d39b6206e4a4cd31bb2b88b Mon Sep 17 00:00:00 2001 From: Raimo Radczewski Date: Fri, 24 May 2024 11:19:26 +0200 Subject: [PATCH 2/8] Use compose --- src/lib/Test/Smoke/Executable.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Test/Smoke/Executable.hs b/src/lib/Test/Smoke/Executable.hs index 8b42ff3..fbcf218 100644 --- a/src/lib/Test/Smoke/Executable.hs +++ b/src/lib/Test/Smoke/Executable.hs @@ -28,7 +28,7 @@ runExecutable (ExecutableProgram executablePath executableArgs) args (StdIn stdI (Vector.toList (unArgs (executableArgs <> args))) ) { cwd = toFilePath . unWorkingDirectory <$> workingDirectory, - env = fmap Map.toList (unEnvVars <$> env) + env = Map.toList . unEnvVars <$> env } ) stdIn From 32ac82da908bbf64327e35ad0f0ead71854c79ed Mon Sep 17 00:00:00 2001 From: Raimo Radczewski Date: Fri, 24 May 2024 12:53:26 +0200 Subject: [PATCH 3/8] chore: Add tests and fix merging environment, not replacing it --- fixtures/environment/smoke.yaml | 38 ++++++++++++++++++++++++++++++++ spec/environment.yaml | 14 +++++++----- spec/io/environment.out | 12 ++++++++++ src/lib/Test/Smoke/Executable.hs | 11 +++++++-- src/lib/Test/Smoke/Types/Base.hs | 2 +- 5 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 fixtures/environment/smoke.yaml create mode 100644 spec/io/environment.out diff --git a/fixtures/environment/smoke.yaml b/fixtures/environment/smoke.yaml new file mode 100644 index 0000000..5864c4f --- /dev/null +++ b/fixtures/environment/smoke.yaml @@ -0,0 +1,38 @@ +tests: + - name: environment + environment: + TEST_ENV: "test-value" + command: | + echo $TEST_ENV + stdout: | + test-value + + - name: inherits + command: | + echo $ONLY_DEFINED_IN_SPEC + stdout: | + defined_in_spec + + - name: overwrites + environment: + OVERWRITE_IN_FIXTURE: "overwritten" + command: | + echo $OVERWRITE_IN_FIXTURE + stdout: | + overwritten + + - name: not-defined + command: | + echo $NOT_DEFINED + stdout: "\n" + + - name: spec-is-merged-into-fixture-not-replaced + environment: + OVERWRITE_IN_FIXTURE: "overwritten" + command: | + echo $OVERWRITE_IN_FIXTURE + echo $ONLY_DEFINED_IN_SPEC + stdout: | + overwritten + defined_in_spec + diff --git a/spec/environment.yaml b/spec/environment.yaml index b60f58f..afbc8a6 100644 --- a/spec/environment.yaml +++ b/spec/environment.yaml @@ -1,8 +1,10 @@ tests: - - name: shell + - name: environment + args: + - fixtures/environment/smoke.yaml + exit-code: 0 environment: - TEST_ENV: "test-value" - command: | - echo $TEST_ENV - stdout: | - test-value + OVERWRITE_IN_FIXTURE: "not_overwritten" + ONLY_DEFINED_IN_SPEC: "defined_in_spec" + stdout: + - file: io/environment.out diff --git a/spec/io/environment.out b/spec/io/environment.out new file mode 100644 index 0000000..89667db --- /dev/null +++ b/spec/io/environment.out @@ -0,0 +1,12 @@ +environment + succeeded +inherits + succeeded +overwrites + succeeded +not-defined + succeeded +spec-is-merged-into-fixture-not-replaced + succeeded + +5 tests, 0 failures diff --git a/src/lib/Test/Smoke/Executable.hs b/src/lib/Test/Smoke/Executable.hs index fbcf218..898f769 100644 --- a/src/lib/Test/Smoke/Executable.hs +++ b/src/lib/Test/Smoke/Executable.hs @@ -5,6 +5,7 @@ import Data.Map.Strict qualified as Map import Data.Text (Text) import Data.Text.IO qualified as Text.IO import Data.Vector qualified as Vector +import System.Environment (getEnvironment) import System.Exit (ExitCode) import System.IO (hClose) import System.IO.Temp (withSystemTempFile) @@ -21,17 +22,23 @@ runExecutable :: Maybe EnvVars -> Maybe WorkingDirectory -> IO (ExitCode, Text, Text) -runExecutable (ExecutableProgram executablePath executableArgs) args (StdIn stdIn) env workingDirectory = +runExecutable (ExecutableProgram executablePath executableArgs) args (StdIn stdIn) env workingDirectory = do + mergedEnv <- traverse addOriginalEnv env readCreateProcessWithExitCode ( ( proc (toFilePath executablePath) (Vector.toList (unArgs (executableArgs <> args))) ) { cwd = toFilePath . unWorkingDirectory <$> workingDirectory, - env = Map.toList . unEnvVars <$> env + env = Map.toList . unEnvVars <$> mergedEnv } ) stdIn + where + addOriginalEnv :: EnvVars -> IO EnvVars + addOriginalEnv overriddenEnv = do + originalEnv <- EnvVars . Map.fromList <$> getEnvironment + pure $ overriddenEnv <> originalEnv runExecutable (ExecutableScript (Shell shellPath shellArgs) (Script script)) args stdIn env workingDirectory = withSystemTempFile defaultShellScriptName $ \scriptPath scriptHandle -> do Text.IO.hPutStr scriptHandle script diff --git a/src/lib/Test/Smoke/Types/Base.hs b/src/lib/Test/Smoke/Types/Base.hs index 8eece25..b48d4d3 100644 --- a/src/lib/Test/Smoke/Types/Base.hs +++ b/src/lib/Test/Smoke/Types/Base.hs @@ -59,7 +59,7 @@ instance FromFixture Args where newtype EnvVars = EnvVars { unEnvVars :: Map String String } - deriving (FromJSON) + deriving (Semigroup, FromJSON) newtype Script = Script { unScript :: Text From 819dfbfefb05fb272cafdccf37ebbe02b320d29c Mon Sep 17 00:00:00 2001 From: Raimo Radczewski Date: Fri, 24 May 2024 16:28:09 +0200 Subject: [PATCH 4/8] Use ruby script to print env variables (works around win vs. linux shell syntax) --- fixtures/environment.rb | 1 + fixtures/environment/smoke.yaml | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 fixtures/environment.rb diff --git a/fixtures/environment.rb b/fixtures/environment.rb new file mode 100644 index 0000000..6d5254b --- /dev/null +++ b/fixtures/environment.rb @@ -0,0 +1 @@ +ARGV.each { |arg| puts ENV[arg] } diff --git a/fixtures/environment/smoke.yaml b/fixtures/environment/smoke.yaml index 5864c4f..a3701cc 100644 --- a/fixtures/environment/smoke.yaml +++ b/fixtures/environment/smoke.yaml @@ -1,38 +1,41 @@ +command: + - ruby + - fixtures/environment.rb + tests: - name: environment environment: TEST_ENV: "test-value" - command: | - echo $TEST_ENV + args: + - TEST_ENV stdout: | test-value - name: inherits - command: | - echo $ONLY_DEFINED_IN_SPEC + args: + - ONLY_DEFINED_IN_SPEC stdout: | defined_in_spec - name: overwrites environment: OVERWRITE_IN_FIXTURE: "overwritten" - command: | - echo $OVERWRITE_IN_FIXTURE + args: + - OVERWRITE_IN_FIXTURE stdout: | overwritten - name: not-defined - command: | - echo $NOT_DEFINED + args: + - NOT_DEFINED stdout: "\n" - name: spec-is-merged-into-fixture-not-replaced environment: OVERWRITE_IN_FIXTURE: "overwritten" - command: | - echo $OVERWRITE_IN_FIXTURE - echo $ONLY_DEFINED_IN_SPEC + args: + - OVERWRITE_IN_FIXTURE + - ONLY_DEFINED_IN_SPEC stdout: | overwritten defined_in_spec - From b55659c0482067667f0e4513c256b4b84fa742a2 Mon Sep 17 00:00:00 2001 From: Raimo Radczewski Date: Fri, 24 May 2024 22:27:08 +0200 Subject: [PATCH 5/8] Allow suite-level definition of environment --- fixtures/environment/smoke.yaml | 16 ++++++++++++++++ spec/io/environment.out | 4 +++- src/lib/Test/Smoke/Plan.hs | 13 ++++++++++--- src/lib/Test/Smoke/Types/Tests.hs | 2 ++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/fixtures/environment/smoke.yaml b/fixtures/environment/smoke.yaml index a3701cc..ae3195c 100644 --- a/fixtures/environment/smoke.yaml +++ b/fixtures/environment/smoke.yaml @@ -2,6 +2,10 @@ command: - ruby - fixtures/environment.rb +environment: + ONLY_DEFINED_IN_FIXTURE_DEFAULT: "defined_in_fixture_default" + OVERWRITTEN_IN_FIXTURE_FROM_DEFAULT: "not_overwritten" + tests: - name: environment environment: @@ -14,8 +18,10 @@ tests: - name: inherits args: - ONLY_DEFINED_IN_SPEC + - ONLY_DEFINED_IN_FIXTURE_DEFAULT stdout: | defined_in_spec + defined_in_fixture_default - name: overwrites environment: @@ -25,6 +31,14 @@ tests: stdout: | overwritten + - name: overwrites-from-default + environment: + OVERWRITTEN_IN_FIXTURE_FROM_DEFAULT: "overwritten" + args: + - OVERWRITTEN_IN_FIXTURE_FROM_DEFAULT + stdout: | + overwritten + - name: not-defined args: - NOT_DEFINED @@ -36,6 +50,8 @@ tests: args: - OVERWRITE_IN_FIXTURE - ONLY_DEFINED_IN_SPEC + - ONLY_DEFINED_IN_FIXTURE_DEFAULT stdout: | overwritten defined_in_spec + defined_in_fixture_default diff --git a/spec/io/environment.out b/spec/io/environment.out index 89667db..c459741 100644 --- a/spec/io/environment.out +++ b/spec/io/environment.out @@ -4,9 +4,11 @@ inherits succeeded overwrites succeeded +overwrites-from-default + succeeded not-defined succeeded spec-is-merged-into-fixture-not-replaced succeeded -5 tests, 0 failures +6 tests, 0 failures diff --git a/src/lib/Test/Smoke/Plan.hs b/src/lib/Test/Smoke/Plan.hs index 093d6dc..b4f5a8b 100644 --- a/src/lib/Test/Smoke/Plan.hs +++ b/src/lib/Test/Smoke/Plan.hs @@ -25,7 +25,7 @@ planTests :: TestSpecification -> IO Plan planTests (TestSpecification specificationCommand suites) = do currentWorkingDirectory <- WorkingDirectory <$> getCurrentWorkingDirectory suitePlans <- - forM suites $ \(SuiteWithMetadata suiteName location (Suite thisSuiteWorkingDirectory thisSuiteShellCommandLine thisSuiteCommand tests)) -> do + forM suites $ \(SuiteWithMetadata suiteName location (Suite thisSuiteWorkingDirectory thisSuiteShellCommandLine thisSuiteCommand thisSuiteEnvVars tests)) -> do let fallbackCommand = thisSuiteCommand <|> specificationCommand shell <- runExceptT $ mapM shellFromCommandLine thisSuiteShellCommandLine @@ -45,6 +45,7 @@ planTests (TestSpecification specificationCommand suites) = do fallbackWorkingDirectory fallbackShell fallbackCommand + thisSuiteEnvVars test ) pure $ SuitePlan suiteName location testPlans @@ -62,9 +63,10 @@ readTest :: WorkingDirectory -> Maybe Shell -> Maybe Command -> + Maybe EnvVars -> Test -> Planning TestPlan -readTest location fallbackWorkingDirectory fallbackShell fallbackCommand test = do +readTest location fallbackWorkingDirectory fallbackShell fallbackCommand fallbackEnvironment test = do let workingDirectory = determineWorkingDirectory location (testWorkingDirectory test) fallbackWorkingDirectory command <- maybe (throwE NoCommand) pure (testCommand test <|> fallbackCommand) @@ -78,6 +80,11 @@ readTest location fallbackWorkingDirectory fallbackShell fallbackCommand test = stdErr <- readStdErr location test files <- readFiles location test let revert = Vector.map (location ) (testRevert test) + let environment = case (testEnvironment test, fallbackEnvironment) of + (Nothing, Nothing) -> Nothing + (Just env, Nothing) -> Just env + (Nothing, Just fallbackEnv) -> Just fallbackEnv + (Just env, Just fallbackEnv) -> Just (env <> fallbackEnv) pure $ TestPlan { planTest = test, @@ -85,7 +92,7 @@ readTest location fallbackWorkingDirectory fallbackShell fallbackCommand test = planShell = fallbackShell, planExecutable = executable, planArgs = args, - planEnvironment = testEnvironment test, + planEnvironment = environment, planStdIn = stdIn, planStatus = status, planStdOut = stdOut, diff --git a/src/lib/Test/Smoke/Types/Tests.hs b/src/lib/Test/Smoke/Types/Tests.hs index 5576927..7581f42 100644 --- a/src/lib/Test/Smoke/Types/Tests.hs +++ b/src/lib/Test/Smoke/Types/Tests.hs @@ -27,6 +27,7 @@ data Suite = Suite { suiteWorkingDirectory :: Maybe (Path Relative Dir), suiteShell :: Maybe CommandLine, suiteCommand :: Maybe Command, + suiteEnvironment :: Maybe EnvVars, suiteTests :: [Test] } @@ -37,6 +38,7 @@ instance FromJSON Suite where <$> (v .:? "working-directory") <*> (v .:? "shell") <*> (v .:? "command") + <*> (v .:? "environment") <*> (v .: "tests") data Test = Test From 6d852d8e9a817a415fe32c4576e2b051bc029dbd Mon Sep 17 00:00:00 2001 From: Raimo Radczewski Date: Fri, 24 May 2024 22:27:12 +0200 Subject: [PATCH 6/8] Add documentation --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 276a16d..dfde0ff 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,28 @@ You can find more examples in the [local shell fixture][] and [global shell fixt [local shell fixture]: ./fixtures/shell/local.yaml [global shell fixture]: ./fixtures/shell/global.yaml +### Setting environment variables + +It is possible to set environment variables, both as defaults for a suite, and for a specific test. Environment variables inherit from the suite, and the suite inherits from the environment `smoke` is started in. + +```yaml +environment: + CI: "0" + +tests: + - name: + environment: + CI: "1" + command: echo ${CI} + stdout: | + 1 +``` + +You can find more examples in the [environment fixture][] + +[environment fixture]: ./fixtures/environment/smoke.yaml + + ### Filtering output Sometimes, things aren't quite so deterministic. When some of the output (or input) is meaningless, or if there's just too much, you can specify filters to transform the data. From 040a25ee0411ad458421dc05ea945946020dc73a Mon Sep 17 00:00:00 2001 From: Raimo Radczewski Date: Fri, 24 May 2024 23:26:47 +0200 Subject: [PATCH 7/8] Shorter merging suite-level an test-level environment --- src/lib/Test/Smoke/Plan.hs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/lib/Test/Smoke/Plan.hs b/src/lib/Test/Smoke/Plan.hs index b4f5a8b..bc9d5db 100644 --- a/src/lib/Test/Smoke/Plan.hs +++ b/src/lib/Test/Smoke/Plan.hs @@ -80,11 +80,6 @@ readTest location fallbackWorkingDirectory fallbackShell fallbackCommand fallbac stdErr <- readStdErr location test files <- readFiles location test let revert = Vector.map (location ) (testRevert test) - let environment = case (testEnvironment test, fallbackEnvironment) of - (Nothing, Nothing) -> Nothing - (Just env, Nothing) -> Just env - (Nothing, Just fallbackEnv) -> Just fallbackEnv - (Just env, Just fallbackEnv) -> Just (env <> fallbackEnv) pure $ TestPlan { planTest = test, @@ -92,7 +87,7 @@ readTest location fallbackWorkingDirectory fallbackShell fallbackCommand fallbac planShell = fallbackShell, planExecutable = executable, planArgs = args, - planEnvironment = environment, + planEnvironment = testEnvironment test <> fallbackEnvironment, planStdIn = stdIn, planStatus = status, planStdOut = stdOut, From 3b8865da30e84c12cd5961f61c61b53585359a54 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Sat, 25 May 2024 10:19:16 +0200 Subject: [PATCH 8/8] dot. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dfde0ff..95b98e0 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ tests: 1 ``` -You can find more examples in the [environment fixture][] +You can find more examples in the [environment fixture][]. [environment fixture]: ./fixtures/environment/smoke.yaml