From b33e65fb97dedbe9216cdef33d8df743c170d538 Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Thu, 25 Jun 2020 18:06:40 +0100 Subject: [PATCH] Revert "Allow testing certain code blocks on only specific TypeScript versions" This reverts commit 04c837a6caa3661bc317be33a7ef896ae51d2183. --- integrationTests/ts/.gitignore | 2 - .../ts/{index.ts.template => index.ts} | 7 ++-- integrationTests/ts/package.json | 2 - integrationTests/ts/test.js | 40 ------------------- 4 files changed, 4 insertions(+), 47 deletions(-) delete mode 100644 integrationTests/ts/.gitignore rename integrationTests/ts/{index.ts.template => index.ts} (94%) diff --git a/integrationTests/ts/.gitignore b/integrationTests/ts/.gitignore deleted file mode 100644 index 26694ecad7..0000000000 --- a/integrationTests/ts/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# TypeScript files are generated from templates; see test.js -*.ts diff --git a/integrationTests/ts/index.ts.template b/integrationTests/ts/index.ts similarity index 94% rename from integrationTests/ts/index.ts.template rename to integrationTests/ts/index.ts index 996ab1b7e7..eb989414b3 100644 --- a/integrationTests/ts/index.ts.template +++ b/integrationTests/ts/index.ts @@ -12,8 +12,9 @@ const example: SomeExtension = { string: 'Meaning of life', }; -// The following code block requires a newer version of TypeScript -/*! >=3.2 !*/ +// FIXME: The following code block requires a version of TypeScript >= 3.2 +/* + declare module 'graphql' { interface GraphQLObjectTypeExtensions { someObjectExtension?: SomeExtension; @@ -29,7 +30,7 @@ declare module 'graphql' { someArgumentExtension?: SomeExtension; } } -/*!!*/ +*/ const queryType: GraphQLObjectType = new GraphQLObjectType({ name: 'Query', diff --git a/integrationTests/ts/package.json b/integrationTests/ts/package.json index fffd774bae..a9090df232 100644 --- a/integrationTests/ts/package.json +++ b/integrationTests/ts/package.json @@ -3,9 +3,7 @@ "test": "node test.js" }, "dependencies": { - "glob": "^7.1.6", "graphql": "file:../../npmDist", - "semver": "^7.3.2", "typescript-2.6": "npm:typescript@2.6.x", "typescript-2.7": "npm:typescript@2.7.x", "typescript-2.8": "npm:typescript@2.8.x", diff --git a/integrationTests/ts/test.js b/integrationTests/ts/test.js index e3172925af..a8bd1ef9ca 100644 --- a/integrationTests/ts/test.js +++ b/integrationTests/ts/test.js @@ -4,11 +4,6 @@ const path = require('path'); const childProcess = require('child_process'); -const assert = require('assert'); -const fs = require('fs'); - -const glob = require('glob'); -const semver = require('semver'); const { dependencies } = require('./package.json'); @@ -16,44 +11,9 @@ const tsVersions = Object.keys(dependencies) .filter((pkg) => pkg.startsWith('typescript-')) .sort((a, b) => b.localeCompare(a)); -// To allow omitting certain code from older versions of TypeScript, we have a -// "magic" comment syntax. We precede a block of code with: -// -// /*! SEMVER_RANGE !*/ -// -// replacing SEMVER_RANGE with a semver range spec, such as '>=3.2'; we -// terminate the block of code with: -// -// /*!!*/ -// -// We will only include the code between these comments if the TypeScript -// version being tested satisfies the semver range that was specified. NOTE: We -// currently do not allow nesting of these blocks. -const templates = glob.sync('./*.ts.template').map((filename) => { - const content = fs.readFileSync(filename, 'utf8'); - const targetFilename = filename.replace(/\.template$/, ''); - assert.notEqual(filename, targetFilename); - const writeFileSync = (version) => { - // Captures our magic comment syntax: `/*!(CAPTURE1)!*/(CAPTURE 2)/*!!*/` - const regex = /\/\*!([^!]+)!\*\/([\s\S]*?)\/\*!!\*\//g; - const finalContent = content.replace(regex, (_, versionRange, payload) => { - if (semver.satisfies(version, versionRange)) { - return payload; - } - return ''; - }); - fs.writeFileSync(targetFilename, finalContent); - }; - return { writeFileSync }; -}); - for (const version of tsVersions) { console.log(`Testing on ${version} ...`); - for (const template of templates) { - template.writeFileSync(version); - } - const tscPath = path.join(__dirname, 'node_modules', version, 'bin/tsc'); childProcess.execSync(tscPath, { stdio: 'inherit' }); }