Skip to content

Commit 2a3d007

Browse files
authored
Merge pull request #4242 from hvitved/csharp/fix-failing-windows-tests
C#: Fix broken auto-builder tests on Windows
2 parents fed973f + fcf39ea commit 2a3d007

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

csharp/autobuilder/Semmle.Autobuild.CSharp.Tests/BuildScripts.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ public void TestWindowsBuildBat()
678678
Actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_TRAP_DIR"] = "";
679679
Actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_SOURCE_ARCHIVE_DIR"] = "";
680680
Actions.RunProcess[@"cmd.exe /C C:\odasa\tools\odasa index --auto C:\Project\build.bat"] = 0;
681-
Actions.RunProcessWorkingDirectory[@"cmd.exe /C C:\odasa\tools\odasa index --auto C:\Project\build.bat"] = "";
681+
Actions.RunProcessWorkingDirectory[@"cmd.exe /C C:\odasa\tools\odasa index --auto C:\Project\build.bat"] = @"C:\Project";
682682
Actions.RunProcess[@"cmd.exe /C C:\codeql\tools\java\bin\java -jar C:\codeql\csharp\tools\extractor-asp.jar ."] = 0;
683683
Actions.RunProcess[@"cmd.exe /C C:\odasa\tools\odasa index --xml --extensions config csproj props xml"] = 0;
684684
Actions.FileExists["csharp.log"] = true;
@@ -695,7 +695,7 @@ public void TestWindowsBuildBatIgnoreErrors()
695695
Actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_TRAP_DIR"] = "";
696696
Actions.GetEnvironmentVariable["CODEQL_EXTRACTOR_CSHARP_SOURCE_ARCHIVE_DIR"] = "";
697697
Actions.RunProcess[@"cmd.exe /C C:\odasa\tools\odasa index --auto C:\Project\build.bat"] = 1;
698-
Actions.RunProcessWorkingDirectory[@"cmd.exe /C C:\odasa\tools\odasa index --auto C:\Project\build.bat"] = "";
698+
Actions.RunProcessWorkingDirectory[@"cmd.exe /C C:\odasa\tools\odasa index --auto C:\Project\build.bat"] = @"C:\Project";
699699
Actions.RunProcess[@"cmd.exe /C C:\codeql\tools\java\bin\java -jar C:\codeql\csharp\tools\extractor-asp.jar ."] = 0;
700700
Actions.RunProcess[@"cmd.exe /C C:\odasa\tools\odasa index --xml --extensions config"] = 0;
701701
Actions.FileExists["csharp.log"] = true;
@@ -1031,7 +1031,7 @@ public void TestDirsProjWindows()
10311031
Actions.RunProcess[@"cmd.exe /C C:\codeql\tools\java\bin\java -jar C:\codeql\csharp\tools\extractor-asp.jar ."] = 0;
10321032
Actions.RunProcess[@"cmd.exe /C C:\odasa\tools\odasa index --xml --extensions config csproj props xml"] = 0;
10331033
Actions.FileExists["csharp.log"] = true;
1034-
Actions.FileExists[@"a\test.csproj"] = true;
1034+
Actions.FileExists[@"C:\Project\a\test.csproj"] = true;
10351035
Actions.FileExists[@"C:\Project\dirs.proj"] = true;
10361036
Actions.FileExists[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"] = false;
10371037
Actions.FileExists[@"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"] = false;
@@ -1053,7 +1053,7 @@ public void TestDirsProjWindows()
10531053
<Compile Include=""test.cs"" />
10541054
</ItemGroup>
10551055
</Project>");
1056-
Actions.LoadXml[@"a\test.csproj"] = csproj;
1056+
Actions.LoadXml[@"C:\Project\a\test.csproj"] = csproj;
10571057

10581058
var dirsproj = new XmlDocument();
10591059
dirsproj.LoadXml(@"<Project DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">

csharp/autobuilder/Semmle.Autobuild.Shared/BuildCommandAutoRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public BuildScript Analyse(Autobuilder builder, bool auto)
4848
chmod.RunCommand("/bin/chmod", $"u+x {scriptPath}");
4949
var chmodScript = builder.Actions.IsWindows() ? BuildScript.Success : BuildScript.Try(chmod.Script);
5050

51-
string? dir = Path.GetDirectoryName(scriptPath);
51+
string? dir = builder.Actions.GetDirectoryName(scriptPath);
5252

5353
// A specific .NET Core version may be required
5454
return chmodScript & withDotNet(builder, environment =>

csharp/autobuilder/Semmle.Autobuild.Shared/ProjectOrSolution.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ public interface IProjectOrSolution
2323

2424
public abstract class ProjectOrSolution : IProjectOrSolution
2525
{
26-
public string FullPath { get; private set; }
26+
public string FullPath { get; }
2727

28-
public string DirectoryName => Path.GetDirectoryName(FullPath) ?? "";
28+
public string DirectoryName { get; }
2929

3030
protected ProjectOrSolution(Autobuilder builder, string path)
3131
{
3232
FullPath = builder.Actions.GetFullPath(path);
33+
DirectoryName = builder.Actions.GetDirectoryName(path) ?? "";
3334
}
3435

3536
public abstract IEnumerable<IProjectOrSolution> IncludedProjects { get; }

0 commit comments

Comments
 (0)