From a63457009eea659573d4ec2648232872642a6743 Mon Sep 17 00:00:00 2001 From: tqiu8 Date: Sat, 5 Sep 2020 14:22:16 -0400 Subject: [PATCH 1/3] [wasm][filesystem] add commandline arg to testharness for setting working dir --- .../System.IO.FileSystem/tests/DirectoryInfo/Name.cs | 1 - src/mono/wasm/runtime-test.js | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs index 30021757a4d6d6..52e08f5c6a08fb 100644 --- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs +++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs @@ -8,7 +8,6 @@ namespace System.IO.Tests public class DirectoryInfo_Name : FileSystemTest { [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/39998", TestPlatforms.Browser)] public void CurrentDirectory() { var info = new DirectoryInfo("."); diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 21b3f118abf0b1..e78715f0b24af1 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -119,6 +119,7 @@ setenv = {}; runtime_args = []; enable_gc = true; enable_zoneinfo = false; +working_dir = "net5.0-Browser-debug"; while (args !== undefined && args.length > 0) { if (args [0].startsWith ("--profile=")) { var arg = args [0].substring ("--profile=".length); @@ -140,6 +141,9 @@ while (args !== undefined && args.length > 0) { } else if (args [0] == "--disable-on-demand-gc") { enable_gc = false; args = args.slice (1); + } else if (args [0] == "--working-dir=") { + var arg = args [0].substring ("--working-dir=".length); + working_dir = arg.split ('=') [1]; } else { break; } @@ -191,6 +195,8 @@ var Module = { } config.loaded_cb = function () { + FS.mkdir(working_dir); + FS.chdir(working_dir); App.init (); }; config.fetch_file_cb = function (asset) { From af8ebe2f7b6d3ac802d1756f9734b1b7591fc4c0 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 15 Sep 2020 19:32:05 -0400 Subject: [PATCH 2/3] [wasm][tests] Fix failing System.IO.Tests.DirectoryInfo_Name.CurrentDirectory - This test was failing because it checks for `Path.GetFileName(Directory.GetCurrentDirectory())` which returns `""` for cwd==`"/"`. - So, we add a dummy directory to the output, and use a new `--working-dir` argument to set that as the cwd. - And this is passed to the runtests script via a new msbuild property called `$(RunTestsJSArguments)` --- eng/testing/tests.mobile.targets | 2 +- .../tests/DirectoryInfo/test-dir/dummy.txt | 0 .../tests/System.IO.FileSystem.Tests.csproj | 5 +++++ src/mono/wasm/runtime-test.js | 15 +++++++++++---- 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 src/libraries/System.IO.FileSystem/tests/DirectoryInfo/test-dir/dummy.txt diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index 481097f938e726..0e13c3c68981f8 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -14,7 +14,7 @@ - $HARNESS_RUNNER wasm test --engine=$(JSEngine) $(JSEngineArgs) --js-file=runtime.js -v --output-directory=$XHARNESS_OUT -- --run WasmTestRunner.dll $(AssemblyName).dll + $HARNESS_RUNNER wasm test --engine=$(JSEngine) $(JSEngineArgs) --js-file=runtime.js -v --output-directory=$XHARNESS_OUT -- $(RunTestsJSArguments) --run WasmTestRunner.dll $(AssemblyName).dll diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/test-dir/dummy.txt b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/test-dir/dummy.txt new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj b/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj index 7115d412c07422..4a921fc8fb4a6f 100644 --- a/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj +++ b/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj @@ -3,6 +3,8 @@ true true $(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser + + --working-dir=/test-dir @@ -172,5 +174,8 @@ Link="Common\System\IO\TempFile.cs" /> + + diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index e78715f0b24af1..c7c37778c29bdd 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -119,7 +119,7 @@ setenv = {}; runtime_args = []; enable_gc = true; enable_zoneinfo = false; -working_dir = "net5.0-Browser-debug"; +working_dir='/'; while (args !== undefined && args.length > 0) { if (args [0].startsWith ("--profile=")) { var arg = args [0].substring ("--profile=".length); @@ -142,8 +142,10 @@ while (args !== undefined && args.length > 0) { enable_gc = false; args = args.slice (1); } else if (args [0] == "--working-dir=") { + } else if (args [0].startsWith ("--working-dir=")) { var arg = args [0].substring ("--working-dir=".length); - working_dir = arg.split ('=') [1]; + working_dir = arg; + args = args.slice (1); } else { break; } @@ -195,8 +197,13 @@ var Module = { } config.loaded_cb = function () { - FS.mkdir(working_dir); - FS.chdir(working_dir); + let wds = FS.stat (working_dir); + if (wds === undefined || !FS.isDir (wds.mode)) { + fail_exec (`Could not find working directory ${working_dir}`); + return; + } + + FS.chdir (working_dir); App.init (); }; config.fetch_file_cb = function (asset) { From 1006eb225f16d13c5064cccf3c35da8f0bcceab2 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 15 Sep 2020 21:58:00 -0400 Subject: [PATCH 3/3] fix bad merge --- src/mono/wasm/runtime-test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index c7c37778c29bdd..b3fbf5dc3fbcaa 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -141,7 +141,6 @@ while (args !== undefined && args.length > 0) { } else if (args [0] == "--disable-on-demand-gc") { enable_gc = false; args = args.slice (1); - } else if (args [0] == "--working-dir=") { } else if (args [0].startsWith ("--working-dir=")) { var arg = args [0].substring ("--working-dir=".length); working_dir = arg;