Skip to content

Handle ENOENT #10863

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

Merged
merged 1 commit into from
Dec 17, 2013
Merged

Handle ENOENT #10863

merged 1 commit into from
Dec 17, 2013

Conversation

cadencemarseille
Copy link
Contributor

Translate ENOENT to IoErrorKind::FileNotFound.

@alexcrichton
Copy link
Member

Can you add a test for this as well?

@cadencemarseille
Copy link
Contributor Author

Hi @alexcrichton,

I added a test that I have been trying to get working, but it always fails for some reason, even when I comment out the two asserts. Do you know why the test is not working? I'm confused because if I change line 71 of rust-pcre's package script and mistype "rust-pcre", then the io_error condition is raised and the IoErrorKind is FileNotFound (using rustc with this patch).

Every time I run make check-stage1-std NO_REBUILD=1 NO_BENCH=1 VERBOSE=1 it eventually fails with:

failures:
    run::tests::test_process_output_io_error_file_not_found
test result: FAILED. 1316 passed; 1 failed; 92 ignored; 0 measured
task '' failed at 'Some tests failed', /Users/cadencemarseille/Projects/rust/src/libextra/test.rs:168

@alexcrichton
Copy link
Member

I suppose that this depends on the test case that you're trying here. I would recommend having a simpler test case which doesn't involve spawning processes. Otherwise there's a very large amount of unknown (to me) code in play so it's tough for me to understand what's going on here.

@cadencemarseille
Copy link
Contributor Author

I split out the test code into a standalone file and it fails with:

task '' failed at 'called `Option::unwrap()` on a `None` value', /Users/cadencemarseille/Projects/rust/src/libstd/option.rs:135

This looks like Issue #10754 std::run functions fail after io_error.

As far as a simpler test, would a test that checks whether uv_error_to_io_error(ENOENT) returns a FileNotFound-kind IoError work?

@alexcrichton
Copy link
Member

Sorry I didn't mean for this to become a long saga of figuring out how to write a test, I just wanted something in the code to assert that ENOENT showed up. As you found out in the unix tests, one of them gives ENOENT and that's good enough for me.

There are many ways to trigger an ENOENT without spawning a process, so if that's blocking you have you tried doing things like listing a directory that doesn't exist or reading a file that doesn't exist?

@alexcrichton
Copy link
Member

We really frequently get different errors on windows, so for now it's fine to just have a different assertion for windows than you have for unix, e.g. assert_eq!(err, if cfg!(windows) { OtherIoError } else { FileNotFound})

Translate ENOENT to IoErrorKind::FileNotFound.
bors added a commit that referenced this pull request Dec 17, 2013
…lexcrichton

Translate ENOENT to IoErrorKind::FileNotFound.
@bors bors closed this Dec 17, 2013
@bors bors merged commit 33ca3e3 into rust-lang:master Dec 17, 2013
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

Successfully merging this pull request may close these issues.

3 participants