Skip to content

Commit

Permalink
Start work on v1 <-> v2 transformation (#1208)
Browse files Browse the repository at this point in the history
* Restore TransformCommand and first (unaffected) unit test

* Restore "minimal prerelease v2 to current v2" test.

* estore "minimal v1 to current v2" test.

* Restore remaining TransformCommand unit tests.

* Uncomment v2 => v1 tests to observe failures.

* Uncomment 'transform' command.
  • Loading branch information
Larry Golding authored and michaelcfanning committed Jan 12, 2019
1 parent 169538f commit 28b9522
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 201 deletions.
8 changes: 6 additions & 2 deletions scripts/Run-Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if ($AppVeyor) {

$TestRunnerRootPath = "$NuGetPackageRoot\xunit.runner.console\2.3.1\tools\"

$failedTestProjects = @()
foreach ($project in $Projects.Tests) {
foreach ($framework in $Frameworks.Application) {
Write-Information "Running tests in ${project}: $framework..."
Expand All @@ -52,9 +53,12 @@ foreach ($project in $Projects.Tests) {
& ${TestRunnerRootPath}net452\xunit.console.exe $dll $ReporterOption
}
if ($LASTEXITCODE -ne 0) {
Pop-Location
Exit-WithFailureMessage $ScriptName "${project}: tests failed."
$failedTestProjects += "${project}: $framework"
}
Pop-Location
}
}

if ($failedTestProjects) {
Exit-WithFailureMessage $ScriptName "Tests failed in these projects `n $($failedTestProjects -join "`n ")"
}
16 changes: 11 additions & 5 deletions src/Sarif.Multitool.UnitTests/TransformCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.CodeAnalysis.Sarif;
using Microsoft.CodeAnalysis.Sarif.Multitool;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Microsoft.CodeAnalysis.Sarif.VersionOne;
using FluentAssertions;
using Moq;
using Newtonsoft.Json;
using Xunit;

namespace Sarif.Multitool.UnitTests
{
Expand Down Expand Up @@ -51,7 +58,6 @@ public class TransformCommandTests
]
}";

/*
[Fact]
public void TransformCommand_TransformsMinimalCurrentV2FileToCurrentV2()
{
Expand Down Expand Up @@ -81,7 +87,7 @@ public void TransformCommand_TransformsMinimalV1FileToCurrentV2()
{
RunTransformationToV2Test(MinimalV1);
}

[Fact]
public void TransformCommand_TransformsMinimalCurrentV2FileToV1()
{
Expand Down Expand Up @@ -111,7 +117,7 @@ public void TransformCommand_TransformsMinimalV1FileToV1()
{
RunTransformationToV1Test(MinimalV1);
}

private static void RunTransformationToV2Test(string logFileContents)
{
string transformedContents = RunTransformationCore(logFileContents, SarifVersion.Current);
Expand All @@ -122,7 +128,7 @@ private static void RunTransformationToV2Test(string logFileContents)
sarifLog.Version.Should().Be(SarifVersion.Current);
}


private void RunTransformationToV1Test(string logFileContents)
{
string transformedContents = RunTransformationCore(logFileContents, SarifVersion.OneZeroZero);
Expand Down Expand Up @@ -156,6 +162,6 @@ private static string RunTransformationCore(string logFileContents, SarifVersion
returnCode.Should().Be(0);

return transformedContents;
}*/
}
}
}
2 changes: 1 addition & 1 deletion src/Sarif.Multitool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static int Main(string[] args)
(ValidateOptions validateOptions) => new ValidateCommand().Run(validateOptions),
(ConvertOptions convertOptions) => ConvertCommand.Run(convertOptions),
(RewriteOptions rewriteOptions) => new RewriteCommand().Run(rewriteOptions),
//(TransformOptions transformOptions) => new TransformCommand().Run(transformOptions),
(TransformOptions transformOptions) => new TransformCommand().Run(transformOptions),
(MergeOptions mergeOptions) => new MergeCommand().Run(mergeOptions),
(RebaseUriOptions rebaseOptions) => new RebaseUriCommand().Run(rebaseOptions),
(AbsoluteUriOptions absoluteUriOptions) => new AbsoluteUriCommand().Run(absoluteUriOptions),
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Multitool/Sarif.Multitool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

<ItemGroup>
<Compile Remove="ResultMatchingCommand.cs" />
<Compile Remove="TransformCommand.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions src/Sarif.UnitTests/Sarif.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@

<ItemGroup>
<Compile Remove="Baseline\**" />
<Compile Remove="TestData\Transformers\**" />
<EmbeddedResource Remove="Baseline\**" />
<EmbeddedResource Remove="TestData\Transformers\**" />
<None Remove="Baseline\**" />
<None Remove="TestData\Transformers\**" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 28b9522

Please sign in to comment.