@@ -31,6 +31,14 @@ import UnliftIO.Directory
3131import UnliftIO.Process
3232
3333
34+ introduceTargetSystem :: (
35+ HasBaseContext context , HasCommandLineOptions context SpecialOptions , MonadIO m , MonadMask m , MonadUnliftIO m , MonadBaseControl IO m
36+ ) => SpecFree (LabelValue " targetSystem" (Maybe String ) :> context ) m () -> SpecFree context m ()
37+ introduceTargetSystem = introduceWith [i |Target system|] targetSystem $ \ action -> do
38+ opts <- getCommandLineOptions
39+ let ts = optTargetSystem (optUserOptions opts)
40+ void $ action ts
41+
3442introduceJupyterRunner :: (
3543 HasBaseContext context , MonadIO m , MonadMask m , MonadUnliftIO m , MonadBaseControl IO m
3644 ) => SpecFree (LabelValue " jupyterRunner" FilePath :> context ) m () -> SpecFree context m ()
@@ -53,6 +61,26 @@ introduceBootstrapNixpkgs = introduceWith [i|Jupyter runner|] bootstrapNixpkgs $
5361 out <- readCreateProcessWithLogging ((proc " nix" [" run" , " .#nixpkgsPath" ]) { cwd = Just (rootDir </> " tests" ) }) " "
5462 void $ action (T. unpack $ T. strip $ T. pack out)
5563
64+ -- | Use bubblewrap unless we're cross-compiling (target system differs from host)
65+ introduceBubblewrap :: (
66+ HasBaseContext context , HasTargetSystem context , MonadIO m , MonadMask m , MonadUnliftIO m , MonadBaseControl IO m
67+ ) => SpecFree (LabelValue " maybeBubblewrap" (Maybe FilePath ) :> context ) m () -> SpecFree context m ()
68+ introduceBubblewrap = introduceWith [i |bwrap|] maybeBubblewrap $ \ action -> do
69+ maybeTargetSys <- getContext targetSystem
70+ case maybeTargetSys of
71+ Just _ -> do
72+ -- Skip bubblewrap for cross-architecture tests to avoid closure issues
73+ info [i |Skipping bubblewrap due to cross-architecture target system|]
74+ void $ action Nothing
75+ Nothing -> do
76+ #ifdef darwin_HOST_OS
77+ void $ action Nothing
78+ #else
79+ liftIO (findExecutable " bwrap" ) >>= \ case
80+ Nothing -> expectationFailure [i |The tests currently require bubblewrap to be present.|]
81+ Just path -> void $ action (Just path)
82+ #endif
83+
5684-- | TODO: pipe through a command-line argument to control whether bwrap is used?
5785introduceJustBubblewrap :: (
5886 HasBaseContext context , MonadIO m , MonadMask m , MonadUnliftIO m , MonadBaseControl IO m
@@ -352,7 +380,8 @@ notebookWithCode kernel code = A.object [
352380
353381jupyterMain :: LanguageSpec -> IO ()
354382jupyterMain tests = runSandwichWithCommandLineArgs' Sandwich. defaultOptions specialOptions $
383+ introduceTargetSystem $
355384 introduceJupyterRunner $
356- introduceJustBubblewrap $
385+ introduceBubblewrap $
357386 introduceBootstrapNixpkgs
358387 tests
0 commit comments