Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run GitRepoTests in sparse mode #84

Merged
merged 20 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8a50311
Run GitRepoTests in sparse mode
derrickstolee Aug 23, 2019
9a7b48d
cleanup: delete fastfetch references
derrickstolee Aug 23, 2019
67f41f7
Wire the sparse clone mode to GitRepoTests
derrickstolee Aug 23, 2019
42bd5f8
Use Git-style paths for sparse-checkout
derrickstolee Aug 23, 2019
bbfa9c5
Fix functional test breakages
derrickstolee Aug 23, 2019
f85b2c0
Always exclude tests that require status cache
derrickstolee Aug 23, 2019
a657239
CloneVerb: move most state to private members
derrickstolee Aug 26, 2019
c0eaeaf
CloneVerb: split TryCreateClone into pieces
derrickstolee Aug 26, 2019
6fd8bfe
CloneVerb: rearrange checkout to be after mount
derrickstolee Aug 26, 2019
d6b1baa
CloneVerb: extract 'DoClone()' from 'Execute()'
derrickstolee Aug 26, 2019
8f3e639
CloneVerb: force checkout won't fail this way after mount
derrickstolee Aug 26, 2019
c084232
GitRepoTests: drop trailing directory separator
derrickstolee Aug 26, 2019
4b4756c
CloneVerb: expand using for tracer
derrickstolee Aug 26, 2019
3957f43
SparseTests: update prefix check to match cone mode
derrickstolee Aug 26, 2019
5fa1445
CloneVerb: add extra tracing for error in functional test
derrickstolee Aug 26, 2019
a93e82e
SparseMode: fix parent path logic
derrickstolee Aug 26, 2019
61a88e5
Use SparseVerb in functional tests
derrickstolee Aug 26, 2019
325c63c
CloneTests: one test still needs update
derrickstolee Aug 26, 2019
4e1e190
CloneVerb: newline and exception filtering
derrickstolee Aug 27, 2019
14a29d8
CloneVerb: cleanups and error reporting on prefetch
derrickstolee Aug 27, 2019
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
35 changes: 10 additions & 25 deletions Scalar.FunctionalTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,17 @@ public static void Main(string[] args)
HashSet<string> includeCategories = new HashSet<string>();
HashSet<string> excludeCategories = new HashSet<string>();

// Run all GitRepoTests with sparse mode
ScalarTestConfig.GitRepoTestsValidateWorkTree =
new object[]
{
new object[] { Settings.ValidateWorkingTreeMode.SparseMode },
};

if (runner.HasCustomArg("--full-suite"))
{
Console.WriteLine("Running the full suite of tests");

List<object[]> modes = new List<object[]>();
foreach (Settings.ValidateWorkingTreeMode mode in Enum.GetValues(typeof(Settings.ValidateWorkingTreeMode)))
{
modes.Add(new object[] { mode });
}

ScalarTestConfig.GitRepoTestsValidateWorkTree = modes.ToArray();

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
ScalarTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllWindowsRunners;
Expand All @@ -57,22 +56,6 @@ public static void Main(string[] args)
}
else
{
Settings.ValidateWorkingTreeMode validateMode = Settings.ValidateWorkingTreeMode.Full;

if (runner.HasCustomArg("--sparse-mode"))
{
validateMode = Settings.ValidateWorkingTreeMode.SparseMode;

// Only test the git commands in sparse mode for splitting out tests in builds
includeCategories.Add(Categories.GitCommands);
}

ScalarTestConfig.GitRepoTestsValidateWorkTree =
new object[]
{
new object[] { validateMode },
};

if (runner.HasCustomArg("--extra-only"))
{
Console.WriteLine("Running only the tests marked as ExtraCoverage");
Expand All @@ -95,13 +78,15 @@ public static void Main(string[] args)
includeCategories.Remove(Categories.ExtraCoverage);
}

// Not just Mac, but no platform has status cache.
excludeCategories.Add(Categories.MacTODO.NeedsStatusCache);

if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
excludeCategories.Add(Categories.MacTODO.NeedsNewFolderCreateNotification);
excludeCategories.Add(Categories.MacTODO.NeedsScalarConfig);
excludeCategories.Add(Categories.MacTODO.NeedsDehydrate);
excludeCategories.Add(Categories.MacTODO.NeedsServiceVerb);
excludeCategories.Add(Categories.MacTODO.NeedsStatusCache);
excludeCategories.Add(Categories.MacTODO.TestNeedsToLockFile);
excludeCategories.Add(Categories.WindowsOnly);
}
Expand Down
9 changes: 0 additions & 9 deletions Scalar.FunctionalTests/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public static class Default
public static string Commitish { get; set; }
public static string ControlGitRepoRoot { get; set; }
public static string EnlistmentRoot { get; set; }
public static string FastFetchBaseRoot { get; set; }
public static string FastFetchRoot { get; set; }
public static string FastFetchControl { get; set; }
public static string PathToGit { get; set; }
public static string PathToScalarService { get; set; }
public static string BinaryFileNameExtension { get; set; }
Expand All @@ -45,9 +42,6 @@ public static void Initialize()
PathToBash = @"C:\Program Files\Git\bin\bash.exe";

