From 8ded20206f07ce1c9ba09b4df3ad8a5e937a6a42 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 20 May 2020 00:33:23 -0400 Subject: [PATCH 1/7] Add a BundleTestWasmApp target to build wasm test apps for libraries. --- eng/testing/tests.mobile.targets | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index 4728c595d981f9..d8956d3d21fe64 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -106,6 +106,29 @@ + + + + + $(OutDir)\app + + + + + + + + + + + @@ -132,5 +155,5 @@ + DependsOnTargets="UpdateRuntimePack;Publish;BundleTestAppleApp;BundleTestAndroidApp;BundleTestWasmApp" /> From 2cf54174c6107908a9a2d0b44272ccc8f9930205 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 20 May 2020 14:35:39 -0400 Subject: [PATCH 2/7] Move runtime.js to src/mono/wasm, rename to runtime-test.js. --- eng/testing/tests.mobile.targets | 4 +--- src/mono/netcore/sample/wasm/Makefile | 6 ++++-- src/mono/netcore/sample/wasm/WasmSample.csproj | 2 +- src/mono/wasm/Makefile | 5 +++++ .../sample/wasm/runtime.js => wasm/runtime-test.js} | 0 .../tasks/mobile.tasks/WasmAppBuilder/WasmAppBuilder.cs | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) rename src/mono/{netcore/sample/wasm/runtime.js => wasm/runtime-test.js} (100%) diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index d8956d3d21fe64..3b4c46a6d2bb04 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -117,13 +117,11 @@ - - diff --git a/src/mono/netcore/sample/wasm/Makefile b/src/mono/netcore/sample/wasm/Makefile index e798a00fd1e22f..05d1e32fdb0ee1 100644 --- a/src/mono/netcore/sample/wasm/Makefile +++ b/src/mono/netcore/sample/wasm/Makefile @@ -2,16 +2,18 @@ TOP=../../../../.. DOTNET_Q_ARGS=--nologo -v:q -consoleloggerparameters:NoSummary +CONFIG?=Release + all: build build: - $(TOP)/.dotnet/dotnet build $(DOTNET_Q_ARGS) /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=Release + $(TOP)/.dotnet/dotnet build $(DOTNET_Q_ARGS) /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=$(CONFIG) WasmSample.csproj clean: rm -rf bin run: - cd bin/Release/publish && ~/.jsvu/v8 --expose_wasm runtime.js -- --enable-gc --run WasmSample.dll + cd bin/$(CONFIG)/publish && ~/.jsvu/v8 --expose_wasm runtime.js -- --enable-gc --run WasmSample.dll runtimepack: EMSDK_PATH=$(TOP)/src/mono/wasm/emsdk $(TOP)/build.sh -c $(MONO_CONFIG) -os Browser -arch wasm -subset Mono+Libs diff --git a/src/mono/netcore/sample/wasm/WasmSample.csproj b/src/mono/netcore/sample/wasm/WasmSample.csproj index 535fd287c058c0..5d30d1b10ed145 100644 --- a/src/mono/netcore/sample/wasm/WasmSample.csproj +++ b/src/mono/netcore/sample/wasm/WasmSample.csproj @@ -29,7 +29,7 @@ AppDir="$(AppDir)" RuntimePackDir="$(RuntimePackDir)" MainAssembly="bin\WasmSample.dll" - MainJS="runtime.js" + MainJS="$(RuntimePackDir)\native\wasm\runtime-test.js" AssemblySearchPaths="@(AssemblySearchPaths)"/> diff --git a/src/mono/wasm/Makefile b/src/mono/wasm/Makefile index 412ec94a18578b..eb59ebb87980df 100644 --- a/src/mono/wasm/Makefile +++ b/src/mono/wasm/Makefile @@ -91,6 +91,11 @@ endef $(eval $(call InterpBuildTemplate,debug,,$(EMCC_DEBUG_FLAGS),$(MONO_LIBS))) $(eval $(call InterpBuildTemplate,release,,$(EMCC_RELEASE_FLAGS),$(MONO_LIBS))) +$(BUILDS_BIN_DIR)/runtime-test.js: runtime-test.js + cp runtime-test.js $@ + +build-native: $(BUILDS_BIN_DIR)/runtime-test.js + build: EMSDK_PATH=$(PWD)/wasm/emsdk ../../../.dotnet/dotnet build /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=$(CONFIG) diff --git a/src/mono/netcore/sample/wasm/runtime.js b/src/mono/wasm/runtime-test.js similarity index 100% rename from src/mono/netcore/sample/wasm/runtime.js rename to src/mono/wasm/runtime-test.js diff --git a/tools-local/tasks/mobile.tasks/WasmAppBuilder/WasmAppBuilder.cs b/tools-local/tasks/mobile.tasks/WasmAppBuilder/WasmAppBuilder.cs index 5261f4c08b276a..ce6839f4f62758 100644 --- a/tools-local/tasks/mobile.tasks/WasmAppBuilder/WasmAppBuilder.cs +++ b/tools-local/tasks/mobile.tasks/WasmAppBuilder/WasmAppBuilder.cs @@ -69,7 +69,7 @@ public override bool Execute () { File.Copy (assembly.Location, Path.Join (AppDir, "managed", Path.GetFileName (assembly.Location)), true); foreach (var f in new string [] { "dotnet.wasm", "dotnet.js" }) File.Copy (Path.Join (RuntimePackDir, "native", "wasm", "runtimes", "release", f), Path.Join (AppDir, f), true); - File.Copy (MainJS!, Path.Join (AppDir, Path.GetFileName (MainJS!)), true); + File.Copy (MainJS!, Path.Join (AppDir, "runtime.js"), true); using (var sw = File.CreateText (Path.Join (AppDir, "mono-config.js"))) { sw.WriteLine ("config = {"); From 1763bfba731334da996e613856db665aa120887f Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 20 May 2020 18:39:53 -0400 Subject: [PATCH 3/7] Add a wasm runner template. --- eng/testing/WasmRunnerTemplate.sh | 6 ++++++ eng/testing/tests.mobile.targets | 7 ++----- eng/testing/tests.targets | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 eng/testing/WasmRunnerTemplate.sh diff --git a/eng/testing/WasmRunnerTemplate.sh b/eng/testing/WasmRunnerTemplate.sh new file mode 100644 index 00000000000000..665d567857f921 --- /dev/null +++ b/eng/testing/WasmRunnerTemplate.sh @@ -0,0 +1,6 @@ +EXECUTION_DIR=$(dirname $0) +TEST_NAME=$1 +TARGET_ARCH=$2 + +echo "Test: $1 Arch: $2" +exit 1 diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index 3b4c46a6d2bb04..5172429a50a158 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -110,21 +110,18 @@ AssemblyFile="$(ArtifactsBinDir)\WasmAppBuilder\$(MonoConfiguration)\$(NetCoreAppCurrent)\publish\WasmAppBuilder.dll" /> - - $(OutDir)\app - - + RunnerTemplate.sh AppleRunnerTemplate.sh AndroidRunnerTemplate.sh + WasmRunnerTemplate.sh $(MSBuildThisFileDirectory)$(RunScriptInputName) From 52f3ea34fcfcdfc722846768b0b1fd2838979bc0 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Mon, 25 May 2020 18:39:32 -0400 Subject: [PATCH 4/7] Fix make runtimepack. --- src/mono/netcore/sample/wasm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/netcore/sample/wasm/Makefile b/src/mono/netcore/sample/wasm/Makefile index 05d1e32fdb0ee1..3734985b2fafce 100644 --- a/src/mono/netcore/sample/wasm/Makefile +++ b/src/mono/netcore/sample/wasm/Makefile @@ -16,4 +16,4 @@ run: cd bin/$(CONFIG)/publish && ~/.jsvu/v8 --expose_wasm runtime.js -- --enable-gc --run WasmSample.dll runtimepack: - EMSDK_PATH=$(TOP)/src/mono/wasm/emsdk $(TOP)/build.sh -c $(MONO_CONFIG) -os Browser -arch wasm -subset Mono+Libs + EMSDK_PATH=$(absdir $(TOP)/src/mono/wasm/emsdk) $(TOP)/build.sh -c $(CONFIG) -os Browser -arch wasm -subset Mono+Libs From b19c1401bcbd013bade5329672cc650ccd75948c Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 26 May 2020 19:00:05 -0400 Subject: [PATCH 5/7] Get runtime-test.js from mono/wasm. --- eng/testing/tests.mobile.targets | 6 +++--- src/mono/netcore/sample/wasm/Makefile | 2 +- src/mono/netcore/sample/wasm/WasmSample.csproj | 2 +- src/mono/wasm/Makefile | 5 ----- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index 5172429a50a158..49de98c3d2cbc5 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -117,9 +117,9 @@ diff --git a/src/mono/netcore/sample/wasm/Makefile b/src/mono/netcore/sample/wasm/Makefile index 3734985b2fafce..aed078c63ebf1a 100644 --- a/src/mono/netcore/sample/wasm/Makefile +++ b/src/mono/netcore/sample/wasm/Makefile @@ -16,4 +16,4 @@ run: cd bin/$(CONFIG)/publish && ~/.jsvu/v8 --expose_wasm runtime.js -- --enable-gc --run WasmSample.dll runtimepack: - EMSDK_PATH=$(absdir $(TOP)/src/mono/wasm/emsdk) $(TOP)/build.sh -c $(CONFIG) -os Browser -arch wasm -subset Mono+Libs + EMSDK_PATH=$(abspath $(TOP)/src/mono/wasm/emsdk) $(TOP)/build.sh -c $(CONFIG) -os Browser -arch wasm -subset Mono+Libs diff --git a/src/mono/netcore/sample/wasm/WasmSample.csproj b/src/mono/netcore/sample/wasm/WasmSample.csproj index 5d30d1b10ed145..1bf65d18fbea7b 100644 --- a/src/mono/netcore/sample/wasm/WasmSample.csproj +++ b/src/mono/netcore/sample/wasm/WasmSample.csproj @@ -29,7 +29,7 @@ AppDir="$(AppDir)" RuntimePackDir="$(RuntimePackDir)" MainAssembly="bin\WasmSample.dll" - MainJS="$(RuntimePackDir)\native\wasm\runtime-test.js" + MainJS="$(MonoProjectRoot)\wasm\runtime-test.js" AssemblySearchPaths="@(AssemblySearchPaths)"/> diff --git a/src/mono/wasm/Makefile b/src/mono/wasm/Makefile index eb59ebb87980df..412ec94a18578b 100644 --- a/src/mono/wasm/Makefile +++ b/src/mono/wasm/Makefile @@ -91,11 +91,6 @@ endef $(eval $(call InterpBuildTemplate,debug,,$(EMCC_DEBUG_FLAGS),$(MONO_LIBS))) $(eval $(call InterpBuildTemplate,release,,$(EMCC_RELEASE_FLAGS),$(MONO_LIBS))) -$(BUILDS_BIN_DIR)/runtime-test.js: runtime-test.js - cp runtime-test.js $@ - -build-native: $(BUILDS_BIN_DIR)/runtime-test.js - build: EMSDK_PATH=$(PWD)/wasm/emsdk ../../../.dotnet/dotnet build /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=$(CONFIG) From 6b260e3cb5ed25dbd09c54770392613e394a39fc Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 27 May 2020 06:03:49 -0400 Subject: [PATCH 6/7] Add beginnings of WasmTestRunner app. --- eng/testing/WasmRunnerTemplate.sh | 8 ++++- eng/testing/tests.mobile.targets | 3 +- eng/testing/tests.props | 1 + .../tests/WasmTestRunner/WasmTestRunner.cs | 29 +++++++++++++++++++ .../WasmTestRunner/WasmTestRunner.csproj | 11 +++++++ src/libraries/pretest.proj | 1 + 6 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs create mode 100644 src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.csproj diff --git a/eng/testing/WasmRunnerTemplate.sh b/eng/testing/WasmRunnerTemplate.sh index 665d567857f921..2d4b8f95d4f491 100644 --- a/eng/testing/WasmRunnerTemplate.sh +++ b/eng/testing/WasmRunnerTemplate.sh @@ -1,6 +1,12 @@ +set -ev + EXECUTION_DIR=$(dirname $0) TEST_NAME=$1 TARGET_ARCH=$2 echo "Test: $1 Arch: $2" -exit 1 + +cd $EXECUTION_DIR +v8 --expose_wasm runtime.js -- --enable-gc --run WasmTestRunner.dll $TEST_NAME + +exit 0 diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index 49de98c3d2cbc5..d0b78ecf928837 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -117,7 +117,7 @@ @@ -129,6 +129,7 @@ <_runnerFilesToPublish Include="$(AndroidTestRunnerDir)*" Condition="'$(TargetOS)' == 'Android'" /> <_runnerFilesToPublish Include="$(AppleTestRunnerDir)*" Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS'" /> + <_runnerFilesToPublish Include="$(WasmTestRunnerDir)*" Condition="'$(TargetOS)' == 'Browser'" /> diff --git a/eng/testing/tests.props b/eng/testing/tests.props index 9b7bc1d270ee7e..cccce13b1c4546 100644 --- a/eng/testing/tests.props +++ b/eng/testing/tests.props @@ -25,6 +25,7 @@ $(NetCoreAppCurrent)-$(Configuration) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleTestRunner', '$(MobileRunnersDirSuffix)')) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidTestRunner', '$(MobileRunnersDirSuffix)')) + $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmTestRunner', '$(MobileRunnersDirSuffix)')) $(PackageRID) true diff --git a/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs b/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs new file mode 100644 index 00000000000000..0ee51166fbf294 --- /dev/null +++ b/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Text; +using System.IO; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; + +public class WasmTestRunner +{ + public static int Main(string[] args) + { + Console.Write("Args: "); + foreach (string arg in args) + { + Console.Write(arg); + } + Console.WriteLine("."); + + return 0; + } +} diff --git a/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.csproj b/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.csproj new file mode 100644 index 00000000000000..7d68c49a196a31 --- /dev/null +++ b/src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.csproj @@ -0,0 +1,11 @@ + + + Exe + enable + $(NetCoreAppCurrent) + + + + + + diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index 94141031b8b855..7b8e5f9f9f38b1 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -18,6 +18,7 @@ + Date: Wed, 27 May 2020 07:09:10 -0400 Subject: [PATCH 7/7] Address comments. --- Directory.Build.props | 2 ++ eng/testing/tests.mobile.targets | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 0415a94c763505..70d6c03f17741a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -50,10 +50,12 @@ $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleAppBuilder', 'Debug', '$(NetCoreAppCurrent)')) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidAppBuilder', 'Debug', '$(NetCoreAppCurrent)')) + $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmAppBuilder', 'Debug', '$(NetCoreAppCurrent)', 'publish')) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'MonoAOTCompiler', 'Debug', '$(NetCoreAppCurrent)')) $([MSBuild]::NormalizePath('$(AppleAppBuilderDir)', 'AppleAppBuilder.dll')) $([MSBuild]::NormalizePath('$(AndroidAppBuilderDir)', 'AndroidAppBuilder.dll')) + $([MSBuild]::NormalizePath('$(WasmAppBuilderDir)', 'WasmAppBuilder.dll')) $([MSBuild]::NormalizePath('$(MonoAOTCompilerDir)', 'MonoAOTCompiler.dll')) diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index d0b78ecf928837..3fd1594b73bd55 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -107,10 +107,10 @@ + AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" /> - + @@ -121,7 +121,6 @@ MainJS="$(MonoProjectRoot)\wasm\runtime-test.js" ExtraAssemblies="$(PublishDir)\$(AssemblyName).dll" AssemblySearchPaths="@(AssemblySearchPaths)"/> -