Skip to content

Commit

Permalink
Move test output underneath baselines folder
Browse files Browse the repository at this point in the history
Simplifies everything but the structure; matches the way that TS does
it.
  • Loading branch information
sandersn committed Oct 27, 2020
1 parent 5638512 commit e674582
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules/
test/ts*/
baselines/local/
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export namespace N {
import { C as CD } from "./src/test";
import * as rex_1 from "./src/test";
//another comment
export { rex_1 as rex } from "./src/test";
export { rex_1 as rex };
export interface E {
a: number;
b: number;
Expand All @@ -48,3 +48,5 @@ type J = [
/*bar*/ number,
/*arr*/ ...boolean[]
];
import * as default_1 from "./src/test";
export { default_1 as default };
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export namespace N {
import { C as CD } from "./src/test";
import * as rex_1 from "./src/test";
//another comment
export { rex_1 as rex } from "./src/test";
export { rex_1 as rex };
export interface E {
a: number;
b: number;
Expand All @@ -50,3 +50,5 @@ type J = [
/*bar*/ number,
/*arr*/ ...boolean[]
];
import * as default_1 from "./src/test";
export { default_1 as default };
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export namespace N {
import { C as CD } from "./src/test";
import * as rex_1 from "./src/test";
//another comment
export { rex_1 as rex } from "./src/test";
export { rex_1 as rex };
export interface E {
a: number;
b: number;
Expand All @@ -50,3 +50,5 @@ type J = [
/*bar*/ number,
/*arr*/ ...boolean[]
];
import * as default_1 from "./src/test";
export { default_1 as default };
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ type J = [
/*bar*/ number,
/*arr*/ ...boolean[]
];
export * as default from "./src/test";
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ type J = [
/*bar*/ number,
/*arr*/ ...boolean[]
];
export * as default from "./src/test";
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ type J = [
bar: number,
...arr: boolean[]
];
export * as default from "./src/test";
12 changes: 12 additions & 0 deletions baselines/reference/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"strict": true,
"noEmit": true,
"target": "esnext",
"module": "commonjs",
},
"files": [
"test.d.ts",
"src/test.d.ts"
]
}
20 changes: 8 additions & 12 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,21 @@ const semver = require("semver");
describe("main", () => {
const tsVersions = ["3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0"];

afterEach(() => {
for (const tsVersion of tsVersions) {
if (fs.existsSync(`test/ts${tsVersion}`)) {
sh.rm("-r", `test/ts${tsVersion}`);
}
}
});
if (fs.existsSync(`baselines/local`)) {
sh.rm("-r", `baselines/local`);
}

for (const tsVersion of tsVersions) {
test(
"downlevel TS to " + tsVersion,
() => {
main("test", `test/ts${tsVersion}`, semver.coerce(tsVersion));
main("test", `baselines/local/ts${tsVersion}`, semver.coerce(tsVersion));

expect(fs.readFileSync(`test/ts${tsVersion}/test.d.ts`, "utf8")).toEqual(
fs.readFileSync(`baselines/ts${tsVersion}/test.d.ts`, "utf8")
expect(fs.readFileSync(`baselines/local/ts${tsVersion}/test.d.ts`, "utf8")).toEqual(
fs.readFileSync(`baselines/reference/ts${tsVersion}/test.d.ts`, "utf8")
);
expect(fs.readFileSync(`test/ts${tsVersion}/src/test.d.ts`, "utf8")).toEqual(
fs.readFileSync(`baselines/ts${tsVersion}/src/test.d.ts`, "utf8")
expect(fs.readFileSync(`baselines/local/ts${tsVersion}/src/test.d.ts`, "utf8")).toEqual(
fs.readFileSync(`baselines/reference/ts${tsVersion}/src/test.d.ts`, "utf8")
);
},
10 * 1000
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"bin": "index.js",
"scripts": {
"test": "jest",
"baseline-accept": "cp -r test/ts3.4 baselines"
"baseline-accept": "cp -r baselines/local/ts* baselines/reference"
},
"author": "Nathan Shively-Sanders",
"license": "MIT",
Expand Down

0 comments on commit e674582

Please sign in to comment.