Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage shows 0% in windows 11 but works good in WSL2 #491

Open
chouzz opened this issue Aug 11, 2023 · 1 comment
Open

Coverage shows 0% in windows 11 but works good in WSL2 #491

chouzz opened this issue Aug 11, 2023 · 1 comment

Comments

@chouzz
Copy link

chouzz commented Aug 11, 2023

  • Version: 8.0.1
  • Platform: windows 11 and wsl2
  • Nodejs: both v16.14.0 in windows11 and wsl2

Reproduce steps:

  1. Generate vscode sample extension
npm install -g yo generator-code
yo code 
// input extension-test and other can be default
  1. Install c8, according to https://stackoverflow.com/questions/71664061/how-to-generate-a-coverage-report-with-vscode-extension-tests

  2. Make a sample test case:
    Make new file in src called resolvedPath.ts

import * as path from 'path';

export function createResolvedFilePath(...pathParts: string[]) {
    return path.resolve(...pathParts);
}

make test file in test/suite/resolvedPath.test.ts

import * as assert from 'assert';
import { createResolvedFilePath } from '../../resolvedPath';

suite('Suite::Tests::ResolvedPath', async () => {
    test('Test::should return full path', async () => {
        const resolvedPath = createResolvedFilePath('/home/user/src/main.cpp');
        assert.strictEqual(resolvedPath, '/home/user/src/main.cpp');
    });

});

And use this function in extension.ts

export function activate(context: vscode.ExtensionContext) {

    // Use the console to output diagnostic information (console.log) and errors (console.error)
    // This line of code will only be executed once when your extension is activated
    console.log('Congratulations, your extension "extension-test" is now active!');
    // add test function
    const resolvedPath = createResolvedFilePath(
  	  process.platform === 'win32' ? 'd:/' : '/', 'user', 'src');
    console.log(resolvedPath)
    // The command has been defined in the package.json file
    // Now provide the implementation of the command with registerCommand
    // The commandId parameter must match the command field in package.json
    let disposable = vscode.commands.registerCommand('extension-test.helloWorld', () => {
  	  // The code you place here will be executed every time your command is executed
  	  // Display a message box to the user
  	  vscode.window.showInformationMessage('Hello World from extension-test!');
    });

    context.subscriptions.push(disposable);
}
  1. run coverage command
npm run coverage

In wsl, it works good:

    ✔ Sample test
  Suite::Tests::ResolvedPath
    ✔ Test::should return full path
  2 passing (9ms)
[23786:0811/113714.110698:ERROR:cert_verify_proc_builtin.cc(670)] CertVerifyProcBuiltin for marketplace.visualstudio.com failed:
----- Certificate i=1 (CN=Huawei Web Secure Internet Gateway CA,OU=IT,O=Huawei,L=Shenzhen,ST=GuangDong,C=cn) -----
ERROR: No matching issuer found


[23853:0811/113714.111671:ERROR:ssl_client_socket_impl.cc(982)] handshake failed; returned -1, SSL error code 1, net_error -202
XHR failed: Error: XHR failed
    at y.onerror (vscode-file://vscode-app/home/xxxxx/src/extension-test/.vscode-test/vscode-linux-x64-1.81.1/resources/app/out/vs/workbench/workbench.desktop.main.js:77:1261)
[main 2023-08-11T03:37:14.116Z] Extension host with pid 24137 exited with code: 0, signal: unknown.
Exit code:   0
Done

-----------------|---------|----------|---------|---------|-------------------
File             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------------|---------|----------|---------|---------|-------------------
All files        |   14.28 |       50 |      50 |   14.28 |
 extension.ts    |       0 |        0 |       0 |       0 | 1-30
 resolvedPath.ts |     100 |      100 |     100 |     100 |
-----------------|---------|----------|---------|---------|-------------------
ERROR: Coverage for lines (14.28%) does not meet global threshold (90%)

image

But in windows 11, it doesn't work:

PS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
Found existing install in D:\src\samples\typescript\extension-test\.vscode-test\vscode-win32-x64-archive-1.81.1. Skipping download

[main 2023-08-11T03:49:09.234Z] update#setState disabled
[main 2023-08-11T03:49:09.237Z] update#ctor - updates are disabled by the environment
Loading development extension at d:\src\samples\typescript\extension-test
[vscode.php]: One or more snippets from the extension 'php' very likely confuse snippet-variables and snippet-placeholders (see https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax for more details)

  Extension Test Suite
    √ Sample test
  Suite::Tests::ResolvedPath
    √ Test::should return full path
  2 passing (4ms)
[main 2023-08-11T03:49:11.484Z] Extension host with pid 48856 exited with code: 0, signal: unknown.
Exit code:   0
Done

-----------------|---------|----------|---------|---------|-------------------
File             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------------|---------|----------|---------|---------|-------------------
All files        |       0 |        0 |       0 |       0 |
 extension.ts    |       0 |        0 |       0 |       0 | 1-29
 resolvedPath.ts |       0 |        0 |       0 |       0 | 1-5
-----------------|---------|----------|---------|---------|-------------------
ERROR: Coverage for lines (0%) does not meet global threshold (90%)

image

@chouzz
Copy link
Author

chouzz commented Aug 11, 2023

Update:

c8 v6.0.1 works good in windows, but v7 and v8 not ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant