mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-10-16 23:49:19 +02:00
Start a Windows build of the simulator through Wine on Linux
Where wine is on the PATH, an eu07.exe in the installation is found after any native binary and needs no execute bit.
This commit is contained in:
@@ -79,4 +79,79 @@ public class ExecutableLocatorTests
|
||||
|
||||
Assert.Equal(new[] { "eu07" }, installation.Executables.ListCandidates());
|
||||
}
|
||||
|
||||
private static readonly string Wine = Path.Combine("/usr/bin", "wine");
|
||||
|
||||
private static TestInstallation WithWine(InMemoryFileSystem files)
|
||||
{
|
||||
var installation = new TestInstallation(files.WithExecutable(Wine));
|
||||
installation.Environment.With("PATH", "/usr/bin");
|
||||
return installation;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Without_wine_a_windows_build_on_linux_is_not_a_candidate()
|
||||
{
|
||||
var installation = new TestInstallation(
|
||||
new InMemoryFileSystem().WithFile(TestInstallation.At("eu07.exe"), PortableExecutable));
|
||||
|
||||
installation.Executables.Resolve(new SimulatorSettings(), out var problem);
|
||||
|
||||
Assert.Equal(ExeProblem.NotFound, problem);
|
||||
Assert.Null(installation.Executables.Wine());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void With_wine_a_windows_build_on_linux_is_found_even_without_the_execute_bit()
|
||||
{
|
||||
var installation = WithWine(
|
||||
new InMemoryFileSystem().WithFile(TestInstallation.At("eu07.exe"), PortableExecutable));
|
||||
|
||||
string resolved = installation.Executables.Resolve(new SimulatorSettings(), out var problem);
|
||||
|
||||
Assert.EndsWith("eu07.exe", resolved);
|
||||
Assert.Equal(ExeProblem.WrongPlatform, problem);
|
||||
Assert.Equal(new[] { "eu07.exe" }, installation.Executables.ListCandidates());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_native_build_wins_over_the_windows_one()
|
||||
{
|
||||
var installation = WithWine(new InMemoryFileSystem()
|
||||
.WithFile(TestInstallation.At("eu07.exe"), PortableExecutable)
|
||||
.WithExecutable(TestInstallation.At("eu07-dev"), Elf));
|
||||
|
||||
string resolved = installation.Executables.Resolve(new SimulatorSettings(), out var problem);
|
||||
|
||||
Assert.EndsWith("eu07-dev", resolved);
|
||||
Assert.Equal(ExeProblem.None, problem);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Wine_starts_the_windows_build_and_a_native_one_starts_itself()
|
||||
{
|
||||
string exe = TestInstallation.At("eu07.exe");
|
||||
string native = TestInstallation.At("eu07");
|
||||
var installation = WithWine(new InMemoryFileSystem()
|
||||
.WithFile(exe, PortableExecutable)
|
||||
.WithExecutable(native, Elf));
|
||||
string[] arguments = { "-s", "$td.scn" };
|
||||
|
||||
var (wine, wineArguments) = installation.Executables.LaunchCommand(exe, arguments);
|
||||
var (program, programArguments) = installation.Executables.LaunchCommand(native, arguments);
|
||||
|
||||
Assert.Equal(Wine, wine);
|
||||
Assert.Equal(new[] { exe, "-s", "$td.scn" }, wineArguments);
|
||||
Assert.Equal(native, program);
|
||||
Assert.Equal(arguments, programArguments);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Wine_is_never_looked_for_on_windows()
|
||||
{
|
||||
var installation = WithWine(new InMemoryFileSystem());
|
||||
installation.Environment.AsWindows();
|
||||
|
||||
Assert.Null(installation.Executables.Wine());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user