diff options
author | Mike Voorhees <mrvoorhe@users.noreply.github.com> | 2021-09-10 11:50:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-10 11:50:47 +0300 |
commit | 0c359eadea75bde0de74d784fdc45788b3668e73 (patch) | |
tree | 608360ca30b4e1ff76339f8d08cf57543e7372f8 | |
parent | 8b7695af6debcbdaad531d521f8a8e10c553541a (diff) |
Make ILCompiler more flexible. (#2272)
-rw-r--r-- | test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs b/test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs index 849e64691..52e876694 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs @@ -12,18 +12,6 @@ namespace Mono.Linker.Tests.TestCasesRunner { public class ILCompiler { - private readonly string _ilasmExecutable; - - public ILCompiler () - { - _ilasmExecutable = LocateIlasm ().ToString (); - } - - public ILCompiler (string ilasmExecutable) - { - _ilasmExecutable = ilasmExecutable; - } - public NPath Compile (CompilerOptions options) { var capturedOutput = new List<string> (); @@ -44,7 +32,7 @@ namespace Mono.Linker.Tests.TestCasesRunner protected virtual void SetupProcess (Process process, CompilerOptions options) { - process.StartInfo.FileName = _ilasmExecutable; + process.StartInfo.FileName = LocateIlasm ().ToString (); process.StartInfo.Arguments = BuildArguments (options); process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; @@ -65,7 +53,7 @@ namespace Mono.Linker.Tests.TestCasesRunner return args.ToString (); } - public static NPath LocateIlasm () + protected virtual NPath LocateIlasm () { #if NETCOREAPP var extension = RuntimeInformation.IsOSPlatform (OSPlatform.Windows) ? ".exe" : ""; @@ -92,6 +80,10 @@ namespace Mono.Linker.Tests.TestCasesRunner if (possiblePath.FileExists ()) return possiblePath; + possiblePath = Environment.CurrentDirectory.ToNPath ().Combine ("ilasm.exe"); + if (possiblePath.FileExists ()) + return possiblePath; + throw new InvalidOperationException ("Could not locate a ilasm.exe executable"); } } |