From 77aeeb5866cf5c1ed0589a0f0b140f5533f818b1 Mon Sep 17 00:00:00 2001 From: johnche Date: Tue, 26 Mar 2024 19:47:56 +0800 Subject: [PATCH] =?UTF-8?q?[unity]=E5=A2=9E=E5=8A=A0=E5=8F=8Cbackend?= =?UTF-8?q?=E7=89=88=E6=9C=AC=EF=BC=8C=E5=88=87=E6=8D=A2=E5=88=B0quickjs?= =?UTF-8?q?=E7=9A=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/unity_unittest.yml | 14 +++++++++++--- unity/cli/cmd.mts | 4 ++++ unity/test/dotnet/Src/TxtLoader.cs | 12 +++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unity_unittest.yml b/.github/workflows/unity_unittest.yml index ea9cca989a..23968dfa4e 100644 --- a/.github/workflows/unity_unittest.yml +++ b/.github/workflows/unity_unittest.yml @@ -69,10 +69,14 @@ jobs: run: | cd unity/test/dotnet node ../../cli dotnet-test quickjs - - name: UnitTest-mult + - name: UnitTest-mult-v8 run: | cd unity/test/dotnet node ../../cli dotnet-test mult + - name: UnitTest-mult-v8-qjs + run: | + cd unity/test/dotnet + node ../../cli dotnet-test mult -sq unittest-osx-dotnet: runs-on: macos-latest @@ -96,7 +100,11 @@ jobs: run: | cd unity/test/dotnet node ../../cli dotnet-test quickjs - - name: UnitTest-mult + - name: UnitTest-mult-v8 + run: | + cd unity/test/dotnet + node ../../cli dotnet-test mult + - name: UnitTest-mult-v8-qjs run: | cd unity/test/dotnet - node ../../cli dotnet-test mult \ No newline at end of file + node ../../cli dotnet-test mult -sq \ No newline at end of file diff --git a/unity/cli/cmd.mts b/unity/cli/cmd.mts index ce841cdc49..ef1e6b8891 100644 --- a/unity/cli/cmd.mts +++ b/unity/cli/cmd.mts @@ -138,7 +138,11 @@ backendProgram program .command("dotnet-test [backend]") .option("--filter ", "testcase will be filtered", "") + .option('-sq, --switch_qjs', 'switch to quickjs backend') .action((backend: string, options: any) => { + if (options.switch_qjs) { + process.env.SwitchToQJS = '1'; + } dotnetTest(cwd, backend || "quickjs", options.filter); }); diff --git a/unity/test/dotnet/Src/TxtLoader.cs b/unity/test/dotnet/Src/TxtLoader.cs index 7e67d886f7..d39019b956 100644 --- a/unity/test/dotnet/Src/TxtLoader.cs +++ b/unity/test/dotnet/Src/TxtLoader.cs @@ -129,7 +129,17 @@ private static void Init() if (env == null) { loader = new TxtLoader(); - env = new JsEnv(loader); + if (System.Environment.GetEnvironmentVariable("SwitchToQJS") == "1") + { + System.Console.Write("---------------------SwitchToQJS------------------------\n"); + env = new JsEnv(loader, -1, BackendType.QuickJS, System.IntPtr.Zero, System.IntPtr.Zero); + } + else + { + System.Console.Write("---------------------Default JsEnv------------------------\n"); + env = new JsEnv(loader); + } + CommonJS.InjectSupportForCJS(env); #if PUERTS_GENERAL && !TESTING_REFLECTION PuertsStaticWrap.PuerRegisterInfo_Gen.AddRegisterInfoGetterIntoJsEnv(env);