From ba303e3455986dd6d4483a2947ae207a12ca755a Mon Sep 17 00:00:00 2001 From: Lukasz Czajka Date: Tue, 15 Oct 2024 19:15:13 +0200 Subject: [PATCH] check config in tests --- app/Commands/Dev/DevCompile/Options.hs | 9 +++++---- test/Main.hs | 3 ++- test/Runtime/Base.hs | 27 ++++++++++++++++---------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/Commands/Dev/DevCompile/Options.hs b/app/Commands/Dev/DevCompile/Options.hs index 8b24a33abb..884cd94a46 100644 --- a/app/Commands/Dev/DevCompile/Options.hs +++ b/app/Commands/Dev/DevCompile/Options.hs @@ -8,6 +8,7 @@ import Commands.Dev.DevCompile.Reg.Options import Commands.Dev.DevCompile.Rust.Options import Commands.Dev.DevCompile.Tree.Options import CommonOptions +import Juvix.Config qualified as Config data DevCompileCommand = Core (CoreOptions 'InputMain) @@ -22,15 +23,15 @@ data DevCompileCommand parseDevCompileCommand :: Parser DevCompileCommand parseDevCompileCommand = hsubparser - ( mconcat + ( mconcat $ [ commandCore, commandReg, commandTree, commandCasm, - commandAsm, - commandRust, - commandNativeRust + commandAsm ] + <> [commandRust | Config.config ^. Config.configRust] + <> [commandNativeRust | Config.config ^. Config.configRust] ) commandCore :: Mod CommandFields DevCompileCommand diff --git a/test/Main.hs b/test/Main.hs index dc32a15451..e54d98a302 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -12,6 +12,7 @@ import Format qualified import Formatter qualified import Internal qualified import Isabelle qualified +import Juvix.Config qualified as Config import Nockma qualified import Package qualified import Parsing qualified @@ -40,12 +41,12 @@ slowTests = return Internal.allTests, return Compilation.allTests, return Examples.allTests, - Rust.allTests, Casm.allTests, VampIR.allTests, return Anoma.allTests, return Repl.allTests ] + <> sequence (if Config.config ^. Config.configRust then [Rust.allTests] else []) fastTests :: IO TestTree fastTests = diff --git a/test/Runtime/Base.hs b/test/Runtime/Base.hs index db8cb706a9..ab18bc6368 100644 --- a/test/Runtime/Base.hs +++ b/test/Runtime/Base.hs @@ -2,6 +2,7 @@ module Runtime.Base where import Base import Data.FileEmbed +import Juvix.Config qualified as Config import System.Process qualified as P clangCompile :: @@ -25,12 +26,14 @@ clangCompile mkClangArgs inputFile outputFile execute step = clangAssertion :: Int -> Path Abs File -> Path Abs File -> Text -> ((String -> IO ()) -> Assertion) clangAssertion optLevel inputFile expectedFile stdinText step = do - step "Check clang and wasmer are on path" - assertCmdExists $(mkRelFile "clang") - assertCmdExists $(mkRelFile "wasmer") - - step "Lookup WASI_SYSROOT_PATH" - sysrootPath :: Path Abs Dir <- getWasiSysrootPath + if + | Config.config ^. Config.configWasm -> do + step "Check clang and wasmer are on path" + assertCmdExists $(mkRelFile "clang") + assertCmdExists $(mkRelFile "wasmer") + | otherwise -> do + step "Check clang is on path" + assertCmdExists $(mkRelFile "clang") expected <- readFile expectedFile @@ -40,10 +43,14 @@ clangAssertion optLevel inputFile expectedFile stdinText step = do let executeNative :: Path Abs File -> IO Text executeNative outputFile = readProcess (toFilePath outputFile) [] stdinText - step "Compile C to WASM32-WASI" - actualWasm <- clangCompile (wasiArgs optLevel sysrootPath) inputFile $(mkRelFile "Program.wasm") executeWasm step - step "Compare expected and actual program output" - assertEqDiffText ("check: WASM output = " <> toFilePath expectedFile) actualWasm expected + when (Config.config ^. Config.configWasm) $ do + step "Lookup WASI_SYSROOT_PATH" + sysrootPath :: Path Abs Dir <- getWasiSysrootPath + + step "Compile C to WASM32-WASI" + actualWasm <- clangCompile (wasiArgs optLevel sysrootPath) inputFile $(mkRelFile "Program.wasm") executeWasm step + step "Compare expected and actual program output" + assertEqDiffText ("check: WASM output = " <> toFilePath expectedFile) actualWasm expected step "Compile C to native 64-bit code" actualNative <- clangCompile (native64Args optLevel) inputFile $(mkRelFile "Program") executeNative step