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

Inaccurate test coverage might be caused by emojis #10936

Closed
Tracked by #12826
eibens opened this issue Jun 11, 2021 · 4 comments · Fixed by #14607
Closed
Tracked by #12826

Inaccurate test coverage might be caused by emojis #10936

eibens opened this issue Jun 11, 2021 · 4 comments · Fixed by #14607
Assignees
Labels
bug Something isn't working correctly testing related to deno test and coverage

Comments

@eibens
Copy link

eibens commented Jun 11, 2021

Hi, I am having an issue where the output of deno coverage appears inaccurate. I was able to narrow it down to a minimal example; instructions below. I hope it is reproducible. The problem goes away if the emojis or the unused function h are removed. Removing a single emoji removes line 2 from the coverage report, but still inaccurately keeps line 3. I have not tested it with other emojis ☺️

This is the mod.ts file:

export default function () {
  return "📣❓";
}

function h() {}

This is the mod_test.ts file:

import f from "./mod.ts";

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

These are the shell commands:

deno test --coverage=.cov
deno coverage .cov
rm -rf .cov

This is the output of deno coverage. As far as I understand it, line 2 and 3 should be covered:

 cover file:///home/mod.ts ... 25.000% (1/4)
   2 |   return "📣❓";
   3 | }
-----|-----
   5 | function h() {}

This is the output of deno --version:

deno 1.11.0 (release, x86_64-unknown-linux-gnu)
v8 9.1.269.35
typescript 4.3.2
@bartlomieju bartlomieju added the bug Something isn't working correctly label Jun 18, 2021
@cdaringe
Copy link
Contributor

cdaringe commented Oct 3, 2021

I get a rust panic.

thread 'main' panicked at 'byte index 1090 is not a char boundary; it is inside '💣' (bytes 1088..1092) of `export class RadError extends Error {
    static message;
    static code;
    static emoji;
    reason;
}
RadError.code = "ERADERROR";
RadError.emoji = "🚨";
export class RadMissingRadFile extends RadError {
}
RadMissingRadFile.message = "unable to find`[...]', cli/tools/coverage.rs:230:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Seems pretty clear that the coverage checker is doing char mapping expecting byte chars, vs graphemes

@bartlomieju bartlomieju added the testing related to deno test and coverage label Dec 5, 2021
@dsherret dsherret self-assigned this Jan 4, 2022
@bartlomieju
Copy link
Member

I got a panic as well:


============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos x86_64
Version: 1.17.2+1fb5858
Args: ["deno", "coverage", "./cov/", "--lcov", "--exclude=test\\.(ts|js)|wasm\\.js|testdata|node/_tools|node/_module/cjs|node_modules"]

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BadJson(Error("invalid unicode code point", line: 1, column: 39318))', cli/tools/coverage.rs:202:57
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Process completed with exit code 1.

@bartlomieju
Copy link
Member

Reported an upstream issue, waiting for response.

@bartlomieju
Copy link
Member

This should be soon fixed by denoland/deno_ast#88

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 testing related to deno test and coverage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants