Skip to content

Commit

Permalink
Merge pull request #536 from microsoft/revert-535-test-removal
Browse files Browse the repository at this point in the history
Revert "FunctionalTests: remove GitCommands tests"
  • Loading branch information
dscho authored Jul 23, 2024
2 parents c098705 + 9081c25 commit 4cdf253
Show file tree
Hide file tree
Showing 16 changed files with 2,872 additions and 1 deletion.
96 changes: 95 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, windows-2019, macos-13]
os: [ ubuntu-20.04, windows-2019, macos-10.15]
features: [ignored]

env:
Expand All @@ -43,3 +43,97 @@ jobs:

- name: Unit test
run: dotnet test --no-restore

- name: Setup platform (Linux)
if: runner.os == 'Linux'
run: |
echo "BUILD_PLATFORM=${{ runner.os }}" >>$GITHUB_ENV
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.features }}" >>$GITHUB_ENV
- name: Setup platform (Mac)
if: runner.os == 'macOS'
run: |
echo 'BUILD_PLATFORM=Mac' >>$GITHUB_ENV
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.features }}" >>$GITHUB_ENV
- name: Setup platform (Windows)
if: runner.os == 'Windows'
run: |
echo "BUILD_PLATFORM=${{ runner.os }}" >>$env:GITHUB_ENV
echo 'BUILD_FILE_EXT=.exe' >>$env:GITHUB_ENV
echo "TRACE2_BASENAME=Trace2.${{ github.run_id }}__${{ github.run_number }}__${{ matrix.os }}__${{ matrix.features }}" >>$env:GITHUB_ENV
- name: Setup Git installer
shell: bash
run: |
GIT_VERSION=$(grep '<GitPackageVersion>' Directory.Build.props | grep -Eo '[0-9.]+(-\w+)*')
cd ../out
dotnet new classlib -n Scalar.GitInstaller
cd Scalar.GitInstaller
cp ../../scalar/nuget.config .
dotnet add Scalar.GitInstaller.csproj package "GitFor${BUILD_PLATFORM}.GVFS.Installer" --package-directory . --version "$GIT_VERSION" --source "https://pkgs.dev.azure.com/gvfs/ci/_packaging/Dependencies/nuget/v3/index.json"
- name: Install Git (Linux)
if: runner.os == 'Linux'
run: |
cd ../out/Scalar.GitInstaller
sudo apt-get install -y $(find . -type f -name '*.deb')
- name: Install Git (Mac)
if: runner.os == 'macOS'
run: |
cd ../out/Scalar.GitInstaller
sudo /usr/sbin/installer -pkg $(find . -type f -name '*.pkg') -target /
- name: Install Git (Windows)
if: runner.os == 'Windows'
run: |
Set-Location -Path ..\out\Scalar.GitInstaller
Write-Host 'Uninstalling Git ...'
foreach ($file in Get-ChildItem 'C:\Program Files\Git' -Recurse -File -Include 'unins*.exe') {
& $file.Fullname /VERYSILENT /SUPPRESSMSGBOXES /NORESTART
Wait-Process -Name $file.Basename
}
Remove-Item 'C:\Program Files\Git' -Recurse -Force
Write-Host 'Installing GitForWindows ...'
$files = Get-ChildItem . -Recurse -File -Include 'Git-*.vfs.*.exe'
& $files[0].Fullname /DIR="C:\Program Files\Git" /NOICONS /COMPONENTS="ext,ext\shellhere,ext\guihere,assoc,assoc_sh,scalar" /GROUP="Git" /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /ALLOWDOWNGRADE=1 /LOG=install.log
Wait-Process $files[0].Basename
Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\GitForWindows'
- name: Configure feature.scalar
run: git config --global feature.scalar ${{ matrix.features }}

- id: functional_test
name: Functional test
shell: bash
run: |
export GIT_TRACE2_EVENT="$PWD/$TRACE2_BASENAME/Event"
export GIT_TRACE2_PERF="$PWD/$TRACE2_BASENAME/Perf"
export GIT_TRACE2_EVENT_BRIEF=true
export GIT_TRACE2_PERF_BRIEF=true
mkdir -p "$TRACE2_BASENAME"
mkdir -p "$TRACE2_BASENAME/Event"
mkdir -p "$TRACE2_BASENAME/Perf"
git version --build-options
cd ../out
Scalar.FunctionalTests/$BUILD_FRAGMENT/Scalar.FunctionalTests$BUILD_FILE_EXT --full-suite
- id: trace2_zip_unix
if: runner.os != 'Windows' && ( success() || failure() ) && ( steps.functional_test.conclusion == 'success' || steps.functional_test.conclusion == 'failure' )
name: Zip Trace2 Logs (Unix)
shell: bash
run: zip -q -r $TRACE2_BASENAME.zip $TRACE2_BASENAME/

