Skip to content
This repository was archived by the owner on Jun 27, 2018. It is now read-only.

Commit 668b540

Browse files
committed
Fix tests
1 parent cab190e commit 668b540

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

src/lib.rs

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,12 @@ mod tests {
244244
fn eval() {
245245
drop(env_logger::init());
246246

247-
let (status, out) = exec(ReleaseChannel::Stable,
248-
"/usr/local/bin/evaluate.sh",
249-
Vec::new(),
250-
String::from(r#"fn main() { println!("Hello") }"#)).unwrap();
247+
let cache = Cache::new();
248+
let input = r#"fn main() { println!("Hello") }"#;
249+
let (status, out) = cache.exec(ReleaseChannel::Stable,
250+
"/usr/local/bin/evaluate.sh",
251+
Vec::new(),
252+
input.to_string()).unwrap();
251253
assert!(status.success());
252254
assert_eq!(out, &[0xff, b'H', b'e', b'l', b'l', b'o', b'\n']);
253255
}
@@ -256,12 +258,16 @@ mod tests {
256258
fn timeout() {
257259
drop(env_logger::init());
258260

259-
let (status, out) = exec(ReleaseChannel::Stable,
260-
"/usr/local/bin/evaluate.sh",
261-
Vec::new(),
262-
String::from(r#"fn main() {
263-
std::thread::sleep_ms(10_000);
264-
}"#)).unwrap();
261+
let cache = Cache::new();
262+
let input = r#"
263+
fn main() {
264+
std::thread::sleep_ms(10_000);
265+
}
266+
"#;
267+
let (status, out) = cache.exec(ReleaseChannel::Stable,
268+
"/usr/local/bin/evaluate.sh",
269+
Vec::new(),
270+
input.to_string()).unwrap();
265271
assert!(!status.success());
266272
assert!(String::from_utf8_lossy(&out).contains("timeout triggered"));
267273
}
@@ -270,10 +276,13 @@ mod tests {
270276
fn compile() {
271277
drop(env_logger::init());
272278

273-
let (status, out) = exec(ReleaseChannel::Stable,
274-
"/usr/local/bin/compile.sh",
275-
vec![String::from("--emit=llvm-ir")],
276-
String::from(r#"fn main() { println!("Hello") }"#)).unwrap();
279+
let cache = Cache::new();
280+
let input = r#"fn main() { println!("Hello") }"#;
281+
let (status, out) = cache.exec(ReleaseChannel::Stable,
282+
"/usr/local/bin/compile.sh",
283+
vec![String::from("--emit=llvm-ir")],
284+
input.to_string()).unwrap();
285+
277286
assert!(status.success());
278287
let mut split = out.splitn(2, |b| *b == b'\xff');
279288
let empty: &[u8] = &[];
@@ -286,10 +295,12 @@ mod tests {
286295
fn fmt() {
287296
drop(env_logger::init());
288297

289-
let (status, out) = exec(ReleaseChannel::Stable,
290-
"rustfmt",
291-
Vec::new(),
292-
String::from(r#"fn main() { println!("Hello") }"#)).unwrap();
298+
let cache = Cache::new();
299+
let input = r#"fn main() { println!("Hello") }"#;
300+
let (status, out) = cache.exec(ReleaseChannel::Stable,
301+
"rustfmt",
302+
Vec::new(),
303+
input.to_string()).unwrap();
293304
assert!(status.success());
294305
assert!(String::from_utf8(out).unwrap().contains(r#""Hello""#))
295306
}

0 commit comments

Comments
 (0)