Skip to content

Commit

Permalink
@W-17380965@ Fixing broken Windows test
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeingold35 committed Dec 10, 2024
1 parent 9f162ba commit dd60ce7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 35 deletions.
5 changes: 5 additions & 0 deletions packages/code-analyzer-core/test/output-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,20 @@ function getContentsOfExpectedOutputFile(expectedOutputFileName: string, escapeB
const contents: string = fs.readFileSync(path.resolve('test','test-data','expectedOutputFiles',expectedOutputFileName), 'utf-8');
let pathSepVar: string = path.sep;
let runDirVar: string = process.cwd() + path.sep;
const encodedRunDir: string = encodeURI(runDirVar);
const escapedRunDir: string = runDirVar.replaceAll('\\', '\\\\');
if (escapeBackslashesOnPaths) {
pathSepVar = pathSepVar.replaceAll('\\','\\\\');
}
if (escapeBackslashesOnRunDir) {
runDirVar = runDirVar.replaceAll('\\','\\\\');
}
const encodedPathSepVar: string = encodeURI(path.sep);

return contents.replaceAll('{{PATHSEP}}', pathSepVar)
.replaceAll(`{{ENCODEDPATHSEP}}`, encodedPathSepVar)
.replaceAll('{{RUNDIR}}', runDirVar)
.replaceAll('{{ENCODEDRUNDIR}}', encodedRunDir)
.replaceAll('{{ESCAPEDRUNDIR}}', escapedRunDir)
.replaceAll('{{###RUNDIR###}}', runDirVar)
.replaceAll('{{###TIMESTAMP###}}', fixedTime.toLocaleString('en-us', {year: "numeric", month: "short",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}config.test.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}config.test.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 3,
Expand All @@ -73,8 +73,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}config.test.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}config.test.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 3,
Expand All @@ -97,8 +97,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}test-data{{PATHSEP}}sample-input-files{{PATHSEP}}subfolder%20with%20spaces{{PATHSEP}}some-target-file.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}test-data{{ENCODEDPATHSEP}}sample-input-files{{ENCODEDPATHSEP}}subfolder%20with%20spaces{{ENCODEDPATHSEP}}some-target-file.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 10,
Expand All @@ -113,8 +113,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}test-data{{PATHSEP}}sample-input-files{{PATHSEP}}subfolder%20with%20spaces{{PATHSEP}}some-target-file.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}test-data{{ENCODEDPATHSEP}}sample-input-files{{ENCODEDPATHSEP}}subfolder%20with%20spaces{{ENCODEDPATHSEP}}some-target-file.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 10,
Expand All @@ -137,8 +137,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}run.test.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}run.test.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 21,
Expand All @@ -153,8 +153,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}run.test.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}run.test.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 21,
Expand All @@ -177,8 +177,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}run.test.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}run.test.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 56,
Expand All @@ -191,8 +191,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}run.test.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}run.test.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 56,
Expand All @@ -207,7 +207,7 @@
{
"executionSuccessful": true,
"workingDirectory": {
"uri": "{{RUNDIR}}"
"uri": "{{ENCODEDRUNDIR}}"
}
}
]
Expand Down Expand Up @@ -244,8 +244,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}stubs.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}stubs.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 76,
Expand All @@ -258,8 +258,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}stubs.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}stubs.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 4,
Expand All @@ -270,8 +270,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}test-helpers.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}test-helpers.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 9,
Expand All @@ -282,8 +282,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}stubs.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}stubs.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 76,
Expand All @@ -298,7 +298,7 @@
{
"executionSuccessful": true,
"workingDirectory": {
"uri": "{{RUNDIR}}"
"uri": "{{ENCODEDRUNDIR}}"
}
}
]
Expand Down Expand Up @@ -335,8 +335,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}stubs.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}stubs.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 90,
Expand All @@ -351,8 +351,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}stubs.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}stubs.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 20,
Expand All @@ -365,8 +365,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}test-helpers.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}test-helpers.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 5,
Expand All @@ -377,8 +377,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri": "test{{PATHSEP}}stubs.ts",
"uriBaseId": "{{RUNDIR}}"
"uri": "test{{ENCODEDPATHSEP}}stubs.ts",
"uriBaseId": "{{ENCODEDRUNDIR}}"
},
"region": {
"startLine": 90,
Expand All @@ -395,7 +395,7 @@
{
"executionSuccessful": true,
"workingDirectory": {
"uri": "{{RUNDIR}}"
"uri": "{{ENCODEDRUNDIR}}"
}
}
]
Expand Down

0 comments on commit dd60ce7

Please sign in to comment.