From c42b43655b3f2e0776564345bead209502fc249a Mon Sep 17 00:00:00 2001 From: Oscar de Groot Date: Thu, 26 Jun 2014 14:30:04 +0200 Subject: [PATCH 1/6] Prototype: handleWebpackResult can now hide specific webpack warnings. --- src/lib/handleWebpackResult.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/lib/handleWebpackResult.js b/src/lib/handleWebpackResult.js index c0ce2ccf..2c6207aa 100644 --- a/src/lib/handleWebpackResult.js +++ b/src/lib/handleWebpackResult.js @@ -1,5 +1,6 @@ -module.exports = function handleWebpackResult(stats) { +module.exports = function handleWebpackResult(stats, webpackWarningFilters) { if (stats) { + stats.compilation.warnings = filterWebpackWarnings(stats.compilation.warnings, webpackWarningFilters); stats = stats.toJson(); } var nonFatalErrors = (stats && stats.errors) || []; @@ -38,3 +39,26 @@ module.exports = function handleWebpackResult(stats) { } }; + +function filterWebpackWarnings(unfilteredWarnings, webpackWarningFilters) { + // TODO check sanity of config + + var filteredWarnings = unfilteredWarnings.filter(function filterWarnings(warning, index, unfilteredWarnings) { + // TODO use webpackWarningFilters + + if (warning.name === "ModuleNotFoundError" + && warning.origin.rawRequest === "imports?process=>undefined!when" + && warning.dependencies[0].request === "vertx" + ) { + // This warning matches one of the filters. + // Remove it from the list, so that it is NOT shown in Jester's output. + return false; + } else { + // This warning matches none of the filters. + // Leave it in the list, so that it IS shown in Jester's output. + return true; + } + }); + + return filteredWarnings; +} From d796b809e8acce39acdc70d3f9ce5fcf5184c33c Mon Sep 17 00:00:00 2001 From: Oscar de Groot Date: Thu, 26 Jun 2014 14:34:29 +0200 Subject: [PATCH 2/6] Updated hacking.md --- HACKING.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/HACKING.md b/HACKING.md index 13f2f128..5b0c53af 100644 --- a/HACKING.md +++ b/HACKING.md @@ -1,22 +1,25 @@ # How to debug Jester -You attach a graphical debugger ([node-inspector]) to the unittests, or to the compiled jester.js +You attach a graphical debugger ([node-inspector]) to jester. -### Attaching the debugger to the compiled jester.js +- Install [node-inspector] somewhere. Doesn't matter where. -1. Start node-inspector on port 8080: + $ npm install node-inspector - $ cd - $ .\dist\node_modules\.bin\node-inspector --web-port=8080 - info - socket.io started - visit http://0.0.0.0:8080/debug?port=5858 to start debugging +- Start node-inspector. -2. Start jester in debug mode: + $ node_modules/.bin/node-inspector + Node Inspector v0.7.4 + Visit http://127.0.0.1:8080/debug?port=5858 to start debugging. - $ .\dist\node.exe --debug-brk .\dist\jester.js + *node-inspector* now waits for the process-to-debug on port 5858, and for you on port 8080. + +- Start jester in debug mode. + + $ node --debug-brk node_modules/jester-tester/src/bin/jester-watch.js debugger listening on port 5858 -3. Open a browser on http://localhost:8080 -4. place your breakpoints and press the play button to start running jester. +- Browse to http://127.0.0.1:8080/debug?port=5858. +- Place your breakpoints and press the play button to start running jester. [node-inspector]: https://npmjs.org/package/node-inspector From 1634703f1e0bf29555228362d86e2a53c710a2c8 Mon Sep 17 00:00:00 2001 From: Oscar de Groot Date: Thu, 26 Jun 2014 14:47:43 +0200 Subject: [PATCH 3/6] config.webpackWarningFilters is now passed from jester-watch/batch to handleWebpackResult(). --- src/bin/jester-batch.js | 2 +- src/bin/jester-watch.js | 4 ++-- src/lib/createTestFile.js | 4 ++-- src/lib/rebuildProject.js | 4 ++-- src/lib/runAllTests.js | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bin/jester-batch.js b/src/bin/jester-batch.js index 8393bb1e..16e66579 100755 --- a/src/bin/jester-batch.js +++ b/src/bin/jester-batch.js @@ -9,7 +9,7 @@ var loadConfig = require("../lib/loadConfig"), var config = loadConfig("./jester.json"); -rebuildProject(config.fullEntryGlob, config.artifactPath) +rebuildProject(config.fullEntryGlob, config.artifactPath, config.webpackWarningFilters) .then(function() { if(config.srcPath && config.apiDocPath) { return rebuildDocumentation(config.srcPath, config.apiDocPath, config.jsdocConf, config.readme); diff --git a/src/bin/jester-watch.js b/src/bin/jester-watch.js index 1102e4c5..2fa31903 100755 --- a/src/bin/jester-watch.js +++ b/src/bin/jester-watch.js @@ -42,7 +42,7 @@ function runTests(path) { console.log("No tests found for '" + path + "'"); return false; } - return createTestFile(testFile, config.karmaPath).then(function () { + return createTestFile(testFile, config.karmaPath, config.webpackWarningFilters).then(function () { return server.run(); }); }); @@ -74,7 +74,7 @@ function startWatching() { } if (filePath.length > 3 && filePath.substr(-3) === ".js") { - var build = rebuildProject(config.fullEntryGlob, config.artifactPath); + var build = rebuildProject(config.fullEntryGlob, config.artifactPath, config.webpackWarningFilters); if (isReallyFileChangeEvent(changeType, fileCurrentStat, filePreviousStat)) { when.join(build, runTests(filePath)).done(function(){}); } else { diff --git a/src/lib/createTestFile.js b/src/lib/createTestFile.js index 5378a9b4..fcc761ca 100644 --- a/src/lib/createTestFile.js +++ b/src/lib/createTestFile.js @@ -16,7 +16,7 @@ function createEntryModules(filenames) { return entryModules; } -module.exports = function createTestFile(filenames, karmaPath) { +module.exports = function createTestFile(filenames, karmaPath, webpackWarningFilters) { return webpack({ entry: createEntryModules(filenames), output: { @@ -30,6 +30,6 @@ module.exports = function createTestFile(filenames, karmaPath) { }, devtool: "#source-map" }).then(function(stats) { - return handleWebpackResult(stats); + return handleWebpackResult(stats, webpackWarningFilters); }); }; \ No newline at end of file diff --git a/src/lib/rebuildProject.js b/src/lib/rebuildProject.js index a4ad3dc3..b0f213e8 100644 --- a/src/lib/rebuildProject.js +++ b/src/lib/rebuildProject.js @@ -16,7 +16,7 @@ function createEntryModules(featureFiles) { return entryModules; } -module.exports = function rebuildProject(entryGlob, artifactPath) { +module.exports = function rebuildProject(entryGlob, artifactPath, webpackWarningFilters) { return clearDir(artifactPath) .then(function filesCleared() { return glob(entryGlob); @@ -39,6 +39,6 @@ module.exports = function rebuildProject(entryGlob, artifactPath) { }); }) .then(function (stats){ - return handleWebpackResult(stats); + return handleWebpackResult(stats, webpackWarningFilters); }); }; \ No newline at end of file diff --git a/src/lib/runAllTests.js b/src/lib/runAllTests.js index 9b6caf29..be038404 100644 --- a/src/lib/runAllTests.js +++ b/src/lib/runAllTests.js @@ -15,7 +15,7 @@ module.exports = function runAllTests(config) { return glob(config.srcPath + "/**/*.test.js"); }) .then(function (testInputFiles) { - return createTestFile(testInputFiles, config.karmaPath); + return createTestFile(testInputFiles, config.karmaPath, config.webpackWarningFilters); }) .catch(function(err) { console.error("failed creating test files ", err); From 4756fe8d375d226d38d5bddcb15f20a9bb6f942c Mon Sep 17 00:00:00 2001 From: Oscar de Groot Date: Thu, 26 Jun 2014 15:36:24 +0200 Subject: [PATCH 4/6] Gave filterWebpackWarnings() an actual implementation: it now checks the webpackWarningFilters-config and uses it to filter warnings. --- src/lib/handleWebpackResult.js | 67 +++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/src/lib/handleWebpackResult.js b/src/lib/handleWebpackResult.js index 2c6207aa..53bb64d2 100644 --- a/src/lib/handleWebpackResult.js +++ b/src/lib/handleWebpackResult.js @@ -1,6 +1,10 @@ module.exports = function handleWebpackResult(stats, webpackWarningFilters) { if (stats) { - stats.compilation.warnings = filterWebpackWarnings(stats.compilation.warnings, webpackWarningFilters); + try { + stats.compilation.warnings = filterWebpackWarnings(stats.compilation.warnings, webpackWarningFilters); + } catch (error) { + console.error(error); + } stats = stats.toJson(); } var nonFatalErrors = (stats && stats.errors) || []; @@ -41,23 +45,60 @@ module.exports = function handleWebpackResult(stats, webpackWarningFilters) { }; function filterWebpackWarnings(unfilteredWarnings, webpackWarningFilters) { - // TODO check sanity of config - - var filteredWarnings = unfilteredWarnings.filter(function filterWarnings(warning, index, unfilteredWarnings) { - // TODO use webpackWarningFilters + if (!webpackWarningFilters) { + // No filters are configured. Use the complete, unfiltered list of warnings. + return unfilteredWarnings; + } - if (warning.name === "ModuleNotFoundError" - && warning.origin.rawRequest === "imports?process=>undefined!when" - && warning.dependencies[0].request === "vertx" + // Check the sanity of the webpackWarningFilters-configuration. + if (!Array.isArray(webpackWarningFilters)) { + throw new TypeError("config.webpackWarningFilters must be an array."); + } + for (var i = 0; i < webpackWarningFilters.length; i++) { + var webpackWarningFilter = webpackWarningFilters[i]; + if ("name" in webpackWarningFilter + && "origin/rawRequest" in webpackWarningFilter + && "dependencies/0/request" in webpackWarningFilter + && Object.keys(webpackWarningFilter).length === 3 // That is, webpackWarningFilter contains no keys other than these three. + && webpackWarningFilter.name === "ModuleNotFoundError" ) { - // This warning matches one of the filters. - // Remove it from the list, so that it is NOT shown in Jester's output. - return false; + // This filter config is supported. Proceed. } else { - // This warning matches none of the filters. - // Leave it in the list, so that it IS shown in Jester's output. + // This filter config isn't supported. Abort. + throw new Error( + "config.webpackWarningFilters[" + i + "] must be an object similar to {\n" + + " 'name': 'ModuleNotFoundError',\n" + + " 'origin/rawRequest': 'imports?process=>undefined!when',\n" + + " 'dependencies/0/request': 'vertx'\n" + + "}." + ); + } + } + + // There's at least one filter and all filter configs are supported. Do the actual filtering. + var filteredWarnings = unfilteredWarnings.filter(function filterWarning(warning, index, unfilteredWarnings) { + if (warning.name !== "ModuleNotFoundError") { + // filterWebpackWarnings only supports filtering of ModuleNotFoundError-warnings. + // This is some other kind of warning. Leave it in the list, so that it IS shown in Jester's output. return true; } + + for (var i = 0; i < webpackWarningFilters.length; i++) { + var webpackWarningFilter = webpackWarningFilters[i]; + if ( + warning.origin.rawRequest === webpackWarningFilter["origin/rawRequest"] + && warning.dependencies.length > 0 + && warning.dependencies[0].request === webpackWarningFilter["dependencies/0/request"] + ) { + // This warning matches one of the filters. + // Remove it from the list, so that it is NOT shown in Jester's output. + return false; + } + } + + // This warning matches none of the filters. + // Leave it in the list, so that it IS shown in Jester's output. + return true; }); return filteredWarnings; From 1d4c92642d1f70e9c6f916894d9777203575f4a6 Mon Sep 17 00:00:00 2001 From: Oscar de Groot Date: Fri, 27 Jun 2014 17:15:39 +0200 Subject: [PATCH 5/6] Extracted the sanity check of the warning filters to a separate function. --- src/lib/handleWebpackResult.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/lib/handleWebpackResult.js b/src/lib/handleWebpackResult.js index 53bb64d2..ca44a7e5 100644 --- a/src/lib/handleWebpackResult.js +++ b/src/lib/handleWebpackResult.js @@ -1,6 +1,7 @@ module.exports = function handleWebpackResult(stats, webpackWarningFilters) { if (stats) { try { + assertFiltersValid(webpackWarningFilters); stats.compilation.warnings = filterWebpackWarnings(stats.compilation.warnings, webpackWarningFilters); } catch (error) { console.error(error); @@ -44,13 +45,14 @@ module.exports = function handleWebpackResult(stats, webpackWarningFilters) { }; -function filterWebpackWarnings(unfilteredWarnings, webpackWarningFilters) { +/** + * Checks the sanity of the webpackWarningFilters-configuration. + */ +function assertFiltersValid(webpackWarningFilters) { if (!webpackWarningFilters) { - // No filters are configured. Use the complete, unfiltered list of warnings. - return unfilteredWarnings; + // No filters are configured. That's okay. + return; } - - // Check the sanity of the webpackWarningFilters-configuration. if (!Array.isArray(webpackWarningFilters)) { throw new TypeError("config.webpackWarningFilters must be an array."); } @@ -74,6 +76,13 @@ function filterWebpackWarnings(unfilteredWarnings, webpackWarningFilters) { ); } } +} + +function filterWebpackWarnings(unfilteredWarnings, webpackWarningFilters) { + if (!webpackWarningFilters) { + // No filters are configured. Use the complete, unfiltered list of warnings. + return unfilteredWarnings; + } // There's at least one filter and all filter configs are supported. Do the actual filtering. var filteredWarnings = unfilteredWarnings.filter(function filterWarning(warning, index, unfilteredWarnings) { From c06a3c3497505f44d969aef9c7baf86da5ea3ea9 Mon Sep 17 00:00:00 2001 From: Oscar de Groot Date: Tue, 1 Jul 2014 15:14:01 +0200 Subject: [PATCH 6/6] The filter-config check now returns a boolean and logs to the console instead of throwing exceptions. --- src/lib/handleWebpackResult.js | 61 ++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/lib/handleWebpackResult.js b/src/lib/handleWebpackResult.js index ca44a7e5..3f2de0a8 100644 --- a/src/lib/handleWebpackResult.js +++ b/src/lib/handleWebpackResult.js @@ -1,10 +1,7 @@ module.exports = function handleWebpackResult(stats, webpackWarningFilters) { if (stats) { - try { - assertFiltersValid(webpackWarningFilters); + if (filterConfigIsValid(webpackWarningFilters)) { stats.compilation.warnings = filterWebpackWarnings(stats.compilation.warnings, webpackWarningFilters); - } catch (error) { - console.error(error); } stats = stats.toJson(); } @@ -48,34 +45,40 @@ module.exports = function handleWebpackResult(stats, webpackWarningFilters) { /** * Checks the sanity of the webpackWarningFilters-configuration. */ -function assertFiltersValid(webpackWarningFilters) { - if (!webpackWarningFilters) { - // No filters are configured. That's okay. - return; - } - if (!Array.isArray(webpackWarningFilters)) { - throw new TypeError("config.webpackWarningFilters must be an array."); - } - for (var i = 0; i < webpackWarningFilters.length; i++) { - var webpackWarningFilter = webpackWarningFilters[i]; - if ("name" in webpackWarningFilter - && "origin/rawRequest" in webpackWarningFilter - && "dependencies/0/request" in webpackWarningFilter - && Object.keys(webpackWarningFilter).length === 3 // That is, webpackWarningFilter contains no keys other than these three. - && webpackWarningFilter.name === "ModuleNotFoundError" - ) { - // This filter config is supported. Proceed. +function filterConfigIsValid(webpackWarningFilters) { + var filterConfigIsValid = true; + if (webpackWarningFilters) { + if (Array.isArray(webpackWarningFilters)) { + for (var i = 0; i < webpackWarningFilters.length; i++) { + var webpackWarningFilter = webpackWarningFilters[i]; + if ("name" in webpackWarningFilter + && "origin/rawRequest" in webpackWarningFilter + && "dependencies/0/request" in webpackWarningFilter + && Object.keys(webpackWarningFilter).length === 3 // That is, webpackWarningFilter contains no keys other than these three. + && webpackWarningFilter.name === "ModuleNotFoundError" + ) { + // This filter config is supported. Proceed. + } else { + // This filter config isn't supported. Abort. + console.warn( + "config.webpackWarningFilters[" + i + "] must be an object similar to {\n" + + " 'name': 'ModuleNotFoundError',\n" + + " 'origin/rawRequest': 'imports?process=>undefined!when',\n" + + " 'dependencies/0/request': 'vertx'\n" + + "}." + ); + filterConfigIsValid = false; + } + } } else { - // This filter config isn't supported. Abort. - throw new Error( - "config.webpackWarningFilters[" + i + "] must be an object similar to {\n" + - " 'name': 'ModuleNotFoundError',\n" + - " 'origin/rawRequest': 'imports?process=>undefined!when',\n" + - " 'dependencies/0/request': 'vertx'\n" + - "}." - ); + console.warn("config.webpackWarningFilters must be an array."); + filterConfigIsValid = false; } + } else { + // No filters are configured. That's okay. + filterConfigIsValid = true; } + return filterConfigIsValid; } function filterWebpackWarnings(unfilteredWarnings, webpackWarningFilters) {