-
-
Save radical/18d60949c789cf98f8b175c30096b683 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs | |
index 6a66aa36121..8dc05f1545c 100644 | |
--- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs | |
+++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs | |
@@ -130,6 +130,7 @@ public BuildTestBase(ITestOutputHelper output, SharedBuildPerTestClassFixture bu | |
string id, | |
Action<string>? test=null, | |
string? buildDir = null, | |
+ string? bundleDir = null, | |
int expectedExitCode = 0, | |
string? args = null, | |
Dictionary<string, string>? envVars = null, | |
@@ -152,7 +153,7 @@ public BuildTestBase(ITestOutputHelper output, SharedBuildPerTestClassFixture bu | |
envVars[kvp.Key] = kvp.Value; | |
} | |
- string bundleDir = Path.Combine(GetBinDir(baseDir: buildDir, config: buildArgs.Config, targetFramework: targetFramework), "AppBundle"); | |
+ bundleDir ??= Path.Combine(GetBinDir(baseDir: buildDir, config: buildArgs.Config, targetFramework: targetFramework), "AppBundle"); | |
// Use wasm-console.log to get the xharness output for non-browser cases | |
(string testCommand, string extraXHarnessArgs, bool useWasmConsoleOutput) = host switch | |
diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmRunOutOfAppBundleTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmRunOutOfAppBundleTests.cs | |
index b7c2a71e7c1..e6af1855bd7 100644 | |
--- a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmRunOutOfAppBundleTests.cs | |
+++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmRunOutOfAppBundleTests.cs | |
@@ -29,56 +29,28 @@ public void RunOutOfAppBundle(BuildArgs buildArgs, RunHost host, string id) | |
string binDir = GetBinDir(baseDir: _projectDir!, config: buildArgs.Config); | |
string appBundleDir = Path.Combine(binDir, "AppBundle"); | |
- string tmpBundleDirName = "AppBundleTmp"; | |
- string tmpBundleDir = Path.Combine(binDir, tmpBundleDirName); | |
+ string outerDir = Path.GetFullPath(Path.Combine(appBundleDir, "..")); | |
- string tmpDir = Path.Combine(Path.GetTempPath(), $"{id}-{buildArgs.ProjectName}"); | |
- | |
- if (host == RunHost.Chrome) | |
+ if (host is RunHost.Chrome) | |
{ | |
- Directory.Move(appBundleDir, tmpBundleDir); | |
- Directory.CreateDirectory(appBundleDir); | |
- // Create $binDir/AppBundle/AppBundle | |
- Directory.Move(tmpBundleDir, Path.Combine(appBundleDir, "AppBundle")); | |
- | |
string indexHtmlPath = Path.Combine(appBundleDir, "index.html"); | |
+ // Delete the original one, so we don't use that by accident | |
+ if (File.Exists(indexHtmlPath)) | |
+ File.Delete(indexHtmlPath); | |
+ | |
+ indexHtmlPath = Path.Combine(outerDir, "index.html"); | |
if (!File.Exists(indexHtmlPath)) | |
{ | |
var html = @"<html><body><script type=""module"" src=""./AppBundle/test-main.js""></script></body></html>"; | |
File.WriteAllText(indexHtmlPath, html); | |
} | |
- } else { | |
- CopyAllFiles(appBundleDir, tmpDir); | |
} | |
- RunAndTestWasmApp(buildArgs, expectedExitCode: 42, host: host, id: id, jsRelativePath: Path.Combine(tmpDir, "test-main.js")); | |
- | |
- // Restore AppBundle Dir | |
- if (host == RunHost.Chrome) | |
- { | |
- Directory.Move(Path.Combine(appBundleDir, "AppBundle"), tmpBundleDir); | |
- Directory.Delete(appBundleDir, true); | |
- Directory.Move(tmpBundleDir, appBundleDir); | |
- } else { | |
- Directory.Delete(tmpDir, true); | |
- } | |
- } | |
- | |
- private void CopyAllFiles(string srcDir, string destDir) | |
- { | |
- if (!Directory.Exists(destDir)) | |
- { | |
- Directory.CreateDirectory(destDir); | |
- } | |
- | |
- foreach (var file in Directory.GetFiles(srcDir)) | |
- { | |
- File.Copy(file, Path.Combine(destDir, Path.GetFileName(file)), true); | |
- } | |
- | |
- foreach (var directory in Directory.GetDirectories(srcDir)) | |
- { | |
- CopyAllFiles(directory, Path.Combine(destDir, Path.GetFileName(directory))); | |
- } | |
+ RunAndTestWasmApp(buildArgs, | |
+ expectedExitCode: 42, | |
+ host: host, | |
+ id: id, | |
+ bundleDir: outerDir, | |
+ jsRelativePath: "./AppBundle/test-main.js"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment