Skip to content

Commit 07964f8

Browse files
authored
Merge pull request #614 from dotnet/fix125
Switch tests from 7z to zip and enable test
2 parents b7707b3 + daa0303 commit 07964f8

File tree

5 files changed

+9
-32
lines changed

5 files changed

+9
-32
lines changed

src/NerdBank.GitVersioning.Tests/NerdBank.GitVersioning.Tests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
<EmbeddedResource Include="ManagedGit\tree*" />
2626
<EmbeddedResource Include="test.vcprj" />
2727
<EmbeddedResource Include="test.prj" />
28-
<EmbeddedResource Include="repos\submodules.7z" />
28+
<EmbeddedResource Include="repos\*" />
2929
</ItemGroup>
3030
<ItemGroup>
3131
<ProjectReference Include="..\Nerdbank.GitVersioning.Tasks\Nerdbank.GitVersioning.Tasks.csproj" />
3232
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj" />
3333
</ItemGroup>
3434
<ItemGroup>
35-
<PackageReference Include="7z.NET" Version="1.0.3" />
3635
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.10" />
3736
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
3837
<PackageReference Include="Microsoft.Build" Version="15.1.548" ExcludeAssets="runtime" />

src/NerdBank.GitVersioning.Tests/TestUtilities.cs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#if NET461
2-
using SevenZipNET;
3-
#endif
4-
using Validation;
1+
using Validation;
52

63
using System;
74
using System.Collections.Generic;
@@ -67,36 +64,19 @@ internal static void ExtractEmbeddedResource(string resourcePath, string extract
6764

6865
internal static ExpandedRepo ExtractRepoArchive(string repoArchiveName)
6966
{
70-
#if NET461
7167
string archiveFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
7268
string expandedFolderPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
7369

74-
ExtractEmbeddedResource($"repos.{repoArchiveName}.7z", archiveFilePath);
70+
ExtractEmbeddedResource($"repos.{repoArchiveName}.zip", archiveFilePath);
7571
try
7672
{
77-
for (int retryCount = 0; ; retryCount++)
78-
{
79-
try
80-
{
81-
var extractor = new SevenZipExtractor(archiveFilePath);
82-
extractor.ExtractAll(expandedFolderPath);
83-
return new ExpandedRepo(expandedFolderPath);
84-
}
85-
catch (System.ComponentModel.Win32Exception) when (retryCount < 2)
86-
{
87-
}
88-
}
73+
System.IO.Compression.ZipFile.ExtractToDirectory(archiveFilePath, expandedFolderPath);
74+
return new ExpandedRepo(expandedFolderPath);
8975
}
9076
finally
9177
{
92-
if (File.Exists(archiveFilePath))
93-
{
94-
File.Delete(archiveFilePath);
95-
}
78+
File.Delete(archiveFilePath);
9679
}
97-
#else
98-
throw new PlatformNotSupportedException();
99-
#endif
10080
}
10181

10282
internal class ExpandedRepo : IDisposable

src/NerdBank.GitVersioning.Tests/VersionOracleTests.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,17 @@ public void NotRepo()
4949
Assert.Equal(0, oracle.VersionHeight);
5050
}
5151

52-
[Fact(Skip = "Unstable test. See issue #125")]
52+
[Fact]
5353
public void Submodule_RecognizedWithCorrectVersion()
5454
{
5555
using (var expandedRepo = TestUtilities.ExtractRepoArchive("submodules"))
5656
{
57-
this.Context = this.CreateGitContext(expandedRepo.RepoPath);
58-
59-
this.Context.RepoRelativeProjectDirectory = "a";
57+
this.Context = this.CreateGitContext(Path.Combine(expandedRepo.RepoPath, "a"));
6058
var oracleA = new VersionOracle(this.Context);
6159
Assert.Equal("1.3.1", oracleA.SimpleVersion.ToString());
6260
Assert.Equal("e238b03e75", oracleA.GitCommitIdShort);
6361

64-
this.Context.RepoRelativeProjectDirectory = Path.Combine("b", "projB");
62+
this.Context = this.CreateGitContext(Path.Combine(expandedRepo.RepoPath, "b", "projB"));
6563
var oracleB = new VersionOracle(this.Context);
6664
Assert.Equal("2.5.2", oracleB.SimpleVersion.ToString());
6765
Assert.Equal("3ea7f010c3", oracleB.GitCommitIdShort);
-9.1 KB
Binary file not shown.
35.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)