diff --git a/src/harness/unittests/tsbuild.ts b/src/harness/unittests/tsbuild.ts index 48f568a65ac..22f68fba866 100644 --- a/src/harness/unittests/tsbuild.ts +++ b/src/harness/unittests/tsbuild.ts @@ -239,13 +239,23 @@ namespace ts { builder.buildAllProjects(); assertDiagnosticMessages(/*none*/); - it("Generates files matching the baseline", () => { - Harness.Baseline.runBaseline("outfile-concat.js", () => { - return fs.readFileSync("/src/third/third-output.js", 'utf-8'); + const files = [ + "/src/third/thirdjs/output/third-output.js", + "/src/third/thirdjs/output/third-output.js.map" + ]; + + + for (const file of files) { + it(`Generates files matching the baseline - ${file}`, () => { + Harness.Baseline.runBaseline(getBaseFileName(file), () => { + return fs.readFileSync(file, 'utf-8'); + }); }); - - Harness.Baseline.runBaseline("outfile-concat.js.map", () => { - return fs.readFileSync("/src/third/third-output.js.map", 'utf-8'); + } + + it(`Generates files matching the baseline - file listing for outFile-concat`, () => { + Harness.Baseline.runBaseline("outfile-concat-fileListing.txt", () => { + return fs.getFileListing(); }); }); }); diff --git a/src/harness/vfs.ts b/src/harness/vfs.ts index ba5905b8ea6..186f3610dcd 100644 --- a/src/harness/vfs.ts +++ b/src/harness/vfs.ts @@ -353,10 +353,7 @@ namespace vfs { if (!result.node) this._mkdir(result); } - /** - * Print diagnostic information about the structure of the file system to the console. - */ - public debugPrint(): void { + public getFileListing(): string { let result = ""; const printLinks = (dirname: string | undefined, links: collections.SortedMap) => { const iterator = collections.getIterator(links); @@ -384,7 +381,14 @@ namespace vfs { } }; printLinks(/*dirname*/ undefined, this._getRootLinks()); - console.log(result); + return result; + } + + /** + * Print diagnostic information about the structure of the file system to the console. + */ + public debugPrint(): void { + console.log(this.getFileListing()); } // POSIX API (aligns with NodeJS "fs" module API) diff --git a/tests/baselines/reference/outfile-concat-fileListing.txt b/tests/baselines/reference/outfile-concat-fileListing.txt new file mode 100644 index 00000000000..3fca9338912 --- /dev/null +++ b/tests/baselines/reference/outfile-concat-fileListing.txt @@ -0,0 +1,39 @@ +*/ + /lib/ + /lib/lib.d.ts + /src/ + /src/2/ + /src/2/second-output.d.ts + /src/2/second-output.d.ts.map + /src/2/second-output.js + /src/2/second-output.js.map + /src/first/ + /src/first/bin/ + /src/first/bin/first-output.d.ts + /src/first/bin/first-output.d.ts.map + /src/first/bin/first-output.js + /src/first/bin/first-output.js.map + /src/first/first_part1.ts + /src/first/first_part2.ts + /src/first/first_part3.ts + /src/first/tsconfig.json + /src/first_part1.ts + /src/first_part2.ts + /src/first_part3.ts + /src/second/ + /src/second/second_part1.ts + /src/second/second_part2.ts + /src/second/tsconfig.json + /src/second_part1.ts + /src/second_part2.ts + /src/third/ + /src/third/third_part1.ts + /src/third/thirdjs/ + /src/third/thirdjs/output/ + /src/third/thirdjs/output/third-output.d.ts + /src/third/thirdjs/output/third-output.d.ts.map + /src/third/thirdjs/output/third-output.js + /src/third/thirdjs/output/third-output.js.map + /src/third/tsconfig.json + /src/third_part1.ts + /src/tsconfig.json \ No newline at end of file diff --git a/tests/baselines/reference/third-output.js b/tests/baselines/reference/third-output.js new file mode 100644 index 00000000000..e3e5aa3d5f0 --- /dev/null +++ b/tests/baselines/reference/third-output.js @@ -0,0 +1,26 @@ +var s = "Hello, world"; +console.log(s); +console.log(f()); +function f() { + return "JS does hoists"; +} +//# sourceMappingURL=first-output.js.map +var N; +(function (N) { + function f() { + console.log('testing'); + } + f(); +})(N || (N = {})); +var C = (function () { + function C() { + } + C.prototype.doSomething = function () { + console.log("something got done"); + }; + return C; +}()); +//# sourceMappingURL=second-output.js.map +var c = new C(); +c.doSomething(); +//# sourceMappingURL=third-output.js.map \ No newline at end of file diff --git a/tests/baselines/reference/third-output.js.map b/tests/baselines/reference/third-output.js.map new file mode 100644 index 00000000000..70b9ad69d53 --- /dev/null +++ b/tests/baselines/reference/third-output.js.map @@ -0,0 +1 @@ +{"version":3,"file":"third-output.js","sections":[{"offset":{"line":0,"column":0},"map":{"version":3,"file":"first-output.js","sourceRoot":"","sources":["../first_part1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAIA,IAAM,CAAC,GAAG,cAAc,CAAC;AAMzB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;ACVf,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;ACAjB;IACI,OAAO,gBAAgB,CAAC;AAC5B,CAAC"}},{"offset":{"line":7,"column":0},"map":{"version":3,"file":"second-output.js","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAIA,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;IACP;QACI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,CAAC,EAAE,CAAC;AACR,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;ACVD;IAAA;IAIA,CAAC;IAHG,uBAAW,GAAX;QACI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACtC,CAAC;IACL,QAAC;AAAD,CAAC,AAJD,IAIC"}},{"offset":{"line":22,"column":41},"map":{"version":3,"file":"third-output.js","sourceRoot":"","sources":["../../third_part1.ts"],"names":[],"mappings":";AAAA,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAChB,CAAC,CAAC,WAAW,EAAE,CAAC"}}]} \ No newline at end of file diff --git a/tests/projects/outfile-concat/first/tsconfig.json b/tests/projects/outfile-concat/first/tsconfig.json index 75562e332f2..8370f6512b8 100644 --- a/tests/projects/outfile-concat/first/tsconfig.json +++ b/tests/projects/outfile-concat/first/tsconfig.json @@ -7,7 +7,7 @@ "sourceMap": true, "declarationMap": true, "declaration": true, - "outFile": "./first-output.js" + "outFile": "./bin/first-output.js" }, "references": [ ] diff --git a/tests/projects/outfile-concat/second/tsconfig.json b/tests/projects/outfile-concat/second/tsconfig.json index 42d93ee56fb..d835cff6d66 100644 --- a/tests/projects/outfile-concat/second/tsconfig.json +++ b/tests/projects/outfile-concat/second/tsconfig.json @@ -7,7 +7,7 @@ "sourceMap": true, "declarationMap": true, "declaration": true, - "outFile": "./second-output.js" + "outFile": "../2/second-output.js" }, "references": [ ] diff --git a/tests/projects/outfile-concat/third/tsconfig.json b/tests/projects/outfile-concat/third/tsconfig.json index 195272b2d94..18c98608db1 100644 --- a/tests/projects/outfile-concat/third/tsconfig.json +++ b/tests/projects/outfile-concat/third/tsconfig.json @@ -7,7 +7,7 @@ "sourceMap": true, "declarationMap": true, "declaration": true, - "outFile": "./third-output.js" + "outFile": "./thirdjs/output/third-output.js" }, "references": [ { "path": "../first", "prepend": true },