aboutsummaryrefslogtreecommitdiff
path: root/testlib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-14 00:10:55 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-14 00:10:55 +0100
commit8b855c969d3db4a2e7ba0c13b45f892a3e508317 (patch)
treec8c957cd90cc228428051c5bb4e70067aeadddb5 /testlib
parentbe5917c97b8163016ce797e0b725b05a38f4c847 (diff)
downloadwallet-core-8b855c969d3db4a2e7ba0c13b45f892a3e508317.tar.xz
generate coverage stubs for files that are not run
Diffstat (limited to 'testlib')
-rw-r--r--testlib/selenium/runtime.js30
1 files changed, 22 insertions, 8 deletions
diff --git a/testlib/selenium/runtime.js b/testlib/selenium/runtime.js
index 7fa9ee958..84660c35b 100644
--- a/testlib/selenium/runtime.js
+++ b/testlib/selenium/runtime.js
@@ -138,19 +138,33 @@ if (argv["coverage"]) {
driver.executeScript(script);
driver.wait(untilTestOver);
+
+/**
+ * Instrument and get a coverage stub for all
+ * files we don't have coverage for, so they show
+ * up in the report.
+ */
function augmentCoverage(cov) {
for (let file of globSync(projectRoot + "/src/**/*.js")) {
+ let suffix = file.substring(0, projectRoot.lenth);
+ if (/.*\/vendor\/.*/.test(suffix)) {
+ continue;
+ }
+ if (/.*\/taler-emscripten-lib.js/.test(suffix)) {
+ continue;
+ }
if (file in cov) {
continue;
}
- cov[file] = {
- "path":file,
- "s":{"1":0},
- "b":{},
- "f":{},
- "fnMap":{},
- "statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":0}}},
- "branchMap":{}
+ let instrumenter = new (require("istanbul").Instrumenter)();
+ let source = fs.readFileSync(file, "utf-8");
+ let instrumentedSrc = instrumenter.instrumentSync(source, file);
+ let covStubRE = /\{.*"path".*"fnMap".*"statementMap".*"branchMap".*\}/g;
+ let covStubMatch = covStubRE.exec(instrumentedSrc);
+
+ if (covStubMatch !== null) {
+ let covStub = JSON.parse(covStubMatch[0]);
+ cov[file] = covStub;
}
}
}