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

Don't panic while panicking in CLI's tests #641

Merged
merged 1 commit into from
Feb 8, 2017

Conversation

sgrif
Copy link
Member

@sgrif sgrif commented Feb 8, 2017

Diesel CLI's tests will abort with no output if the tests for diesel database create fail to drop the database. (This is actually failing
for many people because the code to drop it has diverged from CLI's
behavior, which will be fixed separately).

This change ensures that none of the Drop impls in our test suite will
abort the process.

Diesel CLI's tests will abort with no output if the tests for `diesel
database create` fail to drop the database. (This is actually failing
for many people because the code to drop it has diverged from CLI's
behavior, which will be fixed separately).

This change ensures that none of the `Drop` impls in our test suite will
abort the process.
@sgrif sgrif requested a review from killercup February 8, 2017 12:34
@sgrif
Copy link
Member Author

sgrif commented Feb 8, 2017

Thanks @dnagir for making me aware of this issue.

Copy link
Member

@killercup killercup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Ok(x) => x,
Err(e) => {
use ::std::io::{Write, stderr};
if ::std::thread::panicking() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR, don't compile these tests with panic=abort.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since tests fail by panicking, that would be bad in any project (I'll bet cargo test sets panic=unwind even if the project is configured with panic=abort)

} else {
Err(self)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen a few lines like these in the last few days. Maybe it is time to add the glorious boolinator as a dependency?

conn.silence_notices(|| {
conn.execute(&format!("DROP DATABASE IF EXISTS {}", database)).unwrap();
try_drop!(conn.execute(&format!("DROP DATABASE IF EXISTS {}", database)), "Couldn't drop database");
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memo to self: Open clippy issue for denying unwrap (and other panic-able fns) in drop

@killercup
Copy link
Member

Travis fails in information_schema::tests::load_table_names_loads_from_custom_schema because the tables are not in the expected order.

@sgrif
Copy link
Member Author

sgrif commented Feb 8, 2017

Rerunning. Will make it deterministic in a separate PR.

@sgrif sgrif merged commit c0037b1 into master Feb 8, 2017
@sgrif sgrif deleted the sg-dont-panic-in-cli-drop branch February 8, 2017 14:25
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.

2 participants