Skip to content

Commit

Permalink
Revert multiple compilation stats per patch, has incorrect baseline t…
Browse files Browse the repository at this point in the history
…hat doesnt match actual behavior

This reverts commit 9d62b44.
  • Loading branch information
sheetalkamat committed Apr 13, 2020
1 parent 399b60a commit 7b0ec7d
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 312 deletions.
Expand Up @@ -5,18 +5,6 @@ Entrypoint main = bundle.js
[./src/error2.js] 278 bytes {main} [built] [1 error]
[./src/index.js] 207 bytes {main} [built]

ERROR in src\error2.js
./src/error2.js
[tsl] ERROR in src\error2.js(4,10)
 TS2339: Property 'bar' does not exist on type 'Class2'.

Asset Size Chunks Chunk Names
bundle.js 5.15 KiB main main
Entrypoint main = bundle.js
[./src/error1.js] 265 bytes {main}
[./src/error2.js] 278 bytes {main} [1 error]
[./src/index.js] 207 bytes {main} [built]

ERROR in src\error2.js
./src/error2.js
[tsl] ERROR in src\error2.js(4,10)
Expand Down
59 changes: 17 additions & 42 deletions test/comparison-tests/create-and-execute-test.js
Expand Up @@ -169,38 +169,21 @@ function createWebpackConfig(paths, optionsOriginal, useWatchApi) {
}

function createWebpackWatchHandler(done, paths, testState, options, test) {
let timoutId;
let statsString;
let errString;
return function (err, stats) {
if (timoutId) {
clearTimeout(timoutId);
timoutId = undefined;
}
const patch = setPathsAndGetPatch(paths, testState, options);
const currentErrString = errToString(err, paths);
if (currentErrString) {
errString = errString ? errString + "\n\n" + currentErrString : currentErrString;
}
const currentStatsString = statsToString(stats, testState, paths);
if (currentStatsString) {
statsString = statsString ? statsString + "\n\n" + currentStatsString : currentStatsString;
}
timoutId = setTimeout(function () {
cleanHashFromOutput(stats, paths.webpackOutput);

copySync(paths.webpackOutput, paths.actualOutput);
rimraf.sync(paths.webpackOutput);
cleanHashFromOutput(stats, paths.webpackOutput);

copySync(paths.webpackOutput, paths.actualOutput);
rimraf.sync(paths.webpackOutput);

handleErrors(err, paths);

handleErrors(errString, paths);
errString = undefined;
storeStats(stats, testState, paths);

storeStats(statsString, paths);
statsString = undefined;
compareFiles(paths, test, patch);

compareFiles(paths, test, patch);
copyPatchOrEndTest(paths.testStagingPath, testState.watcher, testState, done);
}, 2000);
copyPatchOrEndTest(paths.testStagingPath, testState.watcher, testState, done);
}
}

Expand All @@ -219,35 +202,26 @@ function setPathsAndGetPatch(paths, testState, options) {
return patch;
}

