无法在MACOS上连续两次运行VSCODE扩展启动项目测试

发布于 2025-01-17 13:12:00 字数 3844 浏览 4 评论 0原文

我正在实现 VSCode 扩展,并且已按照 此链接设置了项目

它创建了一个入门项目,并带有一个 src/test/runTest.ts:

import * as path from 'path';

import { runTests } from '@vscode/test-electron';

async function main() {
    try {
        // The folder containing the Extension Manifest package.json
        // Passed to `--extensionDevelopmentPath`
        const extensionDevelopmentPath = path.resolve(__dirname, '../../');

        // The path to test runner
        // Passed to --extensionTestsPath
        const extensionTestsPath = path.resolve(__dirname, './suite/index');

        // Download VS Code, unzip it and run the integration test
        await runTests({ extensionDevelopmentPath, extensionTestsPath });
    } catch (err) {
        console.error('Failed to run tests');
        process.exit(1);
    }
}

main();

和一个 package.json:

{
    "compile": "tsc -p ./",
    "pretest": "npm run compile && npm run lint",
    "lint": "eslint src --ext ts",
    "test": "node ./out/test/runTest.js"
}

我无法

npm test

连续运行两次。


第一次,一切顺利,看起来正在将 VSCode 下载到文件夹 .vscode-test 中。

Downloading VS Code 1.65.2 from https://update.code.visualstudio.com/1.65.2/darwin/stable
Downloading VS Code [==============================] 100%Downloaded VS Code 1.65.2 into /my-path/my-project/.vscode-test/vscode-darwin-1.65.2

但是,我收到警告:

WARNING: IPC handle "/my-path/my-project/.vscode-test/user-data/1.65.2-main.sock" is longer than 103 chars, try a shorter --user-data-dir

当我第二次运行测试时,如果失败:

Found existing install in /my-path/my-project/.vscode-test/vscode-darwin-1.65.2. Skipping download
WARNING: IPC handle "/my-path/my-project/.vscode-test/user-data/1.65.2-main.sock" is longer than 103 chars, try a shorter --user-data-dir
[main 2022-03-29T14:44:22.271Z] Could not delete obsolete instance handle Error: ENOENT: no such file or directory, unlink '/my-path/my-project/.vscode-test/user-data/1.65.2-main.sock'
    at unlinkSync (original-fs.js:1210:3)
    at ne.claimInstance (/my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:5083)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async /my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:2282
    at async ne.startup (/my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:2151) {
  errno: -2,
  syscall: 'unlink',
  code: 'ENOENT',
  path: '/my-path/my-project/.vscode-test/user-data/1.65.2-main.sock'
}
[main 2022-03-29T14:44:22.274Z] Error: ENOENT: no such file or directory, unlink '/my-path/my-project/.vscode-test/user-data/1.65.2-main.sock'
    at unlinkSync (original-fs.js:1210:3)
    at ne.claimInstance (/my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:5083)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async /my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:2282
    at async ne.startup (/my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:2151)
Exit code:   1
Failed to run tests

但如果我删除文件夹 .vscode-test,它就可以正常工作。

发生了什么事,我能做什么?

I am implementing a VSCode extension and I have set up the project following this link.

It creates a starter project and with it a src/test/runTest.ts:

import * as path from 'path';

import { runTests } from '@vscode/test-electron';

async function main() {
    try {
        // The folder containing the Extension Manifest package.json
        // Passed to `--extensionDevelopmentPath`
        const extensionDevelopmentPath = path.resolve(__dirname, '../../');

        // The path to test runner
        // Passed to --extensionTestsPath
        const extensionTestsPath = path.resolve(__dirname, './suite/index');

        // Download VS Code, unzip it and run the integration test
        await runTests({ extensionDevelopmentPath, extensionTestsPath });
    } catch (err) {
        console.error('Failed to run tests');
        process.exit(1);
    }
}

main();

and a package.json:

{
    "compile": "tsc -p ./",
    "pretest": "npm run compile && npm run lint",
    "lint": "eslint src --ext ts",
    "test": "node ./out/test/runTest.js"
}

I cannot run

npm test

twice in a row.


The first time, everything goes well, and it looks like it is downloading VSCode in the folder .vscode-test.

Downloading VS Code 1.65.2 from https://update.code.visualstudio.com/1.65.2/darwin/stable
Downloading VS Code [==============================] 100%Downloaded VS Code 1.65.2 into /my-path/my-project/.vscode-test/vscode-darwin-1.65.2

However, I get a warning:

WARNING: IPC handle "/my-path/my-project/.vscode-test/user-data/1.65.2-main.sock" is longer than 103 chars, try a shorter --user-data-dir

When I run the tests a second time, if fails:

Found existing install in /my-path/my-project/.vscode-test/vscode-darwin-1.65.2. Skipping download
WARNING: IPC handle "/my-path/my-project/.vscode-test/user-data/1.65.2-main.sock" is longer than 103 chars, try a shorter --user-data-dir
[main 2022-03-29T14:44:22.271Z] Could not delete obsolete instance handle Error: ENOENT: no such file or directory, unlink '/my-path/my-project/.vscode-test/user-data/1.65.2-main.sock'
    at unlinkSync (original-fs.js:1210:3)
    at ne.claimInstance (/my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:5083)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async /my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:2282
    at async ne.startup (/my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:2151) {
  errno: -2,
  syscall: 'unlink',
  code: 'ENOENT',
  path: '/my-path/my-project/.vscode-test/user-data/1.65.2-main.sock'
}
[main 2022-03-29T14:44:22.274Z] Error: ENOENT: no such file or directory, unlink '/my-path/my-project/.vscode-test/user-data/1.65.2-main.sock'
    at unlinkSync (original-fs.js:1210:3)
    at ne.claimInstance (/my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:5083)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async /my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:2282
    at async ne.startup (/my-path/my-project/.vscode-test/vscode-darwin-1.65.2/Visual Studio Code.app/Contents/Resources/app/out/vs/code/electron-main/main.js:77:2151)
Exit code:   1
Failed to run tests

But it works fine if I delete the folder .vscode-test.

What is happening and what can I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空‖城人不在 2025-01-24 13:12:00

尝试使您的工作目录短
或者
使用OS临时目录:

例如,

await runTests({ 
  extensionDevelopmentPath, 
  extensionTestsPath,
  launchArgs: ['--user-data-dir', `${os.tmpdir()}`]
});

try to make your work directory shorter
or
use the os temporary directory

for example:

await runTests({ 
  extensionDevelopmentPath, 
  extensionTestsPath,
  launchArgs: ['--user-data-dir', `${os.tmpdir()}`]
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文