Browse Source

build: run node tests

Samuel Attard 5 years ago
parent
commit
1d06f67672

+ 38 - 0
.circleci/config.yml

@@ -923,6 +923,21 @@ steps-test-nan: &steps-test-nan
           export ELECTRON_OUT_DIR=Default
           node electron/script/nan-spec-runner.js
 
+steps-test-node: &steps-test-node
+  steps:
+    - attach_workspace:
+          at: .
+    - *step-depot-tools-add-to-path
+    - *step-electron-dist-unzip
+    - *step-setup-linux-for-headless-testing
+    - *step-fix-known-hosts-linux
+    - run:
+        name: Run Node Tests
+        command: |
+          cd src
+          export ELECTRON_OUT_DIR=Default
+          node electron/script/node-spec-runner.js
+
 chromium-upgrade-branches: &chromium-upgrade-branches
   /chromium\-upgrade\/[0-9]+/
 
@@ -1369,6 +1384,14 @@ jobs:
       <<: *env-stack-dumping
     <<: *steps-test-nan
 
+  linux-x64-testing-node:
+    <<: *machine-linux-medium
+    environment:
+      <<: *env-linux-medium
+      <<: *env-headless-testing
+      <<: *env-stack-dumping
+    <<: *steps-test-node
+
   linux-x64-release-tests:
     <<: *machine-linux-medium
     environment:
@@ -1411,6 +1434,15 @@ jobs:
       <<: *env-stack-dumping
     <<: *steps-test-nan
 
+  linux-ia32-testing-node:
+    <<: *machine-linux-medium
+    environment:
+      <<: *env-linux-medium
+      <<: *env-ia32
+      <<: *env-headless-testing
+      <<: *env-stack-dumping
+    <<: *steps-test-node
+
   linux-ia32-release-tests:
     <<: *machine-linux-medium
     environment:
@@ -1605,6 +1637,9 @@ workflows:
       - linux-x64-testing-nan:
           requires:
             - linux-x64-testing
+      - linux-x64-testing-node:
+          requires:
+            - linux-x64-testing
 
       - linux-ia32-debug:
           requires:
@@ -1618,6 +1653,9 @@ workflows:
       - linux-ia32-testing-nan:
           requires:
             - linux-ia32-testing
+      - linux-ia32-testing-node:
+          requires:
+            - linux-ia32-testing
 
       - linux-arm-debug:
           requires:

+ 1 - 0
patches/node/.patches

@@ -39,3 +39,4 @@ src_expose_maybeinitializecontext_to_allow_existing_contexts.patch
 fix_extern_the_nativemoduleenv_and_options_parser_for_debug_builds.patch
 chore_read_nobrowserglobals_from_global_not_process.patch
 chore_split_createenvironment_into_createenvironment_and.patch
+chore_handle_default_configuration_not_being_set_in_the_electron_env.patch

+ 19 - 0
patches/node/chore_handle_default_configuration_not_being_set_in_the_electron_env.patch

@@ -0,0 +1,19 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Samuel Attard <[email protected]>
+Date: Tue, 23 Jul 2019 11:36:48 -0700
+Subject: chore: handle default_configuration not being set in the electron env
+
+
+diff --git a/test/common/index.js b/test/common/index.js
+index bbb74e2b988517bddc610084a9ee959eda6912e5..c8487ad94c9f4a9603cee0f2c368a4e119f92bcd 100644
+--- a/test/common/index.js
++++ b/test/common/index.js
+@@ -118,7 +118,7 @@ const enoughTestCpu = Array.isArray(cpus) &&
+ 
+ const rootDir = isWindows ? 'c:\\' : '/';
+ 
+-const buildType = process.config.target_defaults.default_configuration;
++const buildType = process.config.target_defaults ? process.config.target_defaults.default_configuration : 'Release';
+ 
+ 
+ // If env var is set then enable async_hook hooks for all tests.

+ 330 - 0
script/node-disabled-tests.json

@@ -0,0 +1,330 @@
+[
+  "parallel/test-async-hooks-close-during-destroy",
+  "parallel/test-async-hooks-promise",
+  "parallel/test-async-hooks-promise-triggerid",
+  "parallel/test-async-hooks-top-level-clearimmediate",
+  "parallel/test-bootstrap-modules",
+  "parallel/test-buffer-backing-arraybuffer",
+  "parallel/test-buffer-constructor-node-modules-paths",
+  "parallel/test-child-process-exec-maxbuf",
+  "parallel/test-child-process-execfilesync-maxbuf",
+  "parallel/test-child-process-execfile-maxbuf",
+  "parallel/test-child-process-execsync-maxbuf",
+  "parallel/test-child-process-fork-exec-path",
+  "parallel/test-child-process-promisified",
+  "parallel/test-child-process-spawnsync-maxbuf",
+  "parallel/test-child-process-spawnsync-input",
+  "parallel/test-cli-bad-options",
+  "parallel/test-cli-node-print-help",
+  "parallel/test-child-process-windows-hide",
+  "parallel/test-cli-eval",
+  "parallel/test-cli-syntax-eval",
+  "parallel/test-cli-node-options",
+  "parallel/test-cli-syntax-piped-good",
+  "parallel/test-cli-syntax-piped-bad",
+  "parallel/test-code-cache",
+  "parallel/test-common-gc",
+  "parallel/test-crypto-aes-wrap",
+  "parallel/test-crypto",
+  "parallel/test-crypto-authenticated",
+  "parallel/test-crypto-des3-wrap",
+  "parallel/test-crypto-binary-default",
+  "parallel/test-crypto-certificate",
+  "parallel/test-crypto-cipher-decipher",
+  "parallel/test-crypto-cipheriv-decipheriv",
+  "parallel/test-crypto-ecb",
+  "parallel/test-crypto-ecdh-convert-key",
+  "parallel/test-crypto-classes",
+  "parallel/test-crypto-engine",
+  "parallel/test-crypto-dh",
+  "parallel/test-crypto-hash-stream-pipe",
+  "parallel/test-crypto-key-objects",
+  "parallel/test-crypto-keygen",
+  "parallel/test-crypto-padding",
+  "parallel/test-crypto-padding-aes256",
+  "parallel/test-crypto-sign-verify",
+  "parallel/test-crypto-rsa-dsa",
+  "parallel/test-crypto-stream",
+  "parallel/test-debugger-pid",
+  "parallel/test-crypto-scrypt",
+  "parallel/test-debug-usage",
+  "parallel/test-domain-async-id-map-leak",
+  "parallel/test-domain-abort-on-uncaught",
+  "parallel/test-dummy-stdio",
+  "parallel/test-domain-with-abort-on-uncaught-exception",
+  "parallel/test-freeze-intrinsics",
+  "parallel/test-fs-write-sigxfsz",
+  "parallel/test-http-client-readable",
+  "parallel/test-gc-tls-external-memory",
+  "parallel/test-http-generic-streams",
+  "parallel/test-http-pipeline-requests-connection-leak",
+  "parallel/test-http2-compat-serverrequest-settimeout",
+  "parallel/test-http2-compat-serverresponse-settimeout",
+  "parallel/test-https-agent-session-reuse",
+  "parallel/test-https-options-boolean-check",
+  "parallel/test-inspector-port-zero-cluster",
+  "parallel/test-inspector-vm-global-accessors-getter-sideeffect",
+  "parallel/test-inspector-vm-global-accessors-sideeffects",
+  "parallel/test-internal-util-weakreference",
+  "parallel/test-inspector-heap-allocation-tracker",
+  "parallel/test-module-loading-globalpaths",
+  "parallel/test-module-version",
+  "parallel/test-openssl-ca-options",
+  "parallel/test-preload-print-process-argv",
+  "parallel/test-process-env-allowed-flags-are-documented",
+  "parallel/test-process-env-sideeffects",
+  "parallel/test-process-exception-capture",
+  "parallel/test-process-exception-capture-should-abort-on-uncaught",
+  "parallel/test-process-exception-capture-should-abort-on-uncaught-setflagsfromstring",
+  "parallel/test-process-exec-argv",
+  "parallel/test-process-external-stdio-close",
+  "parallel/test-process-external-stdio-close-spawn",
+  "parallel/test-process-uptime",
+  "parallel/test-process-versions",
+  "parallel/test-readline-interface",
+  "parallel/test-inspector-esm",
+  "parallel/test-repl-harmony",
+  "parallel/test-inspector-tracing-domain",
+  "parallel/test-repl",
+  "parallel/test-repl-require-after-write",
+  "parallel/test-repl-pretty-custom-stack",
+  "parallel/test-repl-pretty-stack",
+  "parallel/test-repl-uncaught-exception",
+  "parallel/test-repl-unexpected-token-recoverable",
+  "parallel/test-repl-underscore",
+  "parallel/test-signal-handler",
+  "parallel/test-security-revert-unknown",
+  "parallel/test-stdout-close-catch",
+  "parallel/test-policy-integrity",
+  "parallel/test-repl-tab-complete",
+  "parallel/test-tls-cert-chains-concat",
+  "parallel/test-tls-cert-chains-in-ca",
+  "parallel/test-tls-client-getephemeralkeyinfo",
+  "parallel/test-tls-client-mindhsize",
+  "parallel/test-tls-cli-min-version-1.3",
+  "parallel/test-tls-cli-max-version-1.2",
+  "parallel/test-tls-cli-max-version-1.3",
+  "parallel/test-tls-client-auth",
+  "parallel/test-tls-cli-min-version-1.1",
+  "parallel/test-tls-cli-min-version-1.2",
+  "parallel/test-tls-client-reject",
+  "parallel/test-tls-client-renegotiation-13",
+  "parallel/test-tls-disable-renegotiation",
+  "parallel/test-tls-empty-sni-context",
+  "parallel/test-tls-handshake-error",
+  "parallel/test-tls-generic-stream",
+  "parallel/test-tls-getcipher",
+  "parallel/test-tls-finished",
+  "parallel/test-tls-env-bad-extra-ca",
+  "parallel/test-tls-honorcipherorder",
+  "parallel/test-tls-env-extra-ca",
+  "parallel/test-tls-key-mismatch",
+  "parallel/test-tls-junk-server",
+  "parallel/test-tls-max-send-fragment",
+  "parallel/test-tls-multi-key",
+  "parallel/test-tls-multi-pfx",
+  "parallel/test-tls-no-cert-required",
+  "parallel/test-tls-min-max-version",
+  "parallel/test-tls-options-boolean-check",
+  "parallel/test-tls-passphrase",
+  "parallel/test-tls-peer-certificate",
+  "parallel/test-tls-pfx-authorizationerror",
+  "parallel/test-tls-server-failed-handshake-emits-clienterror",
+  "parallel/test-tls-set-ciphers-error",
+  "parallel/test-tls-set-ciphers",
+  "parallel/test-tls-socket-failed-handshake-emits-error",
+  "parallel/test-tls-ticket",
+  "parallel/test-trace-events-api-worker-disabled",
+  "parallel/test-tls-ticket-cluster",
+  "parallel/test-trace-events-dynamic-enable",
+  "parallel/test-trace-events-dynamic-enable-workers-disabled",
+  "parallel/test-trace-events-all",
+  "parallel/test-trace-events-binding",
+  "parallel/test-trace-events-async-hooks",
+  "parallel/test-trace-events-category-used",
+  "parallel/test-trace-events-fs-sync",
+  "parallel/test-trace-events-bootstrap",
+  "parallel/test-trace-events-console",
+  "parallel/test-trace-events-process-exit",
+  "parallel/test-trace-events-environment",
+  "parallel/test-trace-events-file-pattern",
+  "parallel/test-trace-events-perf",
+  "parallel/test-trace-events-promises",
+  "parallel/test-trace-events-metadata",
+  "parallel/test-trace-events-none",
+  "parallel/test-trace-events-vm",
+  "parallel/test-trace-events-v8",
+  "parallel/test-trace-events-worker-metadata",
+  "parallel/test-v8-flags",
+  "parallel/test-v8-coverage",
+  "parallel/test-vm-basic",
+  "parallel/test-vm-codegen",
+  "parallel/test-vm-parse-abort-on-uncaught-exception",
+  "parallel/test-vm-syntax-error-message",
+  "parallel/test-warn-sigprof",
+  "parallel/test-whatwg-encoding-custom-textdecoder",
+  "parallel/test-worker",
+  "parallel/test-worker-abort-on-uncaught-exception-terminate",
+  "parallel/test-worker-cleanexit-with-js",
+  "parallel/test-worker-cleanexit-with-moduleload",
+  "parallel/test-worker-cleanup-handles",
+  "parallel/test-worker-console-listeners",
+  "parallel/test-worker-dns-terminate",
+  "parallel/test-worker-error-stack-getter-throws",
+  "parallel/test-worker-esm-missing-main",
+  "parallel/test-worker-debug",
+  "parallel/test-worker-dns-terminate-during-query",
+  "parallel/test-worker-esm-exit",
+  "parallel/test-worker-esmodule",
+  "parallel/test-worker-exit-from-uncaught-exception",
+  "parallel/test-worker-exit-code",
+  "parallel/test-worker-execargv",
+  "parallel/test-worker-fs-stat-watcher",
+  "parallel/test-worker-message-channel",
+  "parallel/test-worker-memory",
+  "parallel/test-worker-http2-generic-streams-terminate",
+  "parallel/test-worker-message-channel-sharedarraybuffer",
+  "parallel/test-worker-message-not-serializable",
+  "parallel/test-worker-message-port-drain",
+  "parallel/test-worker-message-port-message-before-close",
+  "parallel/test-worker-message-port-transfer-duplicate",
+  "parallel/test-worker-message-port-transfer-target",
+  "parallel/test-worker-message-port-transfer-terminate",
+  "parallel/test-worker-message-port-wasm-module",
+  "parallel/test-worker-message-port-wasm-threads",
+  "parallel/test-worker-mjs-workerdata",
+  "parallel/test-worker-process-env-shared",
+  "parallel/test-worker-onmessage",
+  "parallel/test-worker-parent-port-ref",
+  "parallel/test-worker-nexttick-terminate",
+  "parallel/test-worker-no-stdin-stdout-interaction",
+  "parallel/test-worker-onmessage-not-a-function",
+  "parallel/test-worker-process-cwd",
+  "parallel/test-worker-process-env",
+  "parallel/test-worker-ref",
+  "parallel/test-worker-ref-onexit",
+  "parallel/test-worker-relative-path",
+  "parallel/test-worker-relative-path-double-dot",
+  "parallel/test-worker-safe-getters",
+  "parallel/test-worker-message-type-unknown",
+  "parallel/test-worker-stack-overflow",
+  "parallel/test-worker-uncaught-exception",
+  "parallel/test-worker-syntax-error",
+  "parallel/test-worker-terminate-microtask-loop",
+  "parallel/test-worker-vm-context-terminate",
+  "parallel/test-worker-stdio",
+  "parallel/test-worker-syntax-error-file",
+  "parallel/test-worker-terminate-timers",
+  "parallel/test-worker-terminate-http2-respond-with-file",
+  "parallel/test-worker-unsupported-things",
+  "parallel/test-worker-uncaught-exception-async",
+  "parallel/test-worker-workerdata-sharedarraybuffer",
+  "async-hooks/test-crypto-randomBytes",
+  "async-hooks/test-fseventwrap",
+  "async-hooks/test-fsreqcallback-readFile",
+  "async-hooks/test-getaddrinforeqwrap",
+  "async-hooks/test-emit-after-on-destroyed",
+  "async-hooks/test-emit-before-after",
+  "async-hooks/test-emit-before-on-destroyed",
+  "async-hooks/test-getnameinforeqwrap",
+  "async-hooks/test-emit-init",
+  "async-hooks/test-graph.signal",
+  "async-hooks/test-crypto-pbkdf2",
+  "async-hooks/test-nexttick-default-trigger",
+  "async-hooks/test-promise",
+  "async-hooks/test-improper-order",
+  "async-hooks/test-pipewrap",
+  "async-hooks/test-queue-microtask",
+  "async-hooks/test-signalwrap",
+  "async-hooks/test-statwatcher",
+  "async-hooks/test-timers.setInterval",
+  "es-module/test-esm-cjs-main",
+  "es-module/test-esm-json-cache",
+  "es-module/test-esm-snapshot",
+  "es-module/test-esm-no-extension",
+  "report/test-report-config",
+  "report/test-report-getreport",
+  "report/test-report-signal",
+  "es-module/test-esm-specifiers",
+  "report/test-report-uncaught-exception",
+  "es-module/test-esm-type-flag",
+  "report/test-report-writereport",
+  "abort/test-abort-backtrace",
+  "abort/test-worker-abort-uncaught-exception",
+  "sequential/test-child-process-execsync",
+  "sequential/test-cli-syntax-bad",
+  "sequential/test-cli-syntax-good",
+  "sequential/test-cli-syntax-require",
+  "sequential/test-cpu-prof-default",
+  "sequential/test-cpu-prof-dir-absolute",
+  "sequential/test-cpu-prof-dir-and-name",
+  "sequential/test-cpu-prof-dir-relative",
+  "sequential/test-cpu-prof-dir-worker",
+  "sequential/test-cpu-prof-drained",
+  "sequential/test-cpu-prof-exit",
+  "sequential/test-cpu-prof-invalid-options",
+  "sequential/test-cpu-prof-kill",
+  "sequential/test-cpu-prof-name",
+  "sequential/test-cpu-prof-worker-argv",
+  "sequential/test-deprecation-flags",
+  "sequential/test-fs-watch",
+  "sequential/test-heap-prof",
+  "sequential/test-heapdump",
+  "sequential/test-heapdump-flag",
+  "sequential/test-inspector",
+  "sequential/test-inspector-async-call-stack-abort",
+  "sequential/test-inspector-break-when-eval",
+  "sequential/test-inspector-console",
+  "sequential/test-inspector-contexts",
+  "sequential/test-inspector-port-zero",
+  "sequential/test-inspector-resource-name-to-url",
+  "sequential/test-inspector-stress-http",
+  "sequential/test-perf-hooks",
+  "sequential/test-process-warnings",
+  "sequential/test-tls-connect",
+  "parallel/test-vm-module-basic",
+  "parallel/test-repl-sigint-nested-eval",
+  "parallel/test-repl-sigint",
+  "sequential/test-vm-timeout-rethrow",
+  "parallel/test-vm-sigint",
+  "parallel/test-vm-timeout",
+  "parallel/test-vm-sigint-existing-handler",
+  "message/assert_throws_stack",
+  "message/async_error_eval_esm",
+  "message/async_error_sync_esm",
+  "message/console",
+  "message/core_line_numbers",
+  "message/error_exit",
+  "message/esm_display_syntax_error",
+  "message/esm_display_syntax_error_import",
+  "message/esm_display_syntax_error_import_module",
+  "message/esm_display_syntax_error_module",
+  "message/eval_messages",
+  "message/events_unhandled_error_common_trace",
+  "message/events_unhandled_error_nexttick",
+  "message/events_unhandled_error_sameline",
+  "message/if-error-has-good-stack",
+  "message/internal_assert",
+  "message/internal_assert_fail",
+  "message/promise_always_throw_unhandled",
+  "message/stdin_messages",
+  "message/undefined_reference_in_new_context",
+  "message/unhandled_promise_trace_warnings",
+  "message/util_inspect_error",
+  "message/v8_warning",
+  "message/vm_display_runtime_error",
+  "message/vm_display_syntax_error",
+  "message/vm_dont_display_runtime_error",
+  "message/vm_dont_display_syntax_error",
+  "pseudo-tty/console_colors",
+  "pseudo-tty/ref_keeps_node_running",
+  "pseudo-tty/test-async-wrap-getasyncid-tty",
+  "pseudo-tty/test-fatal-error",
+  "pseudo-tty/test-handle-wrap-isrefed-tty",
+  "pseudo-tty/test-set-raw-mode-reset",
+  "pseudo-tty/test-set-raw-mode-reset-process-exit",
+  "pseudo-tty/test-set-raw-mode-reset-signal",
+  "pseudo-tty/test-tty-color-support",
+  "pseudo-tty/test-tty-window-size",
+  "pseudo-tty/test-tty-wrap"
+]

