Sanitize version string for syntactically invalid buildinfo baselines (#59932)

This commit is contained in:
Wesley Wigham
2024-09-10 13:58:33 -07:00
committed by GitHub
parent 48f0b3cc38
commit 0d7763e4c8
4 changed files with 15 additions and 5 deletions

View File

@@ -1,7 +1,10 @@
import { Baseline } from "../../_namespaces/Harness.js";
import * as ts from "../../_namespaces/ts.js";
import { jsonToReadableText } from "../helpers.js";
import { patchHostForBuildInfoReadWrite } from "../helpers/baseline.js";
import {
fakeTsVersion,
patchHostForBuildInfoReadWrite,
} from "../helpers/baseline.js";
import { getTypeScriptLibTestLocation } from "../helpers/contents.js";
import {
getSysForSampleProjectReferences,
@@ -198,7 +201,10 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
commandLineArgs: ["--b", "-i", "-v"],
edits: [{
caption: "tsbuildinfo written has error",
edit: sys => sys.prependFile("/home/src/workspaces/project/tsconfig.tsbuildinfo", "Some random string"),
edit: sys => {
sys.prependFile("/home/src/workspaces/project/tsconfig.tsbuildinfo", "Some random string");
sys.replaceFileText("/home/src/workspaces/project/tsconfig.tsbuildinfo", `"version":"${ts.version}"`, `"version":"${fakeTsVersion}"`); // build info won't parse, need to manually sterilize for baseline
},
}],
});

View File

@@ -1,6 +1,7 @@
import * as ts from "../../_namespaces/ts.js";
import { dedent } from "../../_namespaces/Utils.js";
import { jsonToReadableText } from "../helpers.js";
import { fakeTsVersion } from "../helpers/baseline.js";
import { compilerOptionsToConfigJson } from "../helpers/contents.js";
import {
noChangeOnlyRuns,
@@ -100,7 +101,10 @@ describe("unittests:: tsc:: incremental::", () => {
commandLineArgs: ["-i"],
edits: [{
caption: "tsbuildinfo written has error",
edit: sys => sys.prependFile("/home/src/workspaces/project/tsconfig.tsbuildinfo", "Some random string"),
edit: sys => {
sys.prependFile("/home/src/workspaces/project/tsconfig.tsbuildinfo", "Some random string");
sys.replaceFileText("/home/src/workspaces/project/tsconfig.tsbuildinfo", `"version":"${ts.version}"`, `"version":"${fakeTsVersion}"`); // build info won't parse, need to manually sterilize for baseline
},
}],
});

View File

@@ -84,7 +84,7 @@ Change:: tsbuildinfo written has error
Input::
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo]
Some random string{"fileNames":["../../tslibs/ts/lib/lib.d.ts","./main.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-10726455937-export const x = 10;"],"root":[2],"version":"5.7.0-dev"}
Some random string{"fileNames":["../../tslibs/ts/lib/lib.d.ts","./main.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-10726455937-export const x = 10;"],"root":[2],"version":"FakeTSVersion"}
/home/src/tslibs/TS/Lib/tsc.js --b -i -v

View File

@@ -77,7 +77,7 @@ Change:: tsbuildinfo written has error
Input::
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo]
Some random string{"fileNames":["../../tslibs/ts/lib/lib.d.ts","./main.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-10726455937-export const x = 10;"],"root":[2],"version":"5.7.0-dev"}
Some random string{"fileNames":["../../tslibs/ts/lib/lib.d.ts","./main.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-10726455937-export const x = 10;"],"root":[2],"version":"FakeTSVersion"}
/home/src/tslibs/TS/Lib/tsc.js -i