Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FRAMEWORK:=net6.0
FRAMEWORK:=net8.0
CONFIGURATION:=Release
ARCH:=$(subst aarch64,arm64,$(subst x86_64,x64,$(shell uname -m)))
RUNTIME:=linux-$(ARCH)
Expand Down
2 changes: 1 addition & 1 deletion Samples/FailingXUnitTest/FailingXUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Samples/PassingXUnitTest/PassingXUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Samples/TimeOutXUnitTest/TimeOutXUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Turkey.Tests/ProgramTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static string OSArchitectureName
Architecture.Arm => "arm",
Architecture.Arm64 => "arm64",
Architecture.S390x => "s390x",
(Architecture)8 => "ppc64le", // not defined for 'net6.0' target.
Architecture.Ppc64le => "ppc64le",
_ => throw new NotSupportedException(),
};
}
Expand Down
2 changes: 1 addition & 1 deletion Turkey.Tests/Turkey.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<RollForward>Major</RollForward>
</PropertyGroup>
Expand Down
45 changes: 11 additions & 34 deletions Turkey/DotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,14 @@ public List<Version> RuntimeVersions
{
get
{
ProcessStartInfo startInfo = new ProcessStartInfo()
{
FileName = DotnetFileName,
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = "--list-runtimes",
};
using (Process p = Process.Start(startInfo))
{
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
var list = output
.Split("\n", StringSplitOptions.RemoveEmptyEntries)
.Where(line => line.StartsWith("Microsoft.NETCore.App", StringComparison.Ordinal))
.Select(line => line.Split(" ")[1])
.Select(versionString => Version.Parse(versionString))
.OrderBy(x => x)
.ToList();
return list;
}
string output = ProcessRunner.Run(DotnetFileName, "--list-runtimes");
return output
.Split("\n", StringSplitOptions.RemoveEmptyEntries)
.Where(line => line.StartsWith("Microsoft.NETCore.App", StringComparison.Ordinal))
.Select(line => line.Split(" ")[1])
.Select(versionString => Version.Parse(versionString))
.OrderBy(x => x)
.ToList();
}
}

Expand All @@ -72,25 +60,14 @@ public List<Version> SdkVersions
{
get
{
ProcessStartInfo startInfo = new ProcessStartInfo()
{
FileName = DotnetFileName,
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = "--list-sdks",
};
using (Process p = Process.Start(startInfo))
{
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
var list = output

string output = ProcessRunner.Run(DotnetFileName, "--list-sdks");
return output
.Split("\n", StringSplitOptions.RemoveEmptyEntries)
.Select(line => line.Split(" ")[0])
.Select(versionString => Version.Parse(versionString))
.OrderBy(x => x)
.ToList();
return list;
}
}
}

Expand Down
28 changes: 28 additions & 0 deletions Turkey/ProcessExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
Expand All @@ -15,6 +16,33 @@ public static async Task<int> RunAsync(ProcessStartInfo psi, Action<string> logg
await process.WaitForExitAsync(logger, token).ConfigureAwait(false);
return process.ExitCode;
}

public static string Run(string filename, params string[] args)
{
ProcessStartInfo startInfo = new ProcessStartInfo()
{
FileName = filename,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
};
foreach (var arg in args)
{
startInfo.ArgumentList.Add(arg);
}
using (Process p = Process.Start(startInfo))
{
p.StandardInput.Close();
string stdout = p.StandardOutput.ReadToEnd();
p.WaitForExit();
if (p.ExitCode != 0)
{
string stderr = p.StandardError.ReadToEnd();
throw new InvalidOperationException($"Executing {filename} {string.Join(' ', args)} failed with exit code {p.ExitCode} and stderr: {stderr}");
}
return stdout;
}
}
}

public static class ProcessExtensions
Expand Down
18 changes: 18 additions & 0 deletions Turkey/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public TestRunner(SystemUnderTest system, DirectoryInfo root, bool verboseOutput

public async Task<TestResults> ScanAndRunAsync(List<TestOutput> outputs, string logDir, TimeSpan defaultTimeout)
{
LogEnvironment(logDir);

await outputs.ForEachAsync(output => output.AtStartupAsync()).ConfigureAwait(false);

Expand Down Expand Up @@ -161,5 +162,22 @@ public async Task<TestResults> ScanAndRunAsync(List<TestOutput> outputs, string

return results;
}

private static void LogEnvironment(string logDir)
{
foreach (var sourcePath in new[] { "/proc/cpuinfo", "/proc/meminfo", "/etc/os-release" })
{
if (File.Exists(sourcePath))
{
string destinationPath = Path.Combine(logDir, Path.GetFileName(sourcePath));
// Note: we don't use File.Copy because that copies the file permissions,
// which gives issues on successive runs since the files are non-writable.
File.WriteAllBytes(destinationPath, File.ReadAllBytes(sourcePath));
}
}

string unameOutput = ProcessRunner.Run("uname", "-a");
File.WriteAllText(Path.Combine(logDir, "uname"), unameOutput);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it makes sense to augment this with the versions of packages installed via rpm -qa or some such?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a meaningful addition. Let's add it in a separate PR.

}
}
2 changes: 1 addition & 1 deletion Turkey/Turkey.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<!-- Building Turkey with a source-built .NET SDK may fail if that SDK references a version for TargetFramework
that is not yet released. Setting TargetBundledFramework to 'true' enables building with such SDKs by using
the bundled framework instead. -->
Expand Down
Loading