ControlGitRepoRoot = @"C:\Repos\ScalarFunctionalTests\ControlRepo";
FastFetchBaseRoot = @"C:\Repos\ScalarFunctionalTests\FastFetch";
FastFetchRoot = Path.Combine(FastFetchBaseRoot, "test");
FastFetchControl = Path.Combine(FastFetchBaseRoot, "control");
PathToScalarService = @"Scalar.Service.exe";
BinaryFileNameExtension = ".exe";
}
Expand All @@ -58,9 +52,6 @@ public static void Initialize()
"Scalar.FT");
EnlistmentRoot = Path.Combine(root, "test");
ControlGitRepoRoot = Path.Combine(root, "control");
FastFetchBaseRoot = Path.Combine(root, "FastFetch");
FastFetchRoot = Path.Combine(FastFetchBaseRoot, "test");
FastFetchControl = Path.Combine(FastFetchBaseRoot, "control");
PathToScalar = "scalar";
PathToGit = "/usr/local/bin/git";
PathToBash = "/bin/bash";
Expand Down
26 changes: 18 additions & 8 deletions Scalar.FunctionalTests/Should/FileSystemShouldExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public static string ShouldNotExistOnDisk(this string path, FileSystemRunner run

public class FileAdapter
{
private const int MaxWaitMS = 2000;
private const int ThreadSleepMS = 100;

private FileSystemRunner runner;

public FileAdapter(string path, FileSystemRunner runner)
Expand Down Expand Up @@ -260,6 +257,18 @@ private static bool IsMatchedPath(FileSystemInfo info, string repoRoot, string[]
}

string localPath = info.FullName.Substring(repoRoot.Length + 1);
int parentLength = localPath.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
derrickstolee marked this conversation as resolved.
Show resolved Hide resolved

string parentPath = null;

if ((info.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
{
parentPath = localPath;
}
else if (parentLength > 0)
{
parentPath = localPath.Substring(0, parentLength + 1);
}

if (localPath.Equals(".git", StringComparison.OrdinalIgnoreCase))
{
Expand All @@ -268,7 +277,7 @@ private static bool IsMatchedPath(FileSystemInfo info, string repoRoot, string[]
return true;
}

if (!localPath.Contains(System.IO.Path.DirectorySeparatorChar) &&
if (parentPath == null &&
(info.Attributes & FileAttributes.Directory) != FileAttributes.Directory)
{
// If it is a file in the root folder, then include it.
Expand All @@ -277,15 +286,15 @@ private static bool IsMatchedPath(FileSystemInfo info, string repoRoot, string[]

foreach (string prefixDir in prefixes)
{
if (localPath.StartsWith(prefixDir, StringComparison.OrdinalIgnoreCase))
if (localPath.Equals(prefixDir, StringComparison.OrdinalIgnoreCase) ||
localPath.StartsWith(prefixDir + System.IO.Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
return true;
}

if (prefixDir.StartsWith(localPath, StringComparison.OrdinalIgnoreCase) &&
Directory.Exists(info.FullName))
if (parentPath != null && prefixDir.StartsWith(parentPath, StringComparison.OrdinalIgnoreCase))
{
// For example: localPath = "Scalar" and prefix is "Scalar\\Scalar".
// For example: localPath = "Scalar\\file.txt", parentPath="Scalar\\" and prefix is "Scalar\\Scalar".
return true;
}
}
Expand All @@ -305,6 +314,7 @@ private static void CompareDirectories(
IEnumerable<FileSystemInfo> actualEntries = new DirectoryInfo(actualPath).EnumerateFileSystemInfos("*", SearchOption.AllDirectories);

string dotGitFolder = System.IO.Path.DirectorySeparatorChar + TestConstants.DotGit.Root + System.IO.Path.DirectorySeparatorChar;

IEnumerator<FileSystemInfo> expectedEnumerator = expectedEntries
.Where(x => !x.FullName.Contains(dotGitFolder))
.OrderBy(x => x.FullName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void CloneWithLocalCachePathWithinSrc()

[TestCase]
[Category(Categories.MacOnly)]
[Category(Categories.NeedsUpdatesForNonVirtualizedMode)]
public void CloneWithDefaultLocalCacheLocation()
{
FileSystemRunner fileSystem = FileSystemRunner.DefaultRunner;
Expand All @@ -57,11 +58,15 @@ public void CloneWithDefaultLocalCacheLocation()
string newEnlistmentRoot = ScalarFunctionalTestEnlistment.GetUniqueEnlistmentRoot();

ProcessStartInfo processInfo = new ProcessStartInfo(ScalarTestConfig.PathToScalar);

// Needs update for non-virtualized mode: this used to have --no-mount to avoid an issue
// with registering the mount with the service.
processInfo.Arguments = $"clone {Properties.Settings.Default.RepoToClone} {newEnlistmentRoot} --no-prefetch";
processInfo.WindowStyle = ProcessWindowStyle.Hidden;
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
processInfo.WorkingDirectory = Properties.Settings.Default.EnlistmentRoot;

ProcessResult result = ProcessHelper.Run(processInfo);
result.ExitCode.ShouldEqual(0, result.Errors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class LooseObjectStepTests : TestsWithEnlistmentPerFixture
// Set forcePerRepoObjectCache to true to avoid any of the tests inadvertently corrupting
// the cache
public LooseObjectStepTests()
: base(forcePerRepoObjectCache: false)
: base(forcePerRepoObjectCache: true, skipPrefetchDuringClone: false)
derrickstolee marked this conversation as resolved.
Show resolved Hide resolved
{
this.fileSystem = new SystemIORunner();
}
Expand All @@ -31,6 +31,7 @@ public LooseObjectStepTests()
[Order(1)]
public void NoLooseObjectsDoesNothing()
{
this.Enlistment.UnmountScalar();
derrickstolee marked this conversation as resolved.
Show resolved Hide resolved
this.DeleteFiles(this.GetLooseObjectFiles());

this.DeleteFiles(this.GetLooseObjectFiles());
Expand Down
Loading