function handleErrors(errString, paths) {
if (errString) {
function handleErrors(err, paths) {
if (err) {
const errFileName = 'err.txt';
fs.writeFileSync(path.join(paths.actualOutput, errFileName), errString);
}
}

function errToString(err, paths) {
if (err) {
const errString = err.toString()
.replace(new RegExp(regexEscape(paths.testStagingPath + path.sep), 'g'), '')
.replace(new RegExp(regexEscape(rootPath + path.sep), 'g'), '')
.replace(new RegExp(regexEscape(rootPath), 'g'), '')
.replace(/\.transpile/g, '');
return errString;
}
}

function storeStats(statsString, paths) {
if (statsString) {
const statsFileName = 'output.txt';
fs.writeFileSync(path.join(paths.actualOutput, statsFileName), statsString);
fs.writeFileSync(path.join(paths.actualOutput, errFileName), errString);
}
}

function statsToString(stats, testState, paths) {
function storeStats(stats, testState, paths) {
if (stats && stats.hash !== testState.lastHash) {
testState.lastHash = stats.hash;

const statsFileName = 'output.txt';

// do a little magic to normalize `\` to `/` for asset output
const newAssets = {};
Object.keys(stats.compilation.assets).forEach(function (asset) {
Expand All @@ -262,7 +236,8 @@ function statsToString(stats, testState, paths) {
.replace(new RegExp(regexEscape(rootPath), 'g'), '')
.replace(new RegExp(regexEscape(rootPathWithIncorrectWindowsSeparator), 'g'), '')
.replace(/\.transpile/g, '');
return statsString;

fs.writeFileSync(path.join(paths.actualOutput, statsFileName), statsString);
}
}

Expand Down
Expand Up @@ -106,7 +106,7 @@ eval("\nexports.__esModule = true;\nvar lib_1 = __webpack_require__(/*! ./lib */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
eval("\nexports.__esModule = true;\nexports.lib = {\n one: 1,\n two: 2,\n three: 3,\n four: 4 // Add new number\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack:///./lib/out/index.js?");
eval("\nexports.__esModule = true;\nexports.lib = {\n one: 1,\n two: 2,\n three: 3\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack:///./lib/out/index.js?");

/***/ })

Expand Down
Expand Up @@ -6,10 +6,4 @@
../lib/out/tsconfig.tsbuildinfo 70 KiB [emitted]
Entrypoint main = bundle.js
[./app.ts] 131 bytes {main} [built]
[./lib/out/index.js] 130 bytes {main}

Asset Size Chunks Chunk Names
bundle.js 4.37 KiB main [emitted] main
Entrypoint main = bundle.js
[./app.ts] 131 bytes {main}
[./lib/out/index.js] 161 bytes {main} [built]
[./lib/out/index.js] 130 bytes {main}
Expand Up @@ -2,4 +2,4 @@
bundle.js 4.4 KiB main [emitted] main
Entrypoint main = bundle.js
[./app.ts] 169 bytes {main} [built]
[./lib/out/index.js] 161 bytes {main}
[./lib/out/index.js] 161 bytes {main} [built]
Expand Up @@ -106,7 +106,7 @@ eval("\nexports.__esModule = true;\nvar lib_1 = __webpack_require__(/*! ./lib */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
eval("\nexports.__esModule = true;\nexports.lib = {\n one: 1,\n two: 2,\n three: 3,\n four: 4,\n five: 5\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack:///./lib/out/index.js?");
eval("\nexports.__esModule = true;\nexports.lib = {\n one: 1,\n two: 2,\n three: 3,\n four: 4 // Add new number\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack:///./lib/out/index.js?");

/***/ })

Expand Down
Expand Up @@ -6,10 +6,4 @@
../lib/out/tsconfig.tsbuildinfo 70 KiB [emitted]
Entrypoint main = bundle.js
[./app.ts] 169 bytes {main} [built]
[./lib/out/index.js] 161 bytes {main}

Asset Size Chunks Chunk Names
bundle.js 4.4 KiB main [emitted] main
Entrypoint main = bundle.js
[./app.ts] 169 bytes {main}
[./lib/out/index.js] 156 bytes {main} [built]
[./lib/out/index.js] 161 bytes {main}
Expand Up @@ -2,7 +2,7 @@
bundle.js 4.42 KiB main [emitted] main
Entrypoint main = bundle.js
[./app.ts] 186 bytes {main} [built] [1 error]
[./lib/out/index.js] 156 bytes {main}
[./lib/out/index.js] 156 bytes {main} [built]

ERROR in app.ts
./app.ts
Expand Down

This file was deleted.

This file was deleted.

Expand Up @@ -2,4 +2,4 @@
bundle.js 4.44 KiB main [emitted] main
Entrypoint main = bundle.js
[./app.ts] 205 bytes {main} [built]
[./lib/out/index.js] 161 bytes {main}
[./lib/out/index.js] 161 bytes {main} [built]

0 comments on commit 7b0ec7d

Please sign in to comment.