Fix js->ts coverage map transformation in Travis CI where `node` is not on the path.
This commit is contained in:
Piotr Puszkiewicz 2018-03-15 10:03:44 -07:00 коммит произвёл GitHub
Родитель 5850df698b
Коммит 5d1f2026a4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 114 добавлений и 32 удалений

54
package-lock.json сгенерированный
Просмотреть файл

@ -19,6 +19,12 @@
"@types/chai": "4.0.8"
}
},
"@types/events": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz",
"integrity": "sha512-KEIlhXnIutzKwRbQkGWb/I4HFqBuUykAdHgDED6xqwXJfONCjF5VoE0cXEiurh3XauygxzeDzgtXUqvLkxFzzA==",
"dev": true
},
"@types/fs-extra": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-4.0.5.tgz",
@ -28,6 +34,23 @@
"@types/node": "8.0.53"
}
},
"@types/glob": {
"version": "5.0.35",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-5.0.35.tgz",
"integrity": "sha512-wc+VveszMLyMWFvXLkloixT4n0harUIVZjnpzztaZ0nKLuul7Z32iMt2fUFGAaZ4y1XWjFRMtCI5ewvyh4aIeg==",
"dev": true,
"requires": {
"@types/events": "1.2.0",
"@types/minimatch": "3.0.3",
"@types/node": "8.0.53"
}
},
"@types/minimatch": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
"dev": true
},
"@types/mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/@types/mkdirp/-/mkdirp-0.5.1.tgz",
@ -181,6 +204,16 @@
"integrity": "sha1-tVo70HtrizX51EcuH8Mxi2ikk7I=",
"dev": true
},
"@types/shelljs": {
"version": "0.7.8",
"resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.7.8.tgz",
"integrity": "sha512-M2giRw93PxKS7YjU6GZjtdV9HASdB7TWqizBXe4Ju7AqbKlWvTr0gNO92XH56D/gMxqD/jNHLNfC5hA34yGqrQ==",
"dev": true,
"requires": {
"@types/glob": "5.0.35",
"@types/node": "8.0.53"
}
},
"@types/tmp": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.0.33.tgz",
@ -403,6 +436,16 @@
"rimraf": "2.6.2"
}
},
"async-shelljs": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/async-shelljs/-/async-shelljs-0.1.2.tgz",
"integrity": "sha512-dk7WMFhb1dRfexI/2voIUDpmWX3XfPRyTWeafGUtdHqlcQgIZPk0St6+d9Ns3Eantq6MB+Lk4GwMCaSS8MkMRg==",
"dev": true,
"requires": {
"@types/shelljs": "0.7.8",
"shelljs": "0.8.1"
}
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
@ -7045,6 +7088,17 @@
"jsonify": "0.0.0"
}
},
"shelljs": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.1.tgz",
"integrity": "sha512-YA/iYtZpzFe5HyWVGrb02FjPxc4EMCfpoU/Phg9fQoyMC72u9598OUBrsU8IrtwAKG0tO8IYaqbaLIw+k3IRGA==",
"dev": true,
"requires": {
"glob": "7.1.2",
"interpret": "1.1.0",
"rechoir": "0.6.2"
}
},
"sift": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/sift/-/sift-5.0.0.tgz",

Просмотреть файл

@ -40,8 +40,8 @@
"test:runInVsCode": "node ./test/runVsCodeTestsWithAbsolutePaths.js",
"postinstall": "node ./node_modules/vscode/bin/install",
"cov:instrument": "rimraf ./coverage && rimraf ./.nyc_output && rimraf ./out && npm run compile && cd out && nyc instrument --require source-map-support/register --cwd ../ . . && cd ..",
"cov:merge": "cd ./out && istanbul-combine -d ../coverage -r lcovonly ../.nyc_output/*.json && cd ..",
"cov:merge-html": "istanbul-combine -d ./coverage -r html ./.nyc_output/*.json",
"cov:merge": "cd ./out && istanbul-combine -d ../coverage -r lcovonly ../.nyc_output/*.remapped.json && cd ..",
"cov:merge-html": "istanbul-combine -d ./coverage -r html ./.nyc_output/*.remapped.json",
"cov:report": "npm run cov:merge && codecov"
},
"dependencies": {
@ -74,6 +74,7 @@
"@types/tmp": "0.0.33",
"async-child-process": "^1.1.1",
"async-file": "^2.0.2",
"async-shelljs": "^0.1.2",
"chai": "4.1.2",
"chai-arrays": "2.0.0",
"chai-as-promised": "7.1.1",

Просмотреть файл

@ -4,7 +4,9 @@
'use strict';
import {execAsync} from 'async-child-process';
import shelljs = require("async-shelljs");
import path = require('path');
const fs = require('async-file');
import Mocha = require('mocha');
@ -27,17 +29,17 @@ export default class CoverageWritingTestRunner {
public run(testRoot: string, clb: any) {
let promiseResolve: any;
let clbArgsLocal: {error, failures?: number};
let clbArgsLocal: { error, failures?: number };
new Promise<{error, failures?: number}>(function (resolve, reject) {
promiseResolve = (error, failures?: number) => resolve({error, failures});
new Promise<{ error, failures?: number }>(function (resolve, reject) {
promiseResolve = (error, failures?: number) => resolve({ error, failures });
})
.then(clbArgs => {
clbArgsLocal = clbArgs;
return this.writeCoverage();
})
.then(() => clb(clbArgsLocal.error, clbArgsLocal.failures),
() => clb(clbArgsLocal.error, clbArgsLocal.failures));
() => clb(clbArgsLocal.error, clbArgsLocal.failures));
this.baseRunner.run(testRoot, promiseResolve);
}
@ -50,32 +52,58 @@ export default class CoverageWritingTestRunner {
await fs.mkdir(nycFolderPath);
}
let rawCoverageJsonPath = path.join(nycFolderPath, `${process.env.OSVC_SUITE}.json`);
let remappedCoverageJsonPath = path.join(nycFolderPath, `${process.env.OSVC_SUITE}.remapped.json`);
let outFolderPath = path.join(process.env.CODE_EXTENSIONS_PATH, "out");
let remapIstanbulPath = path.join(process.env.CODE_EXTENSIONS_PATH, "node_modules", "remap-istanbul", "bin", "remap-istanbul.js");
let rawCoverageJsonPath: string;
let remappedCoverageJsonPath: string;
let outFolderPath: string;
let remapIstanbulPath: string;
let nodePath: string;
await fs.writeTextFile(rawCoverageJsonPath, JSON.stringify(__coverage__));
let result = await execAsync(`node ${remapIstanbulPath} -i ${rawCoverageJsonPath} -o ${rawCoverageJsonPath}`, {
cwd: outFolderPath
});
let remappedResult = JSON.parse(await fs.readTextFile(rawCoverageJsonPath));
let finalResult = {};
for (let key in remappedResult){
if (remappedResult[key].path) {
let realPath = key.replace("../", "./");
finalResult[realPath] = remappedResult[key];
finalResult[realPath].path = realPath;
try {
rawCoverageJsonPath = path.join(nycFolderPath, `${process.env.OSVC_SUITE}.json`);
remappedCoverageJsonPath = path.join(nycFolderPath, `${process.env.OSVC_SUITE}.remapped.json`);
outFolderPath = path.join(process.env.CODE_EXTENSIONS_PATH, "out");
remapIstanbulPath = path.join(process.env.CODE_EXTENSIONS_PATH, "node_modules", "remap-istanbul", "bin", "remap-istanbul.js");
nodePath = process.env.NVM_BIN;
if (nodePath) {
nodePath = `${nodePath}${path.delimiter}`;
}
else {
finalResult[key] = remappedResult[key];
await fs.writeTextFile(rawCoverageJsonPath, JSON.stringify(__coverage__));
let result = await shelljs.asyncExec(`${nodePath}node ${remapIstanbulPath} -i ${rawCoverageJsonPath} -o ${remappedCoverageJsonPath}`, {
cwd: outFolderPath
});
let remappedResult = JSON.parse(await fs.readTextFile(remappedCoverageJsonPath));
let finalResult = {};
for (let key in remappedResult) {
if (remappedResult[key].path) {
let realPath = key.replace("../", "./");
finalResult[realPath] = remappedResult[key];
finalResult[realPath].path = realPath;
}
else {
finalResult[key] = remappedResult[key];
}
}
await fs.writeTextFile(remappedCoverageJsonPath, JSON.stringify(finalResult));
console.log(`done remapping ${finalResult}`);
}
catch (e) {
console.log(`Coverage remapping failure: ${JSON.stringify(e)}`);
console.log(`* rawCoverageJsonPath: ${rawCoverageJsonPath}`);
console.log(`* remappedCoverageJsonPath: ${remappedCoverageJsonPath}`);
console.log(`* outFolderPath: ${outFolderPath}`);
console.log(`* remapIstanbulPath: ${remapIstanbulPath}`);
console.log(`* nodePath: ${nodePath}`);
}
await fs.writeTextFile(rawCoverageJsonPath, JSON.stringify(finalResult));
}
}
}

Просмотреть файл

@ -6,11 +6,10 @@
"lib": [
"es6"
],
"inlineSourceMap": true,
"rootDir": "."
"inlineSourceMap": true,
"moduleResolution": "node"
},
"exclude": [
"node_modules",
"syntaxes",
".vscode-test"
]