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

Deno.consoleSize(Deno.stdout.rid) doesn't work with deno test --unstable #14543

Closed
ydcjeff opened this issue May 9, 2022 · 12 comments
Closed

Comments

@ydcjeff
Copy link

ydcjeff commented May 9, 2022

Version

Deno 1.21.2

Reproduction

Run the below code with deno run --unstable main.js and it prints with an object with column and row

// main.js
console.log(Deno.consoleSize(Deno.stdout.rid))

Run the below code with deno test --unstable test.js and it throws an error Error: Inappropriate ioctl for device (os error 25)

// test.js
Deno.test('test', () => {
  console.log(Deno.consoleSize(Deno.stdout.rid))
})

I am on Intel based macOS Monterey 12.3.1.

@bartlomieju
Copy link
Member

I'm not sure if there's anything we can do. When running in deno test, Deno.stdout and Deno.stderr are replaced with pipes which are not a TTY.

CC @dsherret any ideas?

@imjamesb
Copy link
Contributor

imjamesb commented May 9, 2022

I'm not sure if there's anything we can do. When running in deno test, Deno.stdout and Deno.stderr are replaced with pipes which are not a TTY.
@bartlomieju

Maybe if #14535 is merged deno test could rely on a PTY, this could most likely be done on the rust-side of Deno.

@ydcjeff
Copy link
Author

ydcjeff commented May 9, 2022

I understand Deno.consoleSize can't be used in CI, but at least I want to run the tests locally.

Deno.stdout and Deno.stderr are replaced with pipes which are not a TTY.

In which minor did this change happen as I am sure the tests are passing locally prior to 1.20?

@bartlomieju
Copy link
Member

It landed in 1.21 in "user output markers" PR

@dsherret
Copy link
Member

@imjamesb how would deno test's stdout/stderr capturing work with a pty?

@bartlomieju maybe we could have a flag to disable capturing output? (maybe --no-capture) Alternatively, people could test with a pty by using #14535 or a "humble object pattern" could be used that returns a dummy value for the console size while testing.

@bartlomieju
Copy link
Member

@bartlomieju maybe we could have a flag to disable capturing output? (maybe --no-capture)

We're not really capturing any output, so I'm not sure it's a good idea.

Alternatively, people could test with a pty by using #14535 or a "humble object pattern" could be used that returns a dummy value for the console size while testing.

I think #14535 should be a preferred solution to this problem.

@imjamesb
Copy link
Contributor

@imjamesb how would deno test's stdout/stderr capturing work with a pty?
@dsherret

I believe that the Deno.std(out,err,in) streams can be replaced to a PTYs interface streams for the deno test environment.

@stale
Copy link

stale bot commented Jul 11, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 11, 2022
@dsherret dsherret removed the stale label Jul 11, 2022
@stale
Copy link

stale bot commented Sep 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 16, 2022
@ydcjeff

This comment was marked as off-topic.

@stale stale bot removed stale labels Sep 16, 2022
@Im-Beast
Copy link

Is there any workaround around this (or preferably progress to make it work)?

@lucacasonato
Copy link
Member

We removed Deno.consoleSize(Deno.stdout.rid) and replaced it with Deno.consoleSize() before stabilizing. This version also works in deno test (tested in latest canary).

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

6 participants