Skip to content

How to test I/O errors #575

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

Open
brson opened this issue Jul 12, 2016 · 2 comments
Open

How to test I/O errors #575

brson opened this issue Jul 12, 2016 · 2 comments

Comments

@brson
Copy link
Contributor

brson commented Jul 12, 2016

I just posted a fix for a file system error that I can't test for. rustup error handling is important but hard to test. In this case I would want to trigger out-of-disk during an installation. I'd prefer to be able to test this stuff.

I see two options:

  • Write a fuse filesystem to create the errors. Requires a lot of work, only works for file system access, not network.
  • Add mocking to the rustup-utils I/O functions, so that the test runner can e.g. set environment variables telling the I/O layer to generate specific errors. Downside is that it's ugly and isn't exercising big parts of the I/O stack.

I'm inclined toward the latter. @alexcrichton do you have opinions?

@brson
Copy link
Contributor Author

brson commented Jul 12, 2016

As a pipe dream: wouldn't it be awesome if I could inject behavior into std's I/O stack? With std-aware cargo I can foresee replacing the I/O crate with an I/O crate that can introduce mock behavior.

@alexcrichton
Copy link
Member

We may only need great coverage here on at least one platform, so I wonder if we could use linux containers in one way or another here? I think that would allow us to basically intercept all system calls and set custom quotas for things. The tests might be brittle over time but perhaps that's not so bad?

I agree that of those two options the latter is better, but I wouldn't be too thrilled about a mocking framework there :(

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

2 participants