Run WASM tests with xharness (#37346)
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Wed, 3 Jun 2020 14:28:31 +0000 (16:28 +0200)
committerGitHub <noreply@github.com>
Wed, 3 Jun 2020 14:28:31 +0000 (16:28 +0200)
Uses the xharness tool to drive the test execution rather than calling v8 directly.
Also includes a fix for running the tests in JavaScriptCore which doesn't provide performance.now().

.config/dotnet-tools.json
eng/Version.Details.xml
eng/Versions.props
eng/testing/WasmRunnerTemplate.sh
src/mono/wasm/Makefile
src/mono/wasm/runtime-test.js

index f03ff79..46328fe 100644 (file)
@@ -15,7 +15,7 @@
       ]
     },
     "microsoft.dotnet.xharness.cli": {
-      "version": "1.0.0-prerelease.20279.2",
+      "version": "1.0.0-prerelease.20303.2",
       "commands": [
         "xharness"
       ]
index c55978f..5b58be2 100644 (file)
       <Uri>https://github.com/mono/linker</Uri>
       <Sha>95d8c21c8d9bfc8cad107ff36fa44851f61bb28c</Sha>
     </Dependency>
-    <Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.20301.2">
+    <Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.20303.2">
       <Uri>https://github.com/dotnet/xharness</Uri>
-      <Sha>bf873c70b1f983f4c9c7280ccb0481142ef64206</Sha>
+      <Sha>2de89cbfa1ad6f5003ba524d520a29d690fa04e7</Sha>
     </Dependency>
   </ToolsetDependencies>
 </Dependencies>
index 12359b0..a0de8d7 100644 (file)
     <SystemDataSqlClientVersion>4.8.0</SystemDataSqlClientVersion>
     <!-- Testing -->
     <MicrosoftNETTestSdkVersion>16.7.0-preview-20200529-01</MicrosoftNETTestSdkVersion>
-    <MicrosoftDotNetXHarnessTestRunnersXunitVersion>1.0.0-prerelease.20301.2</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
+    <MicrosoftDotNetXHarnessTestRunnersXunitVersion>1.0.0-prerelease.20303.2</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
     <XUnitVersion>2.4.1</XUnitVersion>
     <CoverletCollectorVersion>1.3.0</CoverletCollectorVersion>
     <TraceEventVersion>2.0.5</TraceEventVersion>
index 8ae1e35..6e2ebd2 100644 (file)
@@ -1,10 +1,20 @@
-set -ev
+#!/usr/bin/env bash
 
 EXECUTION_DIR=$(dirname $0)
 
 echo "Test: $1"
 
 cd $EXECUTION_DIR
-v8 --expose_wasm runtime.js -- --enable-gc --run WasmTestRunner.dll $*
 
-exit 0
+XHARNESS_OUT="$EXECUTION_DIR/xharness-output"
+
+dotnet xharness wasm test --engine=v8 \
+    --js-file=runtime.js \
+    --output-directory=$XHARNESS_OUT \
+    -- --enable-gc --run WasmTestRunner.dll $*
+
+_exitCode=$?
+
+echo "Xharness artifacts: $XHARNESS_OUT"
+
+exit $_exitCode
index f036ae3..10ed3f9 100644 (file)
@@ -120,4 +120,4 @@ app-builder:
        $(DOTNET) build $(TOP)/tools-local/tasks/mobile.tasks/WasmAppBuilder
 
 run-tests-%:
-       PATH="$(JSVU):$(PATH)" $(DOTNET) build $(TOP)/src/libraries/$*/tests/ /t:Test /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=Release
+       PATH="$(JSVU):$(PATH)" $(DOTNET) build $(TOP)/src/libraries/$*/tests/ /t:Test /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=$(CONFIG)
index 10e4fa6..93c68a5 100644 (file)
@@ -48,6 +48,15 @@ if (typeof crypto == 'undefined') {
        }
 }
 
+if (typeof performance == 'undefined') {
+       // performance.now() is used by emscripten and doesn't work in JSC
+       var performance = {
+               now: function () {
+                       return Date.now ();
+               }
+       }
+}
+
 try {
        if (typeof arguments == "undefined")
                arguments = WScript.Arguments;