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

A few test cases fail if the project directory is located in a deep place #16305

Closed
magurotuna opened this issue Oct 16, 2022 · 3 comments · Fixed by #16482
Closed

A few test cases fail if the project directory is located in a deep place #16305

magurotuna opened this issue Oct 16, 2022 · 3 comments · Fixed by #16482
Labels
good first issue Good for newcomers tests related to tests

Comments

@magurotuna
Copy link
Member

The following two test cases fail if they are located in a deeply nested place.

  • integration::run::queue_microtask_error_handled
  • integration::run::report_error_handled

Output:

OUTPUT
1
{
  cancelable: true,
  message: "Uncaught Error: foo",
  filename: "file:///Users/yusuktan/Repos/github.com/magurotuna/deno/cli/tests/testdata/run/report_error_handled....",
  lineno: 18,
  colno: 13,
  error: Error: foo
    at file:///Users/yusuktan/Repos/github.com/magurotuna/deno/cli/tests/testdata/run/report_error_handled.ts:18:13
}
onerror() called Error: foo
    at file:///Users/yusuktan/Repos/github.com/magurotuna/deno/cli/tests/testdata/run/report_error_handled.ts:18:13
2

OUTPUT
EXPECTED
1
{
  cancelable: true,
  message: "Uncaught Error: foo",
  filename: "[WILDCARD]/report_error_handled.ts",
  lineno: 18,
  colno: 13,
  error: Error: foo
    at [WILDCARD]/report_error_handled.ts:18:13
}
onerror() called Error: foo
    at [WILDCARD]/report_error_handled.ts:18:13
2

EXPECTED

Seems like the "filename" field is different between the expected and actual one. The actual output shows the "omitted" file path (notice that the string ends with the ellipsis), probably because I put the project in a deep place.
This test failure doesn't cause any problem on CI, but it would be even better if we could successfully run it regardless of each individual's setup.

@magurotuna magurotuna added good first issue Good for newcomers tests related to tests labels Oct 16, 2022
@shogohida
Copy link
Contributor

@magurotuna
Hi Tanaka san (I wanted to call you your surname because I'm also Japanese 🙇 ), can I work on this? I'm new to Deno and thought this is a good one for my first issue to contribute.

By the way, I searched a bit but I couldn't see the reason why filepath has ellipsis... It seems the filepath has ellipsis after 101st character in your case. Therefore, I tried to find something related to this rule but I don't know yet.

Please let me know if you have any clue!

@magurotuna
Copy link
Member Author

@shogohida
Hi 👋 Yes, please do!
I haven't delve into it yet, but my guess is that elipsis comes from the implementation of console.log().
Here's one of the test cases that fail.

itest!(queue_microtask_error_handled {
args: "run --quiet run/queue_microtask_error_handled.ts",
output: "run/queue_microtask_error_handled.ts.out",
});

This means that the input for this case is this:

addEventListener("error", (event) => {
console.log({
cancelable: event.cancelable,
message: event.message,
filename: event.filename,
lineno: event.lineno,
colno: event.colno,
error: event.error,
});
event.preventDefault();
});

where we use console.log to print the event information.

The point is that we don't test console.log implementation here, so it's totally fine to use another way to print it. Or you could cut the beginning part of the filename in a heauristic fashion so that it won't get truncated.

@shogohida
Copy link
Contributor

@magurotuna
Thanks for your advice! I noticed filename of event_listener_error_handled and set_timeout_error_handled has slice method after reading your comment.

I made a pull request to add slice to queue_microtask_error_handled and report_error_handled!
#16482

magurotuna pushed a commit that referenced this issue Oct 31, 2022
In order for test cases to pass regardless of each individual's environment,
this commit adds calls to `slice` method when printing the filenames so
we can avoid getting `console.log` to truncate them.

Fixes #16305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers tests related to tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants