Skip to content

Commit

Permalink
allow functional tests to use Git from PATH
Browse files Browse the repository at this point in the history
We implement the equivalent of the existing --test-scalar-on-path
functional test command-line option for Git also, namely by adding
a new --test-git-on-path option.

This permits the execution of the functional test suite on systems
where the default installation of Git may not be sufficient to
support Scalar.
  • Loading branch information
chrisd8088 committed Aug 17, 2020
1 parent 32af59b commit 274b0d1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Scalar.FunctionalTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public static void Main(string[] args)
ScalarTestConfig.NoSharedCache = true;
}

if (runner.HasCustomArg("--test-git-on-path"))
{
Console.WriteLine("Running tests against Git on path");
ScalarTestConfig.TestGitOnPath = true;
}

if (runner.HasCustomArg("--test-scalar-on-path"))
{
Console.WriteLine("Running tests against Scalar on path");
Expand Down
14 changes: 14 additions & 0 deletions Scalar.FunctionalTests/ScalarTestConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ public static class ScalarTestConfig

public static object[] GitRepoTestsValidateWorkTree { get; set; }

public static bool TestGitOnPath { get; set; }

public static string PathToGit
{
get
{
string gitBinaryFileName = "git" + Properties.Settings.Default.BinaryFileNameExtension;
return
TestGitOnPath ?
gitBinaryFileName :
Path.Combine(Properties.Settings.Default.PathToGitRoot, gitBinaryFileName);
}
}

public static bool TestScalarOnPath { get; set; }

public static string PathToScalar
Expand Down
6 changes: 3 additions & 3 deletions Scalar.FunctionalTests/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class Default
public static string CommitId { get; set; }
public static string ControlGitRepoRoot { get; set; }
public static string EnlistmentRoot { get; set; }
public static string PathToGit { get; set; }
public static string PathToGitRoot { get; set; }
public static string PathToScalarService { get; set; }
public static string BinaryFileNameExtension { get; set; }

Expand All @@ -40,7 +40,7 @@ public static void Initialize()
{
EnlistmentRoot = @"C:\Repos\ScalarFunctionalTests\enlistment";
PathToScalar = @"Scalar.exe";
PathToGit = @"C:\Program Files\Git\cmd\git.exe";
PathToGitRoot = @"C:\Program Files\Git\cmd";
PathToBash = @"C:\Program Files\Git\bin\bash.exe";

ControlGitRepoRoot = @"C:\Repos\ScalarFunctionalTests\ControlRepo";
Expand All @@ -55,7 +55,7 @@ public static void Initialize()
EnlistmentRoot = Path.Combine(root, "test");
ControlGitRepoRoot = Path.Combine(root, "control");
PathToScalar = "scalar";
PathToGit = "/usr/local/bin/git";
PathToGitRoot = "/usr/local/bin";
PathToBash = "/bin/bash";
BinaryFileNameExtension = string.Empty;
}
Expand Down
2 changes: 1 addition & 1 deletion Scalar.FunctionalTests/Tools/GitProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static ProcessResult InvokeProcess(string executionWorkingDirectory, stri

public static ProcessResult InvokeProcess(string executionWorkingDirectory, string command, Dictionary<string, string> environmentVariables = null, Stream inputStream = null)
{
ProcessStartInfo processInfo = new ProcessStartInfo(Properties.Settings.Default.PathToGit);
ProcessStartInfo processInfo = new ProcessStartInfo(ScalarTestConfig.PathToGit);
processInfo.WorkingDirectory = executionWorkingDirectory;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
Expand Down

0 comments on commit 274b0d1

Please sign in to comment.