Skip to content

Commit

Permalink
Improve error message for fixture test failures
Browse files Browse the repository at this point in the history
Reviewed By: kassens

Differential Revision: D25873158

fbshipit-source-id: 43a6bcdec0add124f658903c62095a7644139201
  • Loading branch information
Nikhil Handyal authored and facebook-github-bot committed Jan 15, 2021
1 parent ff72e8b commit e5b1155
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions compiler/crates/fixture-tests/src/lib.rs
Expand Up @@ -144,8 +144,15 @@ pub fn test_fixture<T, U, V>(
}

if env::var_os("UPDATE_SNAPSHOTS").is_some() {
File::create("tests/".to_string() + expected_file_name)
.unwrap()
let file_name = format!("tests/{}", expected_file_name);
File::create(&file_name)
.unwrap_or_else(|_| {
panic!(
"Unable to create {}/{}",
env::current_dir().unwrap().to_str().unwrap(),
file_name
)
})
.write_all(actual.as_bytes())
.unwrap();
} else {
Expand Down

0 comments on commit e5b1155

Please sign in to comment.