Skip to content

Commit

Permalink
Add test for cl.exe fallback in ExecutablePath case
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa-mohammed-sonarsource committed Dec 17, 2024
1 parent 4a19e76 commit 377bb2e
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,5 +321,32 @@ public void TryGet_CompilerName_ClangCL()
testLogger.AssertOutputStringExists("Compiler is not supported.");
}

[TestMethod]
public void TryGet_CompilerName_CL_No_ClCompilerPath()
{
// Arrange
var projectItemConfig = new ProjectItemConfig
{
ProjectConfigProperties = new Dictionary<string, string>
{
["ClCompilerPath"] = null,
["IncludePath"] = "C:\\path\\includeDir1;C:\\path\\includeDir2;C:\\path\\includeDir3;",
["ExecutablePath"] = "C:\\path\\no-compiler\\;C:\\path",
["CLToolExe"] = null,
["VC_ExecutablePath_x86"] = "C:\\path\\x86",
["VC_ExecutablePath_x64"] = "C:\\path\\x64",
}
};

var projectItemMock = CreateMockProjectItem("c:\\foo\\xxx.vcxproj", projectItemConfig);

// Act
var request = FileConfig.TryGet(testLogger, projectItemMock.Object, "c:\\dummy\\file.cpp", CreateFileSystemWithClCompiler().Object);

// Assert
request.Should().NotBeNull();
Assert.IsTrue(request.CDCommand.StartsWith("\"C:\\path\\cl.exe\""));
}

}
}

0 comments on commit 377bb2e

Please sign in to comment.