xref: /third_party/node/test/sequential/test-vm-break-on-sigint.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/sequential/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ci// This test ensures that running vm with breakOnSignt option in multiple
51cb0ef41Sopenharmony_ci// worker_threads does not crash.
61cb0ef41Sopenharmony_ci// Issue: https://github.com/nodejs/node/issues/43699
71cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads');
81cb0ef41Sopenharmony_ciconst vm = require('vm');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci// Don't use isMainThread to allow running this test inside a worker.
111cb0ef41Sopenharmony_ciif (!process.env.HAS_STARTED_WORKER) {
121cb0ef41Sopenharmony_ci  process.env.HAS_STARTED_WORKER = 1;
131cb0ef41Sopenharmony_ci  for (let i = 0; i < 10; i++) {
141cb0ef41Sopenharmony_ci    const worker = new Worker(__filename);
151cb0ef41Sopenharmony_ci    worker.on('exit', common.mustCall());
161cb0ef41Sopenharmony_ci  }
171cb0ef41Sopenharmony_ci} else {
181cb0ef41Sopenharmony_ci  const ctx = vm.createContext({});
191cb0ef41Sopenharmony_ci  for (let i = 0; i < 100; i++) {
201cb0ef41Sopenharmony_ci    vm.runInContext('console.log(1)', ctx, { breakOnSigint: true });
211cb0ef41Sopenharmony_ci  }
221cb0ef41Sopenharmony_ci}
23

Indexes created Thu Nov 07 10:32:03 CST 2024