Fix code coverage not mapping correctly (#20026)

This commit is contained in:
Charles Gagnon
2022-07-13 17:05:41 -07:00
committed by GitHub
parent 70f0e7264b
commit 58bf8a100b
2 changed files with 22 additions and 2 deletions

View File

@@ -37,9 +37,19 @@ function createCompile(src, build, emitError) {
const sourcemaps = require('gulp-sourcemaps');
const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json');
const overrideOptions = Object.assign(Object.assign({}, getTypeScriptCompilerOptions(src)), { inlineSources: Boolean(build) });
if (!build) {
// {{SQL CARBON EDIT}} Add override for not inlining the sourcemap during build so we can get code coverage - it
// currently expects a *.map.js file to exist next to the source file for proper source mapping
if (!build && !process.env['SQL_NO_INLINE_SOURCEMAP']) {
overrideOptions.inlineSourceMap = true;
}
else if (!build) {
console.warn('********************************************************************************************');
console.warn('* Inlining of source maps is DISABLED, which will prevent debugging from working properly, *');
console.warn('* but is required to generate code coverage reports. *');
console.warn('* To re-enable inlining of source maps clear the SQL_NO_INLINE_SOURCEMAP environment var *');
console.warn('* and re-run the build/watch task *');
console.warn('********************************************************************************************');
}
const compilation = tsb.create(projectPath, overrideOptions, false, err => reporter(err));
function pipeline(token) {
const bom = require('gulp-bom');

View File

@@ -44,10 +44,20 @@ function createCompile(src: string, build: boolean, emitError?: boolean) {
const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json');
const overrideOptions = { ...getTypeScriptCompilerOptions(src), inlineSources: Boolean(build) };
if (!build) {
// {{SQL CARBON EDIT}} Add override for not inlining the sourcemap during build so we can get code coverage - it
// currently expects a *.map.js file to exist next to the source file for proper source mapping
if (!build && !process.env['SQL_NO_INLINE_SOURCEMAP']) {
overrideOptions.inlineSourceMap = true;
} else if (!build) {
console.warn('********************************************************************************************');
console.warn('* Inlining of source maps is DISABLED, which will prevent debugging from working properly, *');
console.warn('* but is required to generate code coverage reports. *');
console.warn('* To re-enable inlining of source maps clear the SQL_NO_INLINE_SOURCEMAP environment var *');
console.warn('* and re-run the build/watch task *');
console.warn('********************************************************************************************');
}
const compilation = tsb.create(projectPath, overrideOptions, false, err => reporter(err));
function pipeline(token?: util.ICancellationToken) {