+ 35 - 0
script/node-spec-runner.js

@@ -0,0 +1,35 @@
+const cp = require('child_process')
+const fs = require('fs')
+const path = require('path')
+
+const BASE = path.resolve(__dirname, '../..')
+const NODE_DIR = path.resolve(BASE, 'third_party', 'electron_node')
+const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
+
+const utils = require('./lib/utils')
+const { YARN_VERSION } = require('./yarn')
+
+if (!process.mainModule) {
+  throw new Error('Must call the node spec runner directly')
+}
+
+async function main () {
+  const DISABLED_TESTS = require('./node-disabled-tests.json')
+
+  const testChild = cp.spawn('python', ['tools/test.py', '--verbose', '-p', 'tap', '--logfile', 'test.tap', '--mode=debug', 'default', `--skip-tests=${DISABLED_TESTS.join(',')}`, '--shell', utils.getAbsoluteElectronExec(), '-J'], {
+    env: {
+      ...process.env,
+      ELECTRON_RUN_AS_NODE: 'true'
+    },
+    cwd: NODE_DIR,
+    stdio: 'inherit'
+  })
+  testChild.on('exit', (testCode) => {
+    process.exit(testCode)
+  })
+}
+
+main().catch((err) => {
+  console.error('An unhandled error occurred in the node spec runner', err)
+  process.exit(1)
+})

+ 10 - 9
shell/app/node_main.cc

@@ -47,15 +47,6 @@ int NodeMain(int argc, char* argv[]) {
     feature_list->InitializeFromCommandLine("", "");
     base::FeatureList::SetInstance(std::move(feature_list));
 
-    gin::V8Initializer::LoadV8Snapshot(
-        gin::V8Initializer::V8SnapshotFileType::kWithAdditionalContext);
-    gin::V8Initializer::LoadV8Natives();
-
-    // V8 requires a task scheduler apparently
-    base::ThreadPoolInstance::CreateAndStartWithDefaultParams("Electron");
-
-    // Initialize gin::IsolateHolder.
-    JavascriptEnvironment gin_env(loop);
 #if defined(_WIN64)
     crash_reporter::CrashReporterWin::SetUnhandledExceptionFilter();
 #endif
@@ -67,6 +58,16 @@ int NodeMain(int argc, char* argv[]) {
     const char** exec_argv;
     node::Init(&argc, const_cast<const char**>(argv), &exec_argc, &exec_argv);
 
+    gin::V8Initializer::LoadV8Snapshot(
+        gin::V8Initializer::V8SnapshotFileType::kWithAdditionalContext);
+    gin::V8Initializer::LoadV8Natives();
+
+    // V8 requires a task scheduler apparently
+    base::ThreadPoolInstance::CreateAndStartWithDefaultParams("Electron");
+
+    // Initialize gin::IsolateHolder.
+    JavascriptEnvironment gin_env(loop);
+
     node::Environment* env = node::CreateEnvironment(
         node::CreateIsolateData(gin_env.isolate(), loop, gin_env.platform()),
         gin_env.context(), argc, argv, exec_argc, exec_argv);