Skip to content

Commit

Permalink
[unity]增加双backend版本,切换到quickjs的测试
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Mar 26, 2024
1 parent 305a8dc commit 77aeeb5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/unity_unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
node ../../cli dotnet-test mult -sq
4 changes: 4 additions & 0 deletions unity/cli/cmd.mts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ backendProgram
program
.command("dotnet-test [backend]")
.option("--filter <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);
});

Expand Down
12 changes: 11 additions & 1 deletion unity/test/dotnet/Src/TxtLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 77aeeb5

Please sign in to comment.