summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-11-07 11:34:14 -0500
committerGitHub <noreply@github.com>2020-11-07 11:34:14 -0500
commit7fa478295496d16bfc99dd80858544900c7b0a4c (patch)
treeeaf94141835cdc7d27e58c6a0d1977c9361b1525
parent0b003ef2c3c9029a2d92dfc23d760de895e0d7a4 (diff)
Return an error code when promise main() functions fail (#1002)
-rw-r--r--dev/util.js13
-rw-r--r--test/test-cache-map.js3
-rw-r--r--test/test-core.js3
-rw-r--r--test/test-database.js4
-rw-r--r--test/test-dictionary.js4
-rw-r--r--test/test-document-util.js3
-rw-r--r--test/test-dom-text-scanner.js3
-rw-r--r--test/test-japanese.js3
-rw-r--r--test/test-manifest.js4
-rw-r--r--test/test-object-property-accessor.js3
-rw-r--r--test/test-options-util.js3
-rw-r--r--test/test-profile-conditions.js3
-rw-r--r--test/test-schema.js3
-rw-r--r--test/test-text-source-map.js3
14 files changed, 38 insertions, 17 deletions
diff --git a/dev/util.js b/dev/util.js
index 971837af..c17cd29a 100644
--- a/dev/util.js
+++ b/dev/util.js
@@ -137,6 +137,16 @@ function createDictionaryArchive(dictionaryDirectory, dictionaryName) {
}
+async function testMain(func) {
+ try {
+ await func();
+ } catch (e) {
+ console.log(e);
+ process.exit(-1);
+ }
+}
+
+
module.exports = {
get JSZip() { return getJSZip(); },
getArgs,
@@ -144,5 +154,6 @@ module.exports = {
getDefaultManifest,
getDefaultManifestAndVariants,
createManifestString,
- createDictionaryArchive
+ createDictionaryArchive,
+ testMain
};
diff --git a/test/test-cache-map.js b/test/test-cache-map.js
index 12367a90..a0598c18 100644
--- a/test/test-cache-map.js
+++ b/test/test-cache-map.js
@@ -16,6 +16,7 @@
*/
const assert = require('assert');
+const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM({console});
@@ -218,4 +219,4 @@ function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-core.js b/test/test-core.js
index b5c0683f..3e8b8414 100644
--- a/test/test-core.js
+++ b/test/test-core.js
@@ -17,6 +17,7 @@
const assert = require('assert');
const crypto = require('crypto');
+const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM({
@@ -166,4 +167,4 @@ function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-database.js b/test/test-database.js
index dce89559..cbaf49dd 100644
--- a/test/test-database.js
+++ b/test/test-database.js
@@ -19,7 +19,7 @@ const fs = require('fs');
const url = require('url');
const path = require('path');
const assert = require('assert');
-const {JSZip, createDictionaryArchive} = require('../dev/util');
+const {JSZip, createDictionaryArchive, testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
require('fake-indexeddb/auto');
@@ -958,4 +958,4 @@ async function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-dictionary.js b/test/test-dictionary.js
index e7db75eb..1a2dca68 100644
--- a/test/test-dictionary.js
+++ b/test/test-dictionary.js
@@ -16,7 +16,7 @@
*/
const path = require('path');
-const {createDictionaryArchive} = require('../dev/util');
+const {createDictionaryArchive, testMain} = require('../dev/util');
const dictionaryValidate = require('../dev/dictionary-validate');
@@ -62,4 +62,4 @@ async function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-document-util.js b/test/test-document-util.js
index 99eea3ab..63a13581 100644
--- a/test/test-document-util.js
+++ b/test/test-document-util.js
@@ -19,6 +19,7 @@ const fs = require('fs');
const path = require('path');
const assert = require('assert');
const {JSDOM} = require('jsdom');
+const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
@@ -238,4 +239,4 @@ async function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-dom-text-scanner.js b/test/test-dom-text-scanner.js
index b9ff6239..ef59f33e 100644
--- a/test/test-dom-text-scanner.js
+++ b/test/test-dom-text-scanner.js
@@ -19,6 +19,7 @@ const fs = require('fs');
const path = require('path');
const assert = require('assert');
const {JSDOM} = require('jsdom');
+const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
@@ -180,4 +181,4 @@ async function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-japanese.js b/test/test-japanese.js
index ad3084f1..54186a96 100644
--- a/test/test-japanese.js
+++ b/test/test-japanese.js
@@ -16,6 +16,7 @@
*/
const assert = require('assert');
+const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM();
@@ -496,4 +497,4 @@ function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-manifest.js b/test/test-manifest.js
index 230e6139..cd2413b9 100644
--- a/test/test-manifest.js
+++ b/test/test-manifest.js
@@ -18,7 +18,7 @@
const fs = require('fs');
const path = require('path');
const assert = require('assert');
-const {getDefaultManifest, createManifestString} = require('../dev/util');
+const {getDefaultManifest, createManifestString, testMain} = require('../dev/util');
function loadManifestString() {
@@ -38,4 +38,4 @@ function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-object-property-accessor.js b/test/test-object-property-accessor.js
index 42fa3d40..b875575a 100644
--- a/test/test-object-property-accessor.js
+++ b/test/test-object-property-accessor.js
@@ -16,6 +16,7 @@
*/
const assert = require('assert');
+const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM({});
@@ -411,4 +412,4 @@ function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-options-util.js b/test/test-options-util.js
index 82859dd3..135b2b2e 100644
--- a/test/test-options-util.js
+++ b/test/test-options-util.js
@@ -19,6 +19,7 @@ const fs = require('fs');
const url = require('url');
const path = require('path');
const assert = require('assert');
+const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
@@ -627,4 +628,4 @@ async function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-profile-conditions.js b/test/test-profile-conditions.js
index 8ef24b5a..52d2ca24 100644
--- a/test/test-profile-conditions.js
+++ b/test/test-profile-conditions.js
@@ -16,6 +16,7 @@
*/
const assert = require('assert');
+const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
@@ -839,4 +840,4 @@ function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-schema.js b/test/test-schema.js
index 20f72518..34dd857a 100644
--- a/test/test-schema.js
+++ b/test/test-schema.js
@@ -16,6 +16,7 @@
*/
const assert = require('assert');
+const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM();
@@ -613,4 +614,4 @@ function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }
diff --git a/test/test-text-source-map.js b/test/test-text-source-map.js
index c9810d19..ef561653 100644
--- a/test/test-text-source-map.js
+++ b/test/test-text-source-map.js
@@ -16,6 +16,7 @@
*/
const assert = require('assert');
+const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM();
@@ -230,4 +231,4 @@ function main() {
}
-if (require.main === module) { main(); }
+if (require.main === module) { testMain(main); }