-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
8 changed files
with
115 additions
and
237 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 |
---|---|---|
@@ -1,25 +1,24 @@ | ||
using System.IO; | ||
using NUnit.Framework; | ||
using Selenium.WebDriver.GeckoDriver.NuPkg.Test.Lib; | ||
namespace Selenium.WebDriver.GeckoDriver.NuPkg.Test; | ||
|
||
namespace Selenium.WebDriver.GeckoDriver.NuPkg.Test | ||
[Parallelizable(ParallelScope.All)] | ||
public class BuildProjectABTest | ||
{ | ||
[Parallelizable(ParallelScope.All)] | ||
public class BuildProjectABTest | ||
[Test] | ||
public async Task Output_of_ProjectB_Contains_DriverFile_Test() | ||
{ | ||
[Test] | ||
public void Output_of_ProjectB_Contains_DriverFile_Test() | ||
{ | ||
using var workSpace = new WorkSpace(copyFrom: "ProjectAB"); | ||
var unitTestProjectDir = FileIO.FindContainerDirToAncestor("*.csproj"); | ||
using var workDir = WorkDirectory.CreateCopyFrom(Path.Combine(unitTestProjectDir, "ProjectAB"), item => item.Name is not "obj" and not "bin"); | ||
|
||
var devenv = @"C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\devenv.exe"; | ||
Shell.Run(workSpace, "nuget", "restore").Is(0); | ||
Shell.Run(workSpace, devenv, "ProjectAB.sln", "/Build").Is(0); | ||
var devenvExe = @"C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\devenv.exe"; | ||
var nuget = await XProcess.Start("nuget", "restore", workDir).WaitForExitAsync(); | ||
nuget.ExitCode.Is(0, message: nuget.Output); | ||
|
||
var outDir = Path.Combine(workSpace, "ProjectB", "bin", "Debug", "net472"); | ||
var driverFullPath1 = Path.Combine(outDir, "geckodriver"); | ||
var driverFullPath2 = Path.Combine(outDir, "geckodriver.exe"); | ||
(File.Exists(driverFullPath1) || File.Exists(driverFullPath2)).IsTrue(); | ||
} | ||
var devenv = await XProcess.Start(devenvExe, "ProjectAB.sln /Build", workDir).WaitForExitAsync(); | ||
devenv.ExitCode.Is(0, message: devenv.Output); | ||
|
||
var outDir = Path.Combine(workDir, "ProjectB", "bin", "Debug", "net472"); | ||
var driverFullPath1 = Path.Combine(outDir, "geckodriver"); | ||
var driverFullPath2 = Path.Combine(outDir, "geckodriver.exe"); | ||
(File.Exists(driverFullPath1) || File.Exists(driverFullPath2)).IsTrue(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,105 +1,107 @@ | ||
using System.IO; | ||
using NUnit.Framework; | ||
using Selenium.WebDriver.GeckoDriver.NuPkg.Test.Lib; | ||
using static Selenium.WebDriver.GeckoDriver.NuPkg.Test.Lib.ExecutableFile; | ||
namespace Selenium.WebDriver.GeckoDriver.NuPkg.Test; | ||
|
||
namespace Selenium.WebDriver.GeckoDriver.NuPkg.Test | ||
[Parallelizable(ParallelScope.All)] | ||
public class BuildTest | ||
{ | ||
[Parallelizable(ParallelScope.All)] | ||
public class BuildTest | ||
public static object[][] Runtimes => new object[][]{ | ||
new object[] { "win7-x86", "geckodriver.exe", Format.PE32 }, | ||
new object[] { "win-x64", "geckodriver.exe", Format.PE64 }, | ||
new object[] { "osx.10.12-x64", "geckodriver", Format.MachO }, | ||
new object[] { "linux-x64", "geckodriver", Format.ELF }, | ||
}; | ||
|
||
[Test] | ||
[TestCaseSource(nameof(Runtimes))] | ||
public async Task BuildWithRuntimeIdentifier_Test(string rid, string driverFileName, Format executableFileFormat) | ||
{ | ||
public static object[][] Runtimes => new object[][]{ | ||
new object[] { "win7-x86", "geckodriver.exe", Format.PE32 }, | ||
new object[] { "win-x64", "geckodriver.exe", Format.PE64 }, | ||
new object[] { "osx.10.12-x64", "geckodriver", Format.MachO }, | ||
new object[] { "linux-x64", "geckodriver", Format.ELF }, | ||
}; | ||
var unitTestProjectDir = FileIO.FindContainerDirToAncestor("*.csproj"); | ||
using var workDir = WorkDirectory.CreateCopyFrom(Path.Combine(unitTestProjectDir, "Project"), item => item.Name is not "obj" and not "bin"); | ||
|
||
[Test] | ||
[TestCaseSource(nameof(Runtimes))] | ||
public void BuildWithRuntimeIdentifier_Test(string rid, string driverFileName, Format executableFileFormat) | ||
{ | ||
using var workSpace = new WorkSpace(copyFrom: "Project"); | ||
var dotnet = await XProcess.Start("dotnet", $"build -r {rid} -o out", workDir).WaitForExitAsync(); | ||
dotnet.ExitCode.Is(0, message: dotnet.Output); | ||
|
||
var exitCode = Shell.Run(workSpace, "dotnet", "build", "-r", rid, "-o", "out"); | ||
exitCode.Is(0); | ||
var driverFullPath = Path.Combine(workDir, "out", driverFileName); | ||
File.Exists(driverFullPath).IsTrue(); | ||
|
||
var driverFullPath = Path.Combine(workSpace, "out", driverFileName); | ||
File.Exists(driverFullPath).IsTrue(); | ||
DetectFormat(driverFullPath).Is(executableFileFormat); | ||
} | ||
|
||
DetectFormat(driverFullPath).Is(executableFileFormat); | ||
} | ||
[Test] | ||
[TestCaseSource(nameof(Runtimes))] | ||
public async Task PublishWithRuntimeIdentifier_NoPublish_Test(string rid, string driverFileName, Format _) | ||
{ | ||
var unitTestProjectDir = FileIO.FindContainerDirToAncestor("*.csproj"); | ||
using var workDir = WorkDirectory.CreateCopyFrom(Path.Combine(unitTestProjectDir, "Project"), item => item.Name is not "obj" and not "bin"); | ||
|
||
[Test] | ||
[TestCaseSource(nameof(Runtimes))] | ||
public void PublishWithRuntimeIdentifier_NoPublish_Test(string rid, string driverFileName, Format _) | ||
{ | ||
using var workSpace = new WorkSpace(copyFrom: "Project"); | ||
var dotnet = await XProcess.Start("dotnet", $"publish -r {rid} -o out", workDir).WaitForExitAsync(); | ||
dotnet.ExitCode.Is(0, message: dotnet.Output); | ||
|
||
var exitCode = Shell.Run(workSpace, "dotnet", "publish", "-r", rid, "-o", "out"); | ||
exitCode.Is(0); | ||
var driverFullPath = Path.Combine(workDir, "out", driverFileName); | ||
File.Exists(driverFullPath).IsFalse(); | ||
} | ||
|
||
var driverFullPath = Path.Combine(workSpace, "out", driverFileName); | ||
File.Exists(driverFullPath).IsFalse(); | ||
} | ||
[Test] | ||
[TestCaseSource(nameof(Runtimes))] | ||
public async Task PublishWithRuntimeIdentifier_with_MSBuildProp_Test(string rid, string driverFileName, Format executableFileFormat) | ||
{ | ||
var unitTestProjectDir = FileIO.FindContainerDirToAncestor("*.csproj"); | ||
using var workDir = WorkDirectory.CreateCopyFrom(Path.Combine(unitTestProjectDir, "Project"), item => item.Name is not "obj" and not "bin"); | ||
|
||
[Test] | ||
[TestCaseSource(nameof(Runtimes))] | ||
public void PublishWithRuntimeIdentifier_with_MSBuildProp_Test(string rid, string driverFileName, Format executableFileFormat) | ||
{ | ||
using var workSpace = new WorkSpace(copyFrom: "Project"); | ||
var dotnet = await XProcess.Start("dotnet", $"publish -r {rid} -o out -p:PublishGeckoDriver=true", workDir).WaitForExitAsync(); | ||
dotnet.ExitCode.Is(0, message: dotnet.Output); | ||
|
||
var exitCode = Shell.Run(workSpace, "dotnet", "publish", "-r", rid, "-o", "out", "-p:PublishGeckoDriver=true"); | ||
exitCode.Is(0); | ||
var driverFullPath = Path.Combine(workDir, "out", driverFileName); | ||
File.Exists(driverFullPath).IsTrue(); | ||
|
||
var driverFullPath = Path.Combine(workSpace, "out", driverFileName); | ||
File.Exists(driverFullPath).IsTrue(); | ||
DetectFormat(driverFullPath).Is(executableFileFormat); | ||
} | ||
|
||
DetectFormat(driverFullPath).Is(executableFileFormat); | ||
} | ||
[Test] | ||
[TestCaseSource(nameof(Runtimes))] | ||
public async Task PublishWithRuntimeIdentifier_with_DefineConstants_Test(string rid, string driverFileName, Format executableFileFormat) | ||
{ | ||
var unitTestProjectDir = FileIO.FindContainerDirToAncestor("*.csproj"); | ||
using var workDir = WorkDirectory.CreateCopyFrom(Path.Combine(unitTestProjectDir, "Project"), item => item.Name is not "obj" and not "bin"); | ||
|
||
[Test] | ||
[TestCaseSource(nameof(Runtimes))] | ||
public void PublishWithRuntimeIdentifier_with_DefineConstants_Test(string rid, string driverFileName, Format executableFileFormat) | ||
{ | ||
using var workSpace = new WorkSpace(copyFrom: "Project"); | ||
var dotnet = await XProcess.Start("dotnet", $"publish -r {rid} -o out -p:DefineConstants=_PUBLISH_GECKODRIVER", workDir).WaitForExitAsync(); | ||
dotnet.ExitCode.Is(0, message: dotnet.Output); | ||
|
||
var exitCode = Shell.Run(workSpace, "dotnet", "publish", "-r", rid, "-o", "out", "-p:DefineConstants=_PUBLISH_GECKODRIVER"); | ||
exitCode.Is(0); | ||
var driverFullPath = Path.Combine(workDir, "out", driverFileName); | ||
File.Exists(driverFullPath).IsTrue(); | ||
|
||
var driverFullPath = Path.Combine(workSpace, "out", driverFileName); | ||
File.Exists(driverFullPath).IsTrue(); | ||
DetectFormat(driverFullPath).Is(executableFileFormat); | ||
} | ||
|
||
DetectFormat(driverFullPath).Is(executableFileFormat); | ||
} | ||
[Test] | ||
public async Task Publish_with_SingleFileEnabled_Test() | ||
{ | ||
var rid = "win-x64"; | ||
var driverFileName = "geckodriver.exe"; | ||
var executableFileFormat = Format.PE64; | ||
|
||
var unitTestProjectDir = FileIO.FindContainerDirToAncestor("*.csproj"); | ||
using var workDir = WorkDirectory.CreateCopyFrom(Path.Combine(unitTestProjectDir, "Project"), item => item.Name is not "obj" and not "bin"); | ||
var publishCommand = new[] { | ||
"dotnet", "publish", "-r", rid, "-o", "out", | ||
"-c:Release", | ||
"-p:PublishGeckoDriver=true", | ||
"-p:PublishSingleFile=true", | ||
"-p:SelfContained=false" | ||
}; | ||
|
||
[Test] | ||
public void Publish_with_SingleFileEnabled_Test() | ||
// IMPORTANT: 2nd time of publishing, sometimes lost driver file in the published folder, so we have to validate it.. | ||
for (var i = 0; i < 2; i++) | ||
{ | ||
var rid = "win-x64"; | ||
var driverFileName = "geckodriver.exe"; | ||
var executableFileFormat = Format.PE64; | ||
|
||
using var workSpace = new WorkSpace(copyFrom: "Project"); | ||
var publishCommand = new[] { | ||
"dotnet", "publish", "-r", rid, "-o", "out", | ||
"-c:Release", | ||
"-p:PublishGeckoDriver=true", | ||
"-p:PublishSingleFile=true", | ||
"-p:SelfContained=false" | ||
}; | ||
|
||
// IMPORTANT: 2nd time of publishing, sometimes lost driver file in the published folder, so we have to validate it.. | ||
for (var i = 0; i < 2; i++) | ||
{ | ||
var exitCode = Shell.Run(workSpace, publishCommand); | ||
exitCode.Is(0); | ||
|
||
var driverFullPath = Path.Combine(workSpace, "out", driverFileName); | ||
File.Exists(driverFullPath).IsTrue(); | ||
|
||
DetectFormat(driverFullPath).Is(executableFileFormat); | ||
} | ||
var dotnet = await XProcess.Start( | ||
filename: publishCommand.First(), | ||
arguments: String.Join(' ', publishCommand.Skip(1)), | ||
workDir).WaitForExitAsync(); | ||
dotnet.ExitCode.Is(0, message: dotnet.Output); | ||
|
||
var driverFullPath = Path.Combine(workDir, "out", driverFileName); | ||
File.Exists(driverFullPath).IsTrue(); | ||
|
||
DetectFormat(driverFullPath).Is(executableFileFormat); | ||
} | ||
} | ||
} |
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,5 @@ | ||
global using NUnit.Framework; | ||
global using Toolbelt; | ||
global using Toolbelt.Diagnostics; | ||
global using Format = Toolbelt.ExecutableFileFormatType; | ||
global using static Toolbelt.ExecutableFileFormat; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.