File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ namespace xcpp
28
28
29
29
void apply (const std::string& code, nl::json& kernel_res) override
30
30
{
31
+ #if defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
32
+ // WASM environment: Disable shell commands
33
+ kernel_res[" status" ] = " error" ;
34
+ kernel_res[" ename" ] = " UnsupportedEnvironment" ;
35
+ kernel_res[" evalue" ] = " Shell commands are not supported in the WASM environment." ;
36
+ kernel_res[" traceback" ] = nl::json::array ();
37
+ #else
38
+ // Native environment: Execute shell commands
31
39
std::regex re (spattern + R"( (.*))" );
32
40
std::smatch to_execute;
33
41
std::regex_search (code, to_execute, re);
@@ -65,6 +73,7 @@ namespace xcpp
65
73
kernel_res[" evalue" ] = " evalue" ;
66
74
kernel_res[" traceback" ] = nl::json::array ();
67
75
}
76
+ #endif
68
77
}
69
78
70
79
[[nodiscard]] std::unique_ptr<xpreamble> clone () const override
Original file line number Diff line number Diff line change @@ -654,15 +654,10 @@ TEST_SUITE("xsystem_clone")
654
654
}
655
655
}
656
656
657
+ #if !defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
657
658
TEST_SUITE (" xsystem_apply" )
658
659
{
659
- #if defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
660
- TEST_CASE (" apply_xsystem"
661
- * doctest::should_fail (true )
662
- * doctest::description (" TODO: Currently fails for the Emscripten build" ))
663
- #else
664
660
TEST_CASE (" apply_xsystem" )
665
- #endif
666
661
{
667
662
xcpp::xsystem system;
668
663
std::string code = " !echo Hello, World!" ;
@@ -673,6 +668,7 @@ TEST_SUITE("xsystem_apply")
673
668
REQUIRE (kernel_res[" status" ] == " ok" );
674
669
}
675
670
}
671
+ #endif
676
672
677
673
TEST_SUITE (" xmagics_contains" ){
678
674
TEST_CASE (" bad_status_cell" ) {
You can’t perform that action at this time.
0 commit comments