예제 #1
0
        private ProcessStartInfo CreateStartInfo(Benchmark benchmark, string exePath, string args, string workingDirectory, IResolver resolver)
        {
            var start = new ProcessStartInfo
            {
                UseShellExecute        = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                CreateNoWindow         = true,
                WorkingDirectory       = workingDirectory
            };
            var runtime = benchmark.Job.Env.HasValue(EnvMode.RuntimeCharacteristic)
                ? benchmark.Job.Env.Runtime
                : RuntimeInformation.GetCurrentRuntime();

            // TODO: use resolver
            switch (runtime)
            {
            case ClrRuntime clr:
            case CoreRuntime core:
                start.FileName  = exePath;
                start.Arguments = args;
                break;

            case MonoRuntime mono:
                start.FileName  = mono.CustomPath ?? "mono";
                start.Arguments = GetMonoArguments(benchmark.Job, exePath, args, resolver);
                break;

            default:
                throw new NotSupportedException("Runtime = " + runtime);
            }
            return(start);
        }
        public void CurrentRuntimeIsProperlyRecognized()
        {
            var runtime = RuntimeInformation.GetCurrentRuntime();

#if NETFRAMEWORK
            if (RuntimeInformation.IsWindows())
            {
                Assert.True(runtime is ClrRuntime);
            }
            else
            {
                Assert.True(runtime is MonoRuntime);
            }
#elif NETCOREAPP2_1
            Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.TargetFrameworkMoniker == TargetFrameworkMoniker.NetCoreApp21);
#elif NETCOREAPP2_2
            Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.TargetFrameworkMoniker == TargetFrameworkMoniker.NetCoreApp22);
#elif NETCOREAPP3_0
            Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.TargetFrameworkMoniker == TargetFrameworkMoniker.NetCoreApp30);
#elif NETCOREAPP3_1
            Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.TargetFrameworkMoniker == TargetFrameworkMoniker.NetCoreApp31);
#elif NETCOREAPP5_0
            Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.TargetFrameworkMoniker == TargetFrameworkMoniker.NetCoreApp50);
#endif
        }
예제 #3
0
 // ReSharper disable once VirtualMemberCallInConstructor
 public TheoryNetCore30Attribute(string skipReason)
 {
     if (RuntimeInformation.GetCurrentRuntime().RuntimeMoniker != RuntimeMoniker.NetCoreApp30)
     {
         Skip = skipReason;
     }
 }
예제 #4
0
        private ProcessStartInfo CreateStartInfo(Benchmark benchmark, string exeName, string args, string workingDirectory, IResolver resolver)
        {
            var start = new ProcessStartInfo
            {
                UseShellExecute        = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                CreateNoWindow         = true,
                WorkingDirectory       = workingDirectory
            };
            var runtime = benchmark.Job.Env.Runtime.IsDefault ? RuntimeInformation.GetCurrentRuntime() : benchmark.Job.Env.Runtime.SpecifiedValue;

            // TODO: use resolver
            switch (runtime)
            {
            case Runtime.Clr:
            case Runtime.Core:
                start.FileName  = exeName;
                start.Arguments = args;
                break;

            case Runtime.Mono:
                start.FileName  = "mono";
                start.Arguments = GetMonoArguments(benchmark.Job, exeName, args, resolver);
                break;

            default:
                throw new NotSupportedException("Runtime = " + runtime);
            }
            return(start);
        }
예제 #5
0
        public void UserCanSpecifyCustomNuGetPackageDependency()
        {
            var toolchain = RuntimeInformation.GetCurrentRuntime().GetToolchain(preferMsBuildToolchains: true);

            var job    = Job.Dry.With(toolchain).WithNuGet("Newtonsoft.Json", "11.0.2");
            var config = CreateSimpleConfig(job: job);

            CanExecute <WithCallToNewtonsoft>(config);
        }
예제 #6
0
        public void CurrentRuntimeIsProperlyRecognized()
        {
            var runtime = RuntimeInformation.GetCurrentRuntime();

#if NETFRAMEWORK
            Assert.True(runtime is ClrRuntime);
#elif NETCOREAPP2_1
            Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.TargetFrameworkMoniker == TargetFrameworkMoniker.NetCoreApp21);
#endif
        }
예제 #7
0
        [SuppressMessage("ReSharper", "UnusedMember.Global")] // TODO: should be used or removed
        public static IEnumerable <ValidationError> Validate(Job job)
        {
            if (job.Environment.Jit == Jit.RyuJit && !RuntimeInformation.HasRyuJit())
            {
                yield return(new ValidationError(true, "RyuJIT is requested but it is not available in current environment"));
            }
            var currentRuntime = RuntimeInformation.GetCurrentRuntime();

            if (job.Environment.Jit == Jit.LegacyJit && !(currentRuntime is ClrRuntime))
            {
                yield return(new ValidationError(true, $"LegacyJIT is requested but it is not available for {currentRuntime}"));
            }
        }
예제 #8
0
        private IToolchain GetToolchainThatGeneratesProjectFile()
        {
            switch (RuntimeInformation.GetCurrentRuntime())
            {
            case ClrRuntime _:
            case MonoRuntime _:
                return(CsProjClassicNetToolchain.Current.Value);

            case CoreRuntime _:
                return(CsProjCoreToolchain.Current.Value);

            case CoreRtRuntime _:
                return(CoreRtToolchain.LatestBuild);

            default:
                throw new NotSupportedException("Runtime not supported!");
            }
        }
예제 #9
0
 public void B()
 {
     Console.WriteLine($"// {RuntimeInformation.GetCurrentRuntime().GetToolchain()}");
 }
예제 #10
0
 public void Benchmark()
 {
     Console.WriteLine($"{AvoidParsingException} {RuntimeInformation.GetCurrentRuntime().GetToolchain()}");
 }
 public Runtime GetRuntime() => Job.Environment.HasValue(EnvironmentMode.RuntimeCharacteristic)
         ? Job.Environment.Runtime
         : RuntimeInformation.GetCurrentRuntime();