-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
WIP test: improve testing tools #946
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
js/testing/testing.ts
Outdated
try { | ||
await fn(); | ||
console.log("test", name, "...", green_ok()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d like the test name to be displayed before the test is run, so if it crashes there is still evidence of what caused it. Here tha name is printed after “fn()”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this instead first write to stdout instead of console.log (so as to avoid the newline)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried deno.stdout.write(new TextEncoder().encode('message'))
to print the message without newilne, but it didn't print anything...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kt3k That is likely because TTYs are line buffered by default. To do this we probably need call sync(2) or set the TTY in unbuffered mode.
Maybe @piscisaureus remembers how we did this in Node...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon further investigation, we are using tokio-fs's stdout, which writes to std::io::Stdout, which has a flush method (suggesting it is line buffered). If we were issuing a write syscall directly, this wouldn't happen - so my comment about needing to set the TTY into unbuffered mode was wrong.
We should probably expose that flush method as deno.stdout.flush()
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust's stdout is always line buffered:
https://github.com/rust-lang/rust/blob/e1643a8968753226dab7ab3c9fee826f097550f2/src/libstd/io/stdio.rs#L344-L349
We are not so happy with this behavior and likely want an always unbuffered stdout, as in Node. Therefore to support his behavior we will need to refactor the stdout/stderr resources to use a raw file descriptor like this:
use std::os::unix::io::FromRawFd;
let stdout = File::from_raw_fd(1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened an issue for this: #948
@ry Sorry for the duplication. I'll revert that part. |
a1d424d
to
9ace593
Compare
I will submit this again when #948 solved or when other solution available |
This resolves some TODOs in the testing library.
Counts the number of filtered tests.Waiting for #948 to be resolved first.