Created
September 9, 2019 12:04
-
-
Save jamesmunns/51389a60bea580d0420eff464b45bea4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
james@archx1c6g ➜ write-test git:(master) ✗ cat ./src/main.rs | |
use std::io::Write; | |
fn main() { | |
for _ in 0..10 { | |
writeln!( | |
::std::io::stdout().lock(), | |
"Hello, world!" | |
).unwrap_or_else(|_| { | |
eprintln!("stderr: Hello, stderr!"); | |
}); | |
// This panics | |
// println!("Hello, world!"); | |
::std::thread::sleep_ms(1000); | |
} | |
eprintln!("stderr: Test Over in Rust!"); | |
} | |
james@archx1c6g ➜ write-test git:(master) ✗ cat ./test.sh | |
set -euxo pipefail | |
cargo build | |
./target/debug/write-test | head -n 5 | |
echo "Test Passed!" | |
james@archx1c6g ➜ write-test git:(master) ✗ ./test.sh | |
+ cargo build | |
Compiling write-test v0.1.0 (/tmp/write-test) | |
warning: use of deprecated item 'std::thread::sleep_ms': replaced by `std::thread::sleep` | |
--> src/main.rs:13:9 | |
| | |
13 | ::std::thread::sleep_ms(1000); | |
| ^^^^^^^^^^^^^^^^^^^^^^^ | |
| | |
= note: `#[warn(deprecated)]` on by default | |
Finished dev [unoptimized + debuginfo] target(s) in 0.22s | |
+ ./target/debug/write-test | |
+ head -n 5 | |
Hello, world! | |
Hello, world! | |
Hello, world! | |
Hello, world! | |
Hello, world! | |
stderr: Hello, stderr! | |
stderr: Hello, stderr! | |
stderr: Hello, stderr! | |
stderr: Hello, stderr! | |
stderr: Test Over in Rust! | |
+ echo 'Test Passed!' | |
Test Passed! | |
james@archx1c6g ➜ write-test git:(master) ✗ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment