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 raw data with empty url is created when the test case include Deno.statSync call #24004

Closed
kt3k opened this issue May 28, 2024 · 1 comment · Fixed by #24007
Closed
Labels
bug Something isn't working correctly

Comments

@kt3k
Copy link
Member

kt3k commented May 28, 2024

Save the below file as test.ts:

Deno.test("test", () => {
  Deno.statSync(".");
});

And run the command deno test --coverage -A test.ts, then something like the following 2 json files are created:

{
  "scriptId": "308",
  "url": "file:///path/to/test.ts",
  "functions": [
    {
      "functionName": "",
      "ranges": [{ "startOffset": 0, "endOffset": 50, "count": 1 }],
      "isBlockCoverage": true
    },
    {
      "functionName": "",
      "ranges": [{ "startOffset": 18, "endOffset": 47, "count": 1 }],
      "isBlockCoverage": true
    }
  ]
}
{
  "scriptId": "303",
  "url": "",
  "functions": [
    {
      "functionName": "",
      "ranges": [{ "startOffset": 1, "endOffset": 1679, "count": 1 }],
      "isBlockCoverage": false
    }
  ]
}

The second json file has empty url property and causes deno coverage command failure.

Notes:

  • Deno.stat doesn't cause the same issue.
  • The same issue happens when Deno.statSync called at the top level.
  • The same issue happens when Deno.statSync is called in dependencies (and therefore this affects the @std/fs test coverage reports, for example)

Version: Deno 1.43.6

@kt3k kt3k added the bug Something isn't working correctly label May 28, 2024
@kt3k
Copy link
Member Author

kt3k commented May 28, 2024

This happens because statSync internally use Function constructor and that part is caught as another script (with empty url).

The below causes the same issue:

Deno.test("test", () => {
  eval("console.log(1)");
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant