From 26f42a248f4764f85c1c3c3c511b82a990e4b651 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Wed, 24 May 2023 03:56:29 +0900 Subject: fix(ext/node): add basic node:worker_threads support (#19192) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR restores `node:worker_threads` implementation and test cases from [`std@0.175.0/node`](https://github.com/denoland/deno_std/blob/0.175.0/node/worker_threads.ts). --------- Co-authored-by: Bartek IwaƄczuk --- cli/tests/node_compat/test/common/tmpdir.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'cli/tests/node_compat/test') diff --git a/cli/tests/node_compat/test/common/tmpdir.js b/cli/tests/node_compat/test/common/tmpdir.js index d3ce98e45..dbc945c13 100644 --- a/cli/tests/node_compat/test/common/tmpdir.js +++ b/cli/tests/node_compat/test/common/tmpdir.js @@ -2,14 +2,14 @@ // deno-lint-ignore-file // Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 16.13.0 +// Taken from Node 18.12.1 // This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually 'use strict'; const fs = require('fs'); const path = require('path'); -// const { isMainThread } = require('worker_threads'); +const { isMainThread } = require('worker_threads'); function rmSync(pathname) { fs.rmSync(pathname, { maxRetries: 3, recursive: true, force: true }); @@ -26,8 +26,8 @@ const tmpPath = path.join(testRoot, tmpdirName); let firstRefresh = true; function refresh() { - rmSync(this.path); - fs.mkdirSync(this.path); + rmSync(tmpPath); + fs.mkdirSync(tmpPath); if (firstRefresh) { firstRefresh = false; @@ -39,9 +39,8 @@ function refresh() { function onexit() { // Change directory to avoid possible EBUSY - // TODO(f3n67u): uncomment when `worker_thread.isMainThread` implemented - // if (isMainThread) - // process.chdir(testRoot); + if (isMainThread) + process.chdir(testRoot); try { rmSync(tmpPath); -- cgit v1.2.3