Skip to content

Commit

Permalink
WASM: Enable Invariant.Tests (dotnet#39814)
Browse files Browse the repository at this point in the history
* WASM: Enable Invariant.Tests

* Fix build and PR Feedback
  • Loading branch information
safern authored Jul 23, 2020
1 parent 4ac596d commit df35f26
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
15 changes: 3 additions & 12 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,9 @@
<WasmFilesToIncludeInFileSystem Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.BuildReference)' == 'true' and !$([System.String]::new('%(ReferenceCopyLocalPaths.Identity)').EndsWith('.resources.dll'))" />
<WasmFilesToIncludeInFileSystem Include="@(WasmSatelliteAssemblies)" TargetPath="%(WasmSatelliteAssemblies.CultureName)\%(WasmSatelliteAssemblies.Filename)%(WasmSatelliteAssemblies.Extension)" />
<ExtraAssemblies Include="$(PublishDir)$(AssemblyName).dll" />
<!-- we need to preserve these facades for BinaryFormatter tests -->
<!-- We need these facades for some tests. -->
<ExtraAssemblies Include="$(PublishDir)mscorlib.dll" />
<ExtraAssemblies Include="$(PublishDir)System.dll" />
<ExtraAssemblies Include="$(PublishDir)System.ComponentModel.DataAnnotations.dll" />
<ExtraAssemblies Include="$(PublishDir)System.Configuration.dll" />
<ExtraAssemblies Include="$(PublishDir)System.Core.dll" />
<ExtraAssemblies Include="$(PublishDir)System.Data.dll" />
<ExtraAssemblies Include="$(PublishDir)System.Drawing.dll" />
<ExtraAssemblies Include="$(PublishDir)System.Numerics.dll" />
<ExtraAssemblies Include="$(PublishDir)System.Runtime.Serialization.dll" />
<ExtraAssemblies Include="$(PublishDir)System.Transactions.dll" />
<ExtraAssemblies Include="$(PublishDir)System.Xml.dll" />
<ExtraAssemblies Include="$(PublishDir)WindowsBase.dll" />
</ItemGroup>
<!-- these tests load assemblies from the file system -->
<ItemGroup Condition="'$(AssemblyName)' == 'System.Reflection.MetadataLoadContext.Tests'">
Expand All @@ -163,12 +153,13 @@
<Error Condition="!Exists('$(MicrosoftNetCoreAppRuntimePackRidDir)')" Text="MicrosoftNetCoreAppRuntimePackRidDir=$(MicrosoftNetCoreAppRuntimePackRidDir) doesn't exist" />
<WasmAppBuilder
AppDir="$(BundleDir)"
InvariantGlobalization="$(InvariantGlobalization)"
MicrosoftNetCoreAppRuntimePackDir="$(MicrosoftNetCoreAppRuntimePackRidDir)"
MainAssembly="$(PublishDir)WasmTestRunner.dll"
MainJS="$(MonoProjectRoot)\wasm\runtime-test.js"
ExtraAssemblies="@(ExtraAssemblies)"
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
AssemblySearchPaths="@(AssemblySearchPaths)"/>
AssemblySearchPaths="@(AssemblySearchPaths)" />
</Target>

<Target Name="AddTestRunnersToPublishedFiles"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <unicode/localpointer.h>
#include <unicode/utrace.h>

static int32_t isLoaded = 0;

static void log_icu_error(const char* name, UErrorCode status)
{
const char * statusText = u_errorName(status);
Expand Down Expand Up @@ -65,7 +67,8 @@ int32_t GlobalizationNative_LoadICU(void)
log_icu_error("ulocdata_getCLDRVersion", status);
return 0;
}


isLoaded = 1;
return 1;
}

Expand All @@ -76,6 +79,12 @@ void GlobalizationNative_InitICUFunctions(void* icuuc, void* icuin, const char*

int32_t GlobalizationNative_GetICUVersion(void)
{
// this method is only used from our tests
// this way we ensure we're testing on the right mode
// even though we can call u_getVersion without loading since it is statically linked.
if (!isLoaded)
return 0;

UVersionInfo versionInfo;
u_getVersion(versionInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<TestRuntime>true</TestRuntime>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<ItemGroup>
<Compile Include="InvariantMode.cs" />
Expand Down
3 changes: 1 addition & 2 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Data.Common\tests\System.Data.Common.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Diagnostics.DiagnosticSource\tests\TestWithConfigSwitches\System.Diagnostics.DiagnosticSource.Switches.Tests.csproj" />

<!-- Mono-Browser ignores runtimeconfig.template.json (e.g. for these two it has "System.Globalization.Invariant": true) -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Globalization\tests\Invariant\Invariant.Tests.csproj" />
<!-- Mono-Browser ignores runtimeconfig.template.json (e.g. for this it has "System.Globalization.EnforceJapaneseEraYearRanges": true) -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Globalization.Calendars\tests\CalendarTestWithConfigSwitch\System.Globalization.CalendarsWithConfigSwitch.Tests.csproj" />

<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.FileSystem\tests\System.IO.FileSystem.Tests.csproj" />
Expand Down
15 changes: 13 additions & 2 deletions tools-local/tasks/mobile.tasks/WasmAppBuilder/WasmAppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class WasmAppBuilder : Task
public ITaskItem[]? ExtraAssemblies { get; set; }
public ITaskItem[]? FilesToIncludeInFileSystem { get; set; }
public ITaskItem[]? RemoteSources { get; set; }
public bool InvariantGlobalization { get; set; }

SortedDictionary<string, Assembly>? _assemblies;
Resolver? _resolver;
Expand Down Expand Up @@ -117,7 +118,15 @@ public override bool Execute ()
Directory.CreateDirectory(Path.Join(AppDir, config.AssemblyRoot));
foreach (var assembly in _assemblies!.Values)
File.Copy(assembly.Location, Path.Join(AppDir, config.AssemblyRoot, Path.GetFileName(assembly.Location)), true);
foreach (var f in new string[] { "dotnet.wasm", "dotnet.js", "dotnet.timezones.blat", "icudt.dat" })

List<string> nativeAssets = new List<string>() { "dotnet.wasm", "dotnet.js", "dotnet.timezones.blat" };

if (!InvariantGlobalization)
{
nativeAssets.Add("icudt.dat");
}

foreach (var f in nativeAssets)
File.Copy(Path.Join (MicrosoftNetCoreAppRuntimePackDir, "native", f), Path.Join(AppDir, f), true);
File.Copy(MainJS!, Path.Join(AppDir, "runtime.js"), true);

Expand Down Expand Up @@ -152,7 +161,9 @@ public override bool Execute ()
}
}

config.Assets.Add(new IcuData { LoadRemote = RemoteSources?.Length > 0 });
if (!InvariantGlobalization)
config.Assets.Add(new IcuData { LoadRemote = RemoteSources?.Length > 0 });

config.Assets.Add(new VfsEntry ("dotnet.timezones.blat") { VirtualPath = "/usr/share/zoneinfo/"});

if (RemoteSources?.Length > 0) {
Expand Down

0 comments on commit df35f26

Please sign in to comment.