LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 let tests = {}; | 40 let tests = {}; |
41 for (let module of moduleNames) | 41 for (let module of moduleNames) |
42 tests[module] = nodeunit.testCase(require("./" + module + ".js")); | 42 tests[module] = nodeunit.testCase(require("./" + module + ".js")); |
43 | 43 |
44 return new Promise((resolve, reject) => | 44 return new Promise((resolve, reject) => |
45 { | 45 { |
46 nodeunit.runModules(tests, { | 46 nodeunit.runModules(tests, { |
47 moduleStart(name) | 47 moduleStart(name) |
48 { | 48 { |
49 if (typeof window.consoleLogs == "undefined") | 49 if (typeof window._consoleLogs == "undefined") |
50 window.consoleLogs = {failures: 0, log: []}; | 50 window._consoleLogs = {failures: 0, log: []}; |
51 console.log(bold(name)); | 51 console.log(bold(name)); |
52 }, | 52 }, |
53 testDone(name, assertions) | 53 testDone(name, assertions) |
54 { | 54 { |
55 let errors = assertions.filter(assertion => assertion.failed()) | 55 let errors = assertions.filter(assertion => assertion.failed()) |
56 .map(assertion => assertion.error); | 56 .map(assertion => assertion.error); |
57 | 57 |
58 if (errors.length == 0) | 58 if (errors.length == 0) |
59 console.log("\u2714 " + name); | 59 console.log("\u2714 " + name); |
60 else | 60 else |
61 { | 61 { |
62 console.log(error("\u2716 " + name) + "\n"); | 62 console.log(error("\u2716 " + name) + "\n"); |
63 errors.forEach(e => | 63 errors.forEach(e => |
64 { | 64 { |
65 if (e.stack) | 65 if (e.stack) |
66 console.log(e.stack); | 66 console.log(e.stack); |
67 else | 67 else |
68 console.log(String(e)); | 68 console.log(String(e)); |
69 console.log(""); | 69 console.log(""); |
70 }); | 70 }); |
71 } | 71 } |
72 }, | 72 }, |
73 done(assertions) | 73 done(assertions) |
74 { | 74 { |
75 let failures = assertions.filter(assertion => assertion.failed()); | 75 let failures = assertions.filter(assertion => assertion.failed()); |
76 if (failures.length) | 76 if (failures.length) |
77 { | 77 { |
78 window.consoleLogs.failures += failures.length; | 78 window._consoleLogs.failures += failures.length; |
79 console.log( | 79 console.log( |
80 "\n" + | 80 "\n" + |
81 bold(error("FAILURES: ")) + | 81 bold(error("FAILURES: ")) + |
82 failures.length + "/" + assertions.length + " assertions failed" | 82 failures.length + "/" + assertions.length + " assertions failed" |
83 ); | 83 ); |
84 } | 84 } |
85 else | 85 else |
86 { | 86 { |
87 console.log( | 87 console.log( |
88 "\n" + bold(ok("OK: ")) + | 88 `\n ${bold(ok("OK: "))}${assertions.length} assertions (${assertions
.duration}ms)` |
89 assertions.length + " assertions (" + assertions.duration + "ms)" | |
90 ); | 89 ); |
91 } | 90 } |
92 | 91 |
93 resolve(); | 92 resolve(); |
94 } | 93 } |
95 }); | 94 }); |
96 }); | 95 }); |
97 } | 96 } |
98 | 97 |
99 module.exports = runTests; | 98 module.exports = runTests; |
LEFT | RIGHT |