Skip to content

Commit b6b8beb

Browse files
committed
[wasm] WBT: use a common tmp path, easier to clean up
1 parent ffc4092 commit b6b8beb

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/mono/wasm/Wasm.Build.Tests/BuildEnvironment.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class BuildEnvironment
2727
public static readonly string RelativeTestAssetsPath = @"..\testassets\";
2828
public static readonly string TestAssetsPath = Path.Combine(AppContext.BaseDirectory, "testassets");
2929
public static readonly string TestDataPath = Path.Combine(AppContext.BaseDirectory, "data");
30+
public static readonly string TmpPath = Path.Combine(Path.GetTempPath(), "wasmbuildtests");
3031

3132
private static readonly Dictionary<string, string> s_runtimePackVersions = new();
3233

@@ -141,6 +142,10 @@ public BuildEnvironment()
141142
{
142143
LogRootPath = Environment.CurrentDirectory;
143144
}
145+
146+
if (Directory.Exists(TmpPath))
147+
Directory.Delete(TmpPath, recursive: true);
148+
Directory.CreateDirectory(TmpPath);
144149
}
145150

146151
// FIXME: error checks

src/mono/wasm/Wasm.Build.Tests/WasmTemplateTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public void ConsoleBuildAndRunDefault(string config, bool relinking)
189189
=> ConsoleBuildAndRun(config, relinking, string.Empty);
190190

191191
[ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))]
192-
[InlineData("Debug", "-f net7.0")]//FIXME: -- enable when updated template packages are available
192+
[InlineData("Debug", "-f net7.0")]
193193
[InlineData("Debug", "-f net8.0")]
194194
public void ConsoleBuildAndRunForSpecificTFM(string config, string extraNewArgs)
195195
=> ConsoleBuildAndRun(config, false, extraNewArgs);
@@ -243,9 +243,9 @@ void AddTestData(bool forConsole, bool runOutsideProjectDirectory)
243243
//data.Add(runOutsideProjectDirectory, forConsole, string.Empty);
244244

245245
data.Add(runOutsideProjectDirectory, forConsole,
246-
$"<OutputPath>{Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())}</OutputPath>");
246+
$"<OutputPath>{Path.Combine(BuildEnvironment.TmpPath, Path.GetRandomFileName())}</OutputPath>");
247247
data.Add(runOutsideProjectDirectory, forConsole,
248-
$"<WasmAppDir>{Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())}</WasmAppDir>");
248+
$"<WasmAppDir>{Path.Combine(BuildEnvironment.TmpPath, Path.GetRandomFileName())}</WasmAppDir>");
249249
}
250250

251251
return data;
@@ -268,7 +268,7 @@ private async Task BrowserRunTwiceWithAndThenWithoutBuildAsync(string config, st
268268
if (!string.IsNullOrEmpty(extraProperties))
269269
AddItemsPropertiesToProject(projectFile, extraProperties: extraProperties);
270270

271-
string workingDir = runOutsideProjectDirectory ? Path.GetTempPath() : _projectDir!;
271+
string workingDir = runOutsideProjectDirectory ? BuildEnvironment.TmpPath : _projectDir!;
272272

273273
{
274274
using var runCommand = new RunCommand(s_buildEnv, _testOutput)
@@ -302,7 +302,7 @@ private Task ConsoleRunWithAndThenWithoutBuildAsync(string config, string extraP
302302
if (!string.IsNullOrEmpty(extraProperties))
303303
AddItemsPropertiesToProject(projectFile, extraProperties: extraProperties);
304304

305-
string workingDir = runOutsideProjectDirectory ? Path.GetTempPath() : _projectDir!;
305+
string workingDir = runOutsideProjectDirectory ? BuildEnvironment.TmpPath : _projectDir!;
306306

307307
{
308308
string runArgs = $"run -c {config} --project {projectFile}";
@@ -443,7 +443,7 @@ public async Task BlazorRunTest()
443443

444444
[ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))]
445445
[InlineData("")]
446-
[InlineData("-f net7.0")] //FIXME: -- enable when updated template packages are available
446+
[InlineData("-f net7.0")]
447447
[InlineData("-f net8.0")]
448448
public async Task BrowserBuildAndRun(string extraNewArgs)
449449
{

0 commit comments

Comments
 (0)