forked from redhat-developer/dotnet-bunny
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5668a4a
Showing
27 changed files
with
701 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin/ | ||
obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
all: publish | ||
|
||
check: publish | ||
dotnet test Turkey.Tests | ||
|
||
publish: | ||
dotnet publish -c Release | ||
|
||
clean: | ||
rm -rf Turkey/bin Turkey/obj | ||
rm -rf Turkey.Tests/bin Turkey.Tests/obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Turkey | ||
|
||
This is a test runner for running integration/regression tests for | ||
.NET Core. | ||
|
||
It uses the same format for identifying, selecting and running tests | ||
as [dotnet-bunny](https://github.com/redhat-developer/dotnet-bunny/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Turkey.Tests | ||
{ | ||
public class BashTestTest | ||
{ | ||
|
||
} | ||
} |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Xunit; | ||
|
||
namespace Turkey.Tests | ||
{ | ||
public class RuntimeIdTest | ||
{ | ||
|
||
} | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> | ||
<PackageReference Include="xunit" Version="2.4.0" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="../Turkey/Turkey.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using System; | ||
using Xunit; | ||
|
||
using Version = Turkey.Version; | ||
|
||
namespace Turkey.Tests | ||
{ | ||
public class VersionTest | ||
{ | ||
[Fact] | ||
public void SimpleParse() | ||
{ | ||
var version = Version.Parse("2.1"); | ||
Assert.NotNull(version); | ||
Assert.Equal(2, version.Major); | ||
Assert.Equal(1, version.Minor); | ||
} | ||
|
||
[Theory] | ||
[InlineData("1")] | ||
[InlineData("1.0")] | ||
[InlineData("1.0.0")] | ||
[InlineData("1.0.0.0")] | ||
[InlineData("1.0.0.preview3")] | ||
[InlineData("1.0.0.a1")] | ||
[InlineData("1.0.0.a.1")] | ||
public void PareableVersions(string input) | ||
{ | ||
Version.Parse(input); | ||
} | ||
|
||
[Fact] | ||
public void Equality() | ||
{ | ||
var v1 = Version.Parse("1.0"); | ||
var v2 = Version.Parse("1.0"); | ||
|
||
Assert.Equal(v1, v2); | ||
Assert.True(v1 == v2); | ||
Assert.False(v1 != v2); | ||
} | ||
|
||
[Theory] | ||
[InlineData(".1")] | ||
public void InvalidVersionsThrow(string version) | ||
{ | ||
Assert.Throws<FormatException>(() => Version.Parse(version)); | ||
} | ||
|
||
[Theory] | ||
[InlineData("1")] | ||
[InlineData("1.0")] | ||
[InlineData("1.0.0")] | ||
[InlineData("1.0.0.0.0")] | ||
[InlineData("1.0.0.0.0.0")] | ||
public void TrailingZerosDoNotMatter(string version) | ||
{ | ||
var v1 = Version.Parse("1.0"); | ||
var v2 = Version.Parse(version); | ||
|
||
Assert.Equal(v1, v2); | ||
Assert.True(v1 == v2); | ||
Assert.False(v1 != v2); | ||
} | ||
|
||
[Theory] | ||
[InlineData("0.0.1")] | ||
[InlineData("0.0.0.1")] | ||
public void LeadingZerosMatter(string version) | ||
{ | ||
var v1 = Version.Parse("0.1"); | ||
var v2 = Version.Parse(version); | ||
|
||
Assert.NotEqual(v1, v2); | ||
Assert.False(v1 == v2); | ||
Assert.True(v1 != v2); | ||
} | ||
|
||
[Fact] | ||
public void VersionComparisons() | ||
{ | ||
var v1 = Version.Parse("1.0"); | ||
var v2 = Version.Parse("1.0.1"); | ||
var v3 = Version.Parse("1.0.2"); | ||
var v4 = Version.Parse("0.1.2"); | ||
var v5 = Version.Parse("0.9.2"); | ||
var v6 = Version.Parse("0.10.2"); | ||
|
||
Assert.True(v1 < v2); | ||
Assert.True(v2 < v3); | ||
Assert.True(v3 > v2); | ||
Assert.True(v2 > v1); | ||
Assert.True(v4 < v1); | ||
Assert.True(v4 < v5); | ||
Assert.True(v6 > v5); | ||
Assert.True(v6 > v4); | ||
Assert.True(v6 < v1); | ||
} | ||
|
||
[Fact] | ||
public void TestToString() | ||
{ | ||
var v1 = Version.Parse("1.0"); | ||
Assert.Equal("1.0", v1.ToString()); | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26124.0 | ||
MinimumVisualStudioVersion = 15.0.26124.0 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Turkey", "Turkey\Turkey.csproj", "{A16358D4-D37D-4E4D-92A5-142A3D81972A}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Turkey.Tests", "Turkey.Tests\Turkey.Tests.csproj", "{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Debug|x64.Build.0 = Debug|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Debug|x86.Build.0 = Debug|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Release|x64.ActiveCfg = Release|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Release|x64.Build.0 = Release|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Release|x86.ActiveCfg = Release|Any CPU | ||
{A16358D4-D37D-4E4D-92A5-142A3D81972A}.Release|x86.Build.0 = Release|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Debug|x64.Build.0 = Debug|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Debug|x86.Build.0 = Debug|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Release|x64.ActiveCfg = Release|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Release|x64.Build.0 = Release|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Release|x86.ActiveCfg = Release|Any CPU | ||
{AA784CA2-3D2D-4B17-A5D9-40647E1518BF}.Release|x86.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
namespace Turkey | ||
{ | ||
public class BashTest : Test | ||
{ | ||
private DirectoryInfo testDirectory; | ||
|
||
public BashTest(DirectoryInfo testDirectory) | ||
{ | ||
this.testDirectory = testDirectory; | ||
} | ||
|
||
protected override async Task<TestResult> InternalRunAsync() | ||
{ | ||
FileInfo testFile = new FileInfo(testDirectory + "/test.sh"); | ||
if (!testFile.Exists) | ||
{ | ||
throw new Exception(); | ||
} | ||
ProcessStartInfo startInfo = new ProcessStartInfo() | ||
{ | ||
FileName = testFile.FullName, | ||
WorkingDirectory = testDirectory.FullName, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
}; | ||
Process p = Process.Start(startInfo); | ||
p.WaitForExit(); | ||
// TODO timeout + kill | ||
return new TestResult() | ||
{ | ||
Status = (p.ExitCode == 0) ? TestStatus.Passed: TestStatus.Failed, | ||
StandardOutput = p.StandardOutput.ReadToEnd(), | ||
StandardError = p.StandardError.ReadToEnd(), | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Turkey | ||
{ | ||
public class DotNet | ||
{ | ||
public List<string> RuntimeVersions { get; } | ||
public List<string> LatestRuntimeVersion { get; } | ||
|
||
public List<string> SdkVersions { get; } | ||
public List<string> LatestSdkVersion { get; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace Turkey | ||
{ | ||
public class NuGet | ||
{ | ||
public static async Task<bool> IsPackageLiveAsync(string name, string version) | ||
{ | ||
return false; | ||
} | ||
|
||
public static async Task<string> GetProdConFeedAsync(string branchName) | ||
{ | ||
return ""; | ||
} | ||
|
||
public static async Task<string> GenerateNuGetConfig(List<string> urls) | ||
{ | ||
return ""; | ||
} | ||
|
||
public static async Task CleanLocalCache() | ||
{ | ||
foreach (string dir in new string[] { "~/.nuget/packages", "~/.local/share/NuGet/"}) | ||
{ | ||
|
||
} | ||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.IO; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
using System.CommandLine; | ||
using System.CommandLine.Builder; | ||
using System.CommandLine.Invocation; | ||
|
||
namespace Turkey | ||
{ | ||
class Program | ||
{ | ||
public static Option verboseOption = new Option( | ||
new string[] { "--verbose", "-v" }, | ||
"Show verbose output", new Argument<bool>()); | ||
|
||
public static Option logDirectoryOption = new Option( | ||
new string[] { "--log-directory", "-l" }, | ||
"Set directory for writing log files", new Argument<string>()); | ||
|
||
public static async Task<int> Run(bool verbose, string logDir) | ||
{ | ||
var runtimeId = new RuntimeId(); | ||
List<string> currentRuntimeIds = runtimeId.Current; | ||
|
||
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); | ||
|
||
DirectoryInfo logDirectory; | ||
if (string.IsNullOrEmpty(logDir)) | ||
{ | ||
logDirectory = currentDirectory; | ||
} | ||
else | ||
{ | ||
logDirectory = new DirectoryInfo(logDir); | ||
} | ||
|
||
TestRunner runner = new TestRunner(currentDirectory, verbose, logDirectory); | ||
|
||
var results = await runner.ScanAndRunAsync(); | ||
|
||
Console.WriteLine($"Total: {results.Total} Passed: {results.Passed} Failed: {results.Failed}"); | ||
|
||
int exitCode = (results.Total == results.Passed) ? 0 : 1; | ||
return exitCode; | ||
} | ||
|
||
static async Task<int> Main(string[] args) | ||
{ | ||
Func<bool, string, Task<int>> action = Run; | ||
var rootCommand = new RootCommand(description: "A test runner for running standalone bash-based or xunit tests", | ||
handler: CommandHandler.Create(action)); | ||
|
||
var parser = new CommandLineBuilder(rootCommand) | ||
.AddOption(logDirectoryOption) | ||
.AddOption(verboseOption) | ||
.UseVersionOption() | ||
.UseHelp() | ||
.UseParseErrorReporting() | ||
.Build(); | ||
return await parser.InvokeAsync(args); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Turkey | ||
{ | ||
class RuntimeId | ||
{ | ||
|
||
public List<string> KnownRuntimes | ||
{ | ||
get => new List<string>(); | ||
} | ||
|
||
|
||
public List<string> Current | ||
{ | ||
get => new List<string>(); | ||
} | ||
} | ||
} |
Oops, something went wrong.