From 876980c5ed9d97913f121fbd465316217fef6d9b Mon Sep 17 00:00:00 2001 From: Tammy Qiu Date: Thu, 17 Sep 2020 16:44:33 -0400 Subject: [PATCH] [wasm][filesystem] add arg to testharness for setting working dir (#42020) * [wasm][tests] Fix failing System.IO.Tests.DirectoryInfo_Name.CurrentDirectory Co-authored-by: Ankit Jain --- eng/testing/tests.mobile.targets | 2 +- .../System.IO.FileSystem/tests/DirectoryInfo/Name.cs | 1 - .../tests/DirectoryInfo/test-dir/dummy.txt | 0 .../tests/System.IO.FileSystem.Tests.csproj | 5 +++++ src/mono/wasm/runtime-test.js | 12 ++++++++++++ 5 files changed, 18 insertions(+), 2 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 e3d033b..0a3f5f4 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/Name.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs index 3002175..52e08f5 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/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 0000000..e69de29 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 7115d41..4a921fc 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 21b3f11..b3fbf5d 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='/'; while (args !== undefined && args.length > 0) { if (args [0].startsWith ("--profile=")) { var arg = args [0].substring ("--profile=".length); @@ -140,6 +141,10 @@ 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].startsWith ("--working-dir=")) { + var arg = args [0].substring ("--working-dir=".length); + working_dir = arg; + args = args.slice (1); } else { break; } @@ -191,6 +196,13 @@ var Module = { } config.loaded_cb = function () { + 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) { -- 2.7.4