Skip to content

Commit

Permalink
Normalize paths
Browse files Browse the repository at this point in the history
  • Loading branch information
vnaskos-sonar committed Jan 10, 2025
1 parent f66a108 commit fcabc72
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/SLCore.IntegrationTests/SimpleAnalysisTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ private static Dictionary<string, string> GenerateTestCompilationDatabase()
The compilation database file must contain the absolute path to the source code file the compilation database json file and the compiler path.
For the compiler we use the MSVC which is set as an environment variable. Make sure the environment variable is set to point to the compiler path
(the absolute path to cl.exe). */
var compilerPath = Environment.GetEnvironmentVariable("MSVC")?.Replace(@"\", @"\\");
var cFamilyIssuesFileAbsolutePath = FileAnalysisTestsRunner.CFamilyIssues.GetFullPath().Replace(@"\", @"\\");
var analysisDirectory = cFamilyIssuesFileAbsolutePath.Substring(0, cFamilyIssuesFileAbsolutePath.LastIndexOf('\\') + 1);
var compilerPath = NormalizePath(Environment.GetEnvironmentVariable("MSVC"));
var cFamilyIssuesFileAbsolutePath = NormalizePath(FileAnalysisTestsRunner.CFamilyIssues.GetFullPath());
var analysisDirectory = NormalizePath(Path.GetDirectoryName(cFamilyIssuesFileAbsolutePath));
var jsonContent = $$"""
[
{
Expand All @@ -127,4 +127,11 @@ For the compiler we use the MSVC which is set as an environment variable. Make s
};
return compilationDatabase;
}

private static string NormalizePath(string path)
{
var singleDirectorySeparator = Path.DirectorySeparatorChar.ToString();
var doubleDirectorySeparator = singleDirectorySeparator + singleDirectorySeparator;
return path?.Replace(singleDirectorySeparator, doubleDirectorySeparator);
}
}

0 comments on commit fcabc72

Please sign in to comment.