Skip to content

Commit

Permalink
Build: Use downloaded Mono runtime and framework to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinCampbell committed Aug 2, 2017
1 parent fef5fff commit fde0984
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ scripts/Omnisharp*
.dotnet/
.dotnet-legacy/
.dotnet-future/
.mono/
tools/*
!tools/packages.config

Expand Down
50 changes: 48 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,38 @@ Task("InstallMonoAssets")
DownloadFileAndUnzip($"{buildPlan.DownloadURL}/{buildPlan.MonoFramework}", env.Folders.MonoFramework);
DownloadFileAndUnzip($"{buildPlan.DownloadURL}/{buildPlan.MonoMSBuildRuntime}", env.Folders.MonoMSBuildRuntime);
DownloadFileAndUnzip($"{buildPlan.DownloadURL}/{buildPlan.MonoMSBuildLib}", env.Folders.MonoMSBuildLib);

string runtimeFolder;
string runtimeFile;
if (Platform.Current.IsMacOS)
{
runtimeFolder = env.Folders.MonoRuntimeMacOS;
runtimeFile = "mono.osx";
}
else if (Platform.Current.IsLinux && Platform.Current.Is32Bit)
{
runtimeFolder = env.Folders.MonoRuntimeLinux32;
runtimeFile = "mono.linux-x86";
}
else if (Platform.Current.IsLinux && Platform.Current.Is64Bit)
{
runtimeFolder = env.Folders.MonoRuntimeLinux64;
runtimeFile = "mono.linux-x86_64";
}
else
{
throw new Exception($"Unsupported platform: {Platform.Current}");
}

DirectoryHelper.ForceCreate(env.Folders.Mono);
DirectoryHelper.Copy(runtimeFolder, env.Folders.Mono);

var frameworkFolder = CombinePaths(env.Folders.Mono, "framework");
DirectoryHelper.ForceCreate(frameworkFolder);
DirectoryHelper.Copy(env.Folders.MonoFramework, frameworkFolder);

Run("chmod", $"+x '{CombinePaths(env.Folders.Mono, runtimeFile)}'");
Run("chmod", $"+x '{CombinePaths(env.Folders.Mono, "run")}'");
});

/// <summary>
Expand Down Expand Up @@ -404,8 +436,22 @@ Task("Test")
// Copy the Mono-built Microsoft.Build.* binaries to the test folder.
DirectoryHelper.Copy($"{env.Folders.MonoMSBuildLib}", instanceFolder);

Run("mono", $"--assembly-loader=strict \"{xunitInstancePath}\" {arguments}", instanceFolder)
.ExceptionOnError($"Test {testProject} failed for net46");
var runScript = CombinePaths(env.Folders.Mono, "run");

var oldMonoPath = Environment.GetEnvironmentVariable("MONO_PATH");
try
{
Environment.SetEnvironmentVariable("MONO_PATH", $"{instanceFolder}");

// By default, the run script launches OmniSharp. To launch our Mono runtime
// with xUnit rather than OmniSharp, we pass '--no-omnisharp'
Run(runScript, $"--no-omnisharp \"{xunitInstancePath}\" {arguments}", instanceFolder)
.ExceptionOnError($"Test {testProject} failed for net46");
}
finally
{
Environment.SetEnvironmentVariable("MONO_PATH", oldMonoPath);
}
}
}
});
Expand Down
8 changes: 4 additions & 4 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"LegacyDotNetVersion": "1.0.0-preview2-1-003177",
"RequiredMonoVersion": "5.2.0.196",
"DownloadURL": "https://omnisharpdownload.blob.core.windows.net/ext",
"MonoRuntimeMacOS": "mono.osx-5.2.0.209.zip",
"MonoRuntimeLinux32": "mono.linux-x86-5.2.0.209.zip",
"MonoRuntimeLinux64": "mono.linux-x86_64-5.2.0.209.zip",
"MonoFramework": "framework-5.2.0.209.zip",
"MonoRuntimeMacOS": "mono.osx-5.2.0.213.zip",
"MonoRuntimeLinux32": "mono.linux-x86-5.2.0.213.zip",
"MonoRuntimeLinux64": "mono.linux-x86_64-5.2.0.213.zip",
"MonoFramework": "framework-5.2.0.213.zip",
"MonoMSBuildRuntime": "Microsoft.Build.Runtime.Mono-alpha5.zip",
"MonoMSBuildLib": "Microsoft.Build.Lib.Mono-alpha5.zip",
"Frameworks": [
Expand Down
2 changes: 1 addition & 1 deletion scripts/platform.cake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public sealed class Platform
private readonly string _architecture;

public bool IsWindows => _os == "Windows";
public bool IsMacOS => _os == "macOS";
public bool IsMacOS => _os == "MacOS";
public bool IsLinux => _os == "Linux";

public bool Is32Bit => _architecture == "x86";
Expand Down

0 comments on commit fde0984

Please sign in to comment.