Skip to content

Commit

Permalink
Ensure translation test output committing is prevented on main branch (
Browse files Browse the repository at this point in the history
  • Loading branch information
mknejp authored Jan 11, 2022
1 parent 2b8056d commit 243b24a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
18 changes: 12 additions & 6 deletions src/dotVariant.Generator.Test/SourceGenerator.Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,27 @@ public static void Translation(string typeName, string fileName, string input, s
$"{typeName}.cs");
var output = outputs[file];
output = _copyrightHeader + output;

if (output != expected)
{
var commit = true;
//var commit = false;
#if CI
Assert.That(commit, Is.False);
#endif
if (commit)
if (_commitTranslations)
{
WriteSample(fileName, output);
}
Assert.That(output, Is.EqualTo(expected));
}
}

private static readonly bool _commitTranslations = false;

[Test]
public static void PreventCommitInMain()
{
#if CI
Assert.That(_commitTranslations, Is.False);
#endif
}

private static readonly string _samplesDir
= Assembly
.GetExecutingAssembly()
Expand Down
12 changes: 9 additions & 3 deletions src/dotVariant.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31025.218
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotVariant", "dotVariant\dotVariant.csproj", "{B14D1B4F-EA99-4937-90C6-235AD8FB7251}"
EndProject
Expand All @@ -22,6 +21,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotVariant.Test-net45", "do
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "dotVariant.Test", "dotVariant.Test\dotVariant.Test.shproj", "{193D7A79-92BF-46BE-BB02-60360DA0883D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{A5DAA24D-3270-4696-9620-104C5987E146}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\publish.yaml = ..\.github\workflows\publish.yaml
..\.github\workflows\test-package.yaml = ..\.github\workflows\test-package.yaml
..\.github\workflows\test.yaml = ..\.github\workflows\test.yaml
EndProjectSection
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
dotVariant.Test\dotVariant.Test.projitems*{1305501c-65ab-4338-848f-3d2b919b7255}*SharedItemsImports = 5
Expand Down

0 comments on commit 243b24a

Please sign in to comment.