mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-12-01 01:17:05 +01:00
feat(exe): on Windows the automatic choice starts eu07_starter.exe
The simulator builds eu07_starter.exe beside eu07.exe (starter/eu07_starter.cpp): it checks the processor and the libraries first, explains a start the system refuses with a bare code, writes the minidump of a crash from outside, passes the arguments on and returns the simulator's exit code. The automatic search now takes it ahead of eu07.exe on Windows. A simulator picked by hand stays. Without AVX2 a build without it still comes first, as the starter would start the AVX2 build. Under Wine nothing changes.
This commit is contained in:
@@ -230,6 +230,54 @@ public class ExecutableLocatorTests
|
||||
Assert.Equal(ExeProblem.None, installation.Executables.Validate(build));
|
||||
}
|
||||
|
||||
private static string Automatic(TestInstallation installation) =>
|
||||
Path.GetFileName(installation.Executables.Resolve(new SimulatorSettings(), out _));
|
||||
|
||||
private static TestInstallation OnWindows(bool lacksAvx2, params string[] names)
|
||||
{
|
||||
var files = new InMemoryFileSystem();
|
||||
foreach (string name in names)
|
||||
files.WithFile(TestInstallation.At(name), PortableExecutable);
|
||||
var installation = new TestInstallation(files, lacksAvx2: lacksAvx2);
|
||||
installation.Environment.AsWindows();
|
||||
return installation;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void On_windows_the_simulators_own_starter_is_picked_ahead_of_the_simulator()
|
||||
{
|
||||
var installation = OnWindows(false, "eu07.exe", "eu07_starter.exe", "eu07_2026-11-15_abc.exe");
|
||||
|
||||
Assert.Equal("eu07_starter.exe", Automatic(installation));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_simulator_picked_by_hand_stays_although_the_starter_is_there()
|
||||
{
|
||||
var installation = OnWindows(false, "eu07.exe", "eu07_starter.exe");
|
||||
var settings = new SimulatorSettings { SelectExeAutomatically = false, ExecutablePath = "eu07.exe" };
|
||||
|
||||
Assert.Equal("eu07.exe", installation.Executables.Resolve(settings, out _));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Without_avx2_a_build_without_it_still_comes_before_the_starter()
|
||||
{
|
||||
var installation = OnWindows(true, "eu07.exe", "eu07_starter.exe", "eu07_noavx2.exe");
|
||||
|
||||
Assert.Equal("eu07_noavx2.exe", Automatic(installation));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Under_wine_the_simulator_is_started_without_its_windows_starter()
|
||||
{
|
||||
var installation = WithWine(new InMemoryFileSystem()
|
||||
.WithFile(TestInstallation.At("eu07.exe"), PortableExecutable)
|
||||
.WithFile(TestInstallation.At("eu07_starter.exe"), PortableExecutable));
|
||||
|
||||
Assert.Equal("eu07.exe", Automatic(installation));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Wine_is_never_looked_for_on_windows()
|
||||
{
|
||||
|
||||
@@ -55,6 +55,19 @@ public sealed class ExecutableLocator
|
||||
|
||||
public string CanonicalName => _environment.IsWindows ? "eu07.exe" : "eu07";
|
||||
|
||||
/// <summary>
|
||||
/// The simulator's own starter on Windows, built beside eu07.exe: it checks the processor and the
|
||||
/// libraries first, explains a start the system refuses with a bare code, writes the minidump of a
|
||||
/// crash from outside, passes the arguments on and returns the simulator's exit code.
|
||||
/// </summary>
|
||||
public const string WindowsStarterName = "eu07_starter.exe";
|
||||
|
||||
// Picked ahead of the simulator next to it on Windows alone: under Wine neither its checks nor its
|
||||
// minidumps are of any use.
|
||||
private bool IsWindowsStarter(string path) =>
|
||||
_environment.IsWindows &&
|
||||
string.Equals(Path.GetFileName(path), WindowsStarterName, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// The simulator to start: the one picked in the settings, or the best one in
|
||||
/// the installation. A pick that is not there - the settings live per user and
|
||||
@@ -95,6 +108,7 @@ public sealed class ExecutableLocator
|
||||
.Where(IsCandidate)
|
||||
.OrderBy(Rank)
|
||||
.ThenByDescending(path => _lacksAvx2 && IsNoAvx2(path) ? _files.GetLastWriteTimeUtc(path) : DateTime.MinValue)
|
||||
.ThenBy(path => IsWindowsStarter(path) ? 0 : 1)
|
||||
.ThenBy(path => string.Equals(Path.GetFileName(path), CanonicalName,
|
||||
StringComparison.OrdinalIgnoreCase) ? 0 : 1)
|
||||
.ThenBy(path => Path.GetFileName(path).Length);
|
||||
|
||||
Reference in New Issue
Block a user