Skip to content

Commit

Permalink
More coverage (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpar authored Nov 29, 2023
1 parent 6fd0357 commit 4129baa
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions src/Basic.CompilerLog.UnitTests/ProgramTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,18 @@ public void CreateNoopBuild()
Assert.Empty(reader.ReadAllCompilerCalls());
}

[Theory]
[InlineData("console.sln")]
[InlineData("console.csproj")]
[InlineData("")]
public void CreateSolution(string target)
[Fact]
public void CreateWithBuild()
{
RunDotNet("new console --name console -o .");
RunDotNet("new sln --name console");
RunDotNet("sln add console.csproj");
Assert.Equal(0, RunCompLog($"create {target} -o msbuild.complog"));
var complogPath = Path.Combine(RootDirectory, "msbuild.complog");
using var reader = CompilerLogReader.Create(complogPath, BasicAnalyzerHostOptions.None);
Assert.Single(reader.ReadAllCompilerCalls());
RunCore(Fixture.SolutionPath);
RunCore(Fixture.ConsoleProjectPath);
void RunCore(string filePath)
{
Assert.Equal(0, RunCompLog($"create {filePath} -o msbuild.complog"));
var complogPath = Path.Combine(RootDirectory, "msbuild.complog");
using var reader = CompilerLogReader.Create(complogPath, BasicAnalyzerHostOptions.None);
Assert.NotEmpty(reader.ReadAllCompilerCalls());
}
}

/// <summary>
Expand Down Expand Up @@ -127,16 +126,26 @@ public void CreateOverRemovedProject()
Assert.Equal(1, RunCompLog($"create {Fixture.RemovedBinaryLogPath}"));
}

/// <summary>
/// Don't search for complogs when an explicit log source isn't provided.
/// </summary>
[Theory]
[InlineData("-h")]
[InlineData("-help")]
public void CreateHelp(string arg)
{
Assert.Equal(1, RunCompLog($"create {arg}"));
}

[Fact]
public void CreateOtherComplogExists()
public void CreateExistingComplog()
{
RunDotNet($"new console --name example --output .");
RunDotNet("build -bl -nr:false");
Root.NewFile("other.complog", "");
Assert.Equal(0, RunCompLog($"create", RootDirectory));
var complogPath = Path.Combine(RootDirectory, "file.complog");
File.WriteAllText(complogPath, "");
Assert.Equal(1, RunCompLog($"create {complogPath}"));
}

[Fact]
public void CreateExtraArguments()
{
Assert.Equal(1, RunCompLog($"create {Fixture.SolutionBinaryLogPath} extra"));
}

[Fact]
Expand Down

0 comments on commit 4129baa

Please sign in to comment.