- id: trace2_zip_windows
if: runner.os == 'Windows' && ( success() || failure() ) && ( steps.functional_test.conclusion == 'success' || steps.functional_test.conclusion == 'failure' )
name: Zip Trace2 Logs (Windows)
run: Compress-Archive -DestinationPath ${{ env.TRACE2_BASENAME }}.zip -Path ${{ env.TRACE2_BASENAME }}

- name: Archive Trace2 Logs
if: ( success() || failure() ) && ( steps.trace2_zip_unix.conclusion == 'success' || steps.trace2_zip_windows.conclusion == 'success' )
uses: actions/upload-artifact@v2
with:
name: ${{ env.TRACE2_BASENAME }}.zip
path: ${{ env.TRACE2_BASENAME }}.zip
retention-days: 3
43 changes: 43 additions & 0 deletions Scalar.FunctionalTests/Tests/GitCommands/AddStageTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using NUnit.Framework;
using Scalar.FunctionalTests.Properties;

namespace Scalar.FunctionalTests.Tests.GitCommands
{
[TestFixtureSource(typeof(GitRepoTests), nameof(GitRepoTests.ValidateWorkingTree))]
[Category(Categories.GitCommands)]
public class AddStageTests : GitRepoTests
{
public AddStageTests(Settings.ValidateWorkingTreeMode validateWorkingTree)
: base(enlistmentPerTest: false, validateWorkingTree: validateWorkingTree)
{
}

[TestCase, Order(1)]
public void AddBasicTest()
{
this.EditFile("Some new content.", "Readme.md");
this.ValidateGitCommand("add Readme.md");
this.RunGitCommand("commit -m \"Changing the Readme.md\"");
}

[TestCase, Order(2)]
public void StageBasicTest()
{
this.EditFile("Some new content.", "AuthoringTests.md");
this.ValidateGitCommand("stage AuthoringTests.md");
this.RunGitCommand("commit -m \"Changing the AuthoringTests.md\"");
}

[TestCase, Order(3)]
public void AddAndStageHardLinksTest()
{
this.CreateHardLink("ReadmeLink.md", "Readme.md");
this.ValidateGitCommand("add ReadmeLink.md");
this.RunGitCommand("commit -m \"Created ReadmeLink.md\"");

this.CreateHardLink("AuthoringTestsLink.md", "AuthoringTests.md");
this.ValidateGitCommand("stage AuthoringTestsLink.md");
this.RunGitCommand("commit -m \"Created AuthoringTestsLink.md\"");
}
}
}
104 changes: 104 additions & 0 deletions Scalar.FunctionalTests/Tests/GitCommands/CherryPickConflictTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using NUnit.Framework;
using Scalar.FunctionalTests.Properties;

namespace Scalar.FunctionalTests.Tests.GitCommands
{
[TestFixtureSource(typeof(GitRepoTests), nameof(GitRepoTests.ValidateWorkingTree))]
[Category(Categories.GitCommands)]
public class CherryPickConflictTests : GitRepoTests
{
public CherryPickConflictTests(Settings.ValidateWorkingTreeMode validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

[TestCase]
public void CherryPickConflict()
{
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
this.ValidateGitCommand("cherry-pick " + GitRepoTests.ConflictSourceBranch);
this.FilesShouldMatchAfterConflict();
}

[TestCase]
public void CherryPickConflictWithFileReads()
{
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
this.ReadConflictTargetFiles();
this.ValidateGitCommand("status");
this.ValidateGitCommand("cherry-pick " + GitRepoTests.ConflictSourceBranch);
this.FilesShouldMatchAfterConflict();
}

[TestCase]
public void CherryPickConflictWithFileReads2()
{
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
this.ReadConflictTargetFiles();
this.ValidateGitCommand("status");
this.ValidateGitCommand("cherry-pick " + GitRepoTests.ConflictSourceBranch);
this.FilesShouldMatchAfterConflict();
this.ValidateGitCommand("cherry-pick --abort");
this.FilesShouldMatchCheckoutOfTargetBranch();
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictSourceBranch);
}

[TestCase]
public void CherryPickConflict_ThenAbort()
{
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
this.ValidateGitCommand("cherry-pick " + GitRepoTests.ConflictSourceBranch);
this.ValidateGitCommand("cherry-pick --abort");
this.FilesShouldMatchCheckoutOfTargetBranch();
}

[TestCase]
public void CherryPickConflict_ThenSkip()
{
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
this.ValidateGitCommand("cherry-pick " + GitRepoTests.ConflictSourceBranch);
this.ValidateGitCommand("cherry-pick --skip");
this.FilesShouldMatchAfterConflict();
}

[TestCase]
public void CherryPickConflict_UsingOurs()
{
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
this.ValidateGitCommand("cherry-pick -Xours " + GitRepoTests.ConflictSourceBranch);
this.FilesShouldMatchAfterConflict();
}

[TestCase]
public void CherryPickConflict_UsingTheirs()
{
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
this.ValidateGitCommand("cherry-pick -Xtheirs " + GitRepoTests.ConflictSourceBranch);
this.FilesShouldMatchAfterConflict();
}

[TestCase]
public void CherryPickNoCommit()
{
this.ValidateGitCommand("checkout 170b13ce1990c53944403a70e93c257061598ae0");
this.ValidateGitCommand("cherry-pick --no-commit " + GitRepoTests.ConflictTargetBranch);
}

[TestCase]
public void CherryPickNoCommitReset()
{
this.ValidateGitCommand("checkout 170b13ce1990c53944403a70e93c257061598ae0");
this.ValidateGitCommand("cherry-pick --no-commit " + GitRepoTests.ConflictTargetBranch);
this.ValidateGitCommand("reset");
}

protected override void CreateEnlistment()
{
base.CreateEnlistment();
this.ControlGitRepo.Fetch(GitRepoTests.ConflictSourceBranch);
this.ControlGitRepo.Fetch(GitRepoTests.ConflictTargetBranch);
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictSourceBranch);
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
}
}
}
45 changes: 45 additions & 0 deletions Scalar.FunctionalTests/Tests/GitCommands/DeleteEmptyFolderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using NUnit.Framework;
using Scalar.FunctionalTests.Properties;
using Scalar.FunctionalTests.Should;

namespace Scalar.FunctionalTests.Tests.GitCommands
{
[TestFixtureSource(typeof(GitRepoTests), nameof(GitRepoTests.ValidateWorkingTree))]
[Category(Categories.GitCommands)]
public class DeleteEmptyFolderTests : GitRepoTests
{
public DeleteEmptyFolderTests(Settings.ValidateWorkingTreeMode validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

[TestCase]
public void VerifyResetHardDeletesEmptyFolders()
{
this.SetupFolderDeleteTest();

this.RunGitCommand("reset --hard HEAD");
this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
.WithDeepStructure(this.FileSystem, this.ControlGitRepo.RootPath, withinPrefixes: this.pathPrefixes);
}

[TestCase]
public void VerifyCleanDeletesEmptyFolders()
{
this.SetupFolderDeleteTest();

this.RunGitCommand("clean -fd");
this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
.WithDeepStructure(this.FileSystem, this.ControlGitRepo.RootPath, withinPrefixes: this.pathPrefixes);
}

private void SetupFolderDeleteTest()
{
this.ControlGitRepo.Fetch("FunctionalTests/20170202_RenameTestMergeTarget");
this.ValidateGitCommand("checkout FunctionalTests/20170202_RenameTestMergeTarget");
this.DeleteFile("Test_EPF_GitCommandsTestOnlyFileFolder", "file.txt");
this.ValidateGitCommand("add .");
this.RunGitCommand("commit -m\"Delete only file.\"");
}
}
}
31 changes: 31 additions & 0 deletions Scalar.FunctionalTests/Tests/GitCommands/EnumerationMergeTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using NUnit.Framework;
using Scalar.FunctionalTests.Properties;

namespace Scalar.FunctionalTests.Tests.GitCommands
{
[TestFixtureSource(typeof(GitRepoTests), nameof(GitRepoTests.ValidateWorkingTree))]
[Category(Categories.GitCommands)]
public class EnumerationMergeTest : GitRepoTests
{
// Commit that found GvFlt Bug 12258777: Entries are sometimes skipped during
// enumeration when they don't fit in a user's buffer
private const string EnumerationReproCommitish = "FunctionalTests/20170602";

public EnumerationMergeTest(Settings.ValidateWorkingTreeMode validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

[TestCase]
public void ConfirmEnumerationMatches()
{
this.ControlGitRepo.Fetch(GitRepoTests.ConflictSourceBranch);
this.ValidateGitCommand("checkout " + GitRepoTests.ConflictSourceBranch);
}

protected override void CreateEnlistment()
{
this.CreateEnlistment(EnumerationReproCommitish);
}
}
}
Loading

0 comments on commit 4cdf253

Please sign in to comment.