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

Possibility to replace self-maintained test utility with assert_cli #21

Closed
mssun opened this issue Jul 12, 2018 · 7 comments
Closed

Possibility to replace self-maintained test utility with assert_cli #21

mssun opened this issue Jul 12, 2018 · 7 comments

Comments

@mssun
Copy link
Contributor

mssun commented Jul 12, 2018

Can we replace our self-maintained test utility with assert_cmd? (https://github.com/assert-rs/assert_cmd). Seems that assert_cmd provides most of functions we have, but I'm not sure what is still missing.

@Arcterus
Copy link
Contributor

Does it spawn actual processes? Ours just creates new threads and executes the commands in-process so that code coverage works.

@mssun
Copy link
Contributor Author

mssun commented Jul 12, 2018

Oh,that issue is caused by ptrace-based coverage report tool. Because we are using gcov (compiler instrumentation-based method), I think we can safely spawn processes and get accurate code coverage report. Anyway, let me verify my thought first.

@mssun
Copy link
Contributor Author

mssun commented Jul 12, 2018

It works as expected.

diff --git a/tests/gnu/test_arch.rs b/tests/gnu/test_arch.rs
index e6a4401..7f5863e 100644
--- a/tests/gnu/test_arch.rs
+++ b/tests/gnu/test_arch.rs
@@ -7,13 +7,18 @@
 //

 use util::*;
+extern crate assert_cmd;
+use std::process::Command;
+use self::assert_cmd::prelude::*;

 #[test]
 #[cfg(target_arch = "x86_64")]
 fn test_x86_64() {
-    new_ucmd!()
-        .succeeds()
-        .stdout_only("x86_64\n");
+    Command::main_binary()
+        .unwrap()
+        .args(&["arch"])
+        .assert()
+        .stdout("x86_64\n");
 }

 #[test]

image

@mssun
Copy link
Contributor Author

mssun commented Jul 12, 2018

For the issue I mentioned here: https://github.com/rust-lang-nursery/cli-wg/issues/9#issuecomment-385530575

It can be solve with a rustc wrapper: https://github.com/mesalock-linux/mesabox/blob/master/ci/cov-rustc

In this way, we can add coverage-related flags to both mesabox and tests crate names.

@Arcterus
Copy link
Contributor

I'm not opposed to this change then (assuming assert_cmd has everything we need, which I haven't verified).

@mssun mssun changed the title Possibility to replace self-maintained test utility with assert_cmd Possibility to replace self-maintained test utility with assert_cli Jul 12, 2018
@mssun
Copy link
Contributor Author

mssun commented Jul 12, 2018

Sorry, should be assert_cli. I changed the title accordingly.

Edit: assert_cli is deprecated. We use assert_cmd instead.

I'm working on this in this PR: #24

@mssun
Copy link
Contributor Author

mssun commented Aug 1, 2018

Merged.

@mssun mssun closed this as completed Aug 1, 2018
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