Skip to content

Commit 41cde56

Browse files
committed
extra: Fix tests with io_error usage
1 parent 209642c commit 41cde56

File tree

9 files changed

+28
-27
lines changed

9 files changed

+28
-27
lines changed

src/libextra/arc.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ mod tests {
637637
fn test_mutex_arc_poison() {
638638
let arc = ~MutexArc::new(1);
639639
let arc2 = ~arc.clone();
640-
task::try(proc() {
640+
let _ = task::try(proc() {
641641
arc2.access(|one| {
642642
assert_eq!(*one, 2);
643643
})
@@ -668,7 +668,7 @@ mod tests {
668668
fn test_mutex_arc_access_in_unwind() {
669669
let arc = MutexArc::new(1i);
670670
let arc2 = arc.clone();
671-
task::try::<()>(proc() {
671+
let _ = task::try::<()>(proc() {
672672
struct Unwinder {
673673
i: MutexArc<int>
674674
}
@@ -687,7 +687,7 @@ mod tests {
687687
fn test_rw_arc_poison_wr() {
688688
let arc = RWArc::new(1);
689689
let arc2 = arc.clone();
690-
task::try(proc() {
690+
let _ = task::try(proc() {
691691
arc2.write(|one| {
692692
assert_eq!(*one, 2);
693693
})
@@ -701,7 +701,7 @@ mod tests {
701701
fn test_rw_arc_poison_ww() {
702702
let arc = RWArc::new(1);
703703
let arc2 = arc.clone();
704-
task::try(proc() {
704+
let _ = task::try(proc() {
705705
arc2.write(|one| {
706706
assert_eq!(*one, 2);
707707
})
@@ -714,7 +714,7 @@ mod tests {
714714
fn test_rw_arc_poison_dw() {
715715
let arc = RWArc::new(1);
716716
let arc2 = arc.clone();
717-
task::try(proc() {
717+
let _ = task::try(proc() {
718718
arc2.write_downgrade(|mut write_mode| {
719719
write_mode.write(|one| {
720720
assert_eq!(*one, 2);
@@ -729,7 +729,7 @@ mod tests {
729729
fn test_rw_arc_no_poison_rr() {
730730
let arc = RWArc::new(1);
731731
let arc2 = arc.clone();
732-
task::try(proc() {
732+
let _ = task::try(proc() {
733733
arc2.read(|one| {
734734
assert_eq!(*one, 2);
735735
})
@@ -742,7 +742,7 @@ mod tests {
742742
fn test_rw_arc_no_poison_rw() {
743743
let arc = RWArc::new(1);
744744
let arc2 = arc.clone();
745-
task::try(proc() {
745+
let _ = task::try(proc() {
746746
arc2.read(|one| {
747747
assert_eq!(*one, 2);
748748
})
@@ -755,7 +755,7 @@ mod tests {
755755
fn test_rw_arc_no_poison_dr() {
756756
let arc = RWArc::new(1);
757757
let arc2 = arc.clone();
758-
task::try(proc() {
758+
let _ = task::try(proc() {
759759
arc2.write_downgrade(|write_mode| {
760760
let read_mode = arc2.downgrade(write_mode);
761761
read_mode.read(|one| {
@@ -800,7 +800,7 @@ mod tests {
800800

801801
// Wait for children to pass their asserts
802802
for r in children.mut_iter() {
803-
r.recv();
803+
let _ = r.recv();
804804
}
805805

806806
// Wait for writer to finish
@@ -814,7 +814,7 @@ mod tests {
814814
fn test_rw_arc_access_in_unwind() {
815815
let arc = RWArc::new(1i);
816816
let arc2 = arc.clone();
817-
task::try::<()>(proc() {
817+
let _ = task::try::<()>(proc() {
818818
struct Unwinder {
819819
i: RWArc<int>
820820
}

src/libextra/base64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ mod test {
359359
ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン";
360360
let b = s.as_bytes().to_base64(STANDARD);
361361
bh.iter(|| {
362-
b.from_base64();
362+
b.from_base64().unwrap();
363363
});
364364
bh.bytes = b.len() as u64;
365365
}

src/libextra/hex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ mod tests {
201201
ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン";
202202
let b = s.as_bytes().to_hex();
203203
bh.iter(|| {
204-
b.from_hex();
204+
b.from_hex().unwrap();
205205
});
206206
bh.bytes = b.len() as u64;
207207
}

src/libextra/stats.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,11 @@ mod tests {
456456

457457
let mut w = io::stdout();
458458
let w = &mut w as &mut io::Writer;
459-
write!(w, "\n");
460-
write_5_number_summary(w, &summ2);
461-
write!(w, "\n");
462-
write_boxplot(w, &summ2, 50);
463-
write!(w, "\n");
459+
(write!(w, "\n")).unwrap();
460+
write_5_number_summary(w, &summ2).unwrap();
461+
(write!(w, "\n")).unwrap();
462+
write_boxplot(w, &summ2, 50).unwrap();
463+
(write!(w, "\n")).unwrap();
464464

465465
assert_eq!(summ.sum, summ2.sum);
466466
assert_eq!(summ.min, summ2.min);
@@ -1003,7 +1003,7 @@ mod tests {
10031003
fn t(s: &Summary, expected: ~str) {
10041004
use std::io::MemWriter;
10051005
let mut m = MemWriter::new();
1006-
write_boxplot(&mut m as &mut io::Writer, s, 30);
1006+
write_boxplot(&mut m as &mut io::Writer, s, 30).unwrap();
10071007
let out = str::from_utf8_owned(m.unwrap()).unwrap();
10081008
assert_eq!(out, expected);
10091009
}

src/libextra/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ mod tests {
959959
fn test_mutex_cond_no_waiter() {
960960
let m = Mutex::new();
961961
let m2 = m.clone();
962-
task::try(proc() {
962+
let _ = task::try(proc() {
963963
m.lock_cond(|_x| { })
964964
});
965965
m2.lock_cond(|cond| {

src/libextra/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ fn should_sort_failures_before_printing_them() {
720720
failures: ~[test_b, test_a]
721721
};
722722

723-
st.write_failures();
723+
st.write_failures().unwrap();
724724
let s = match st.out {
725725
Raw(ref m) => str::from_utf8(m.get_ref()).unwrap(),
726726
Pretty(_) => unreachable!()
@@ -1485,7 +1485,7 @@ mod tests {
14851485
m2.insert_metric("runtime", 1100.0, 2.0);
14861486
m2.insert_metric("throughput", 50.0, 2.0);
14871487
1488-
m1.save(&pth);
1488+
m1.save(&pth).unwrap();
14891489
14901490
// Ask for a ratchet that should fail to advance.
14911491
let (diff1, ok1) = m2.ratchet(&pth, None);

src/libextra/uuid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ mod bench {
821821
pub fn parse_str(bh: &mut BenchHarness) {
822822
let s = "urn:uuid:F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4";
823823
bh.iter(|| {
824-
Uuid::parse_string(s);
824+
Uuid::parse_string(s).unwrap();
825825
})
826826
}
827827
}

src/libextra/workcache.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,13 @@ fn test() {
473473
fn make_path(filename: ~str) -> Path {
474474
let pth = os::self_exe_path().expect("workcache::test failed").with_filename(filename);
475475
if pth.exists() {
476-
fs::unlink(&pth);
476+
fs::unlink(&pth).unwrap();
477477
}
478478
return pth;
479479
}
480480

481481
let pth = make_path(~"foo.c");
482-
File::create(&pth).write(bytes!("int main() { return 0; }"));
482+
File::create(&pth).write(bytes!("int main() { return 0; }")).unwrap();
483483

484484
let db_path = make_path(~"db.json");
485485

@@ -491,7 +491,8 @@ fn test() {
491491
let subcx = cx.clone();
492492
let pth = pth.clone();
493493

494-
let file_content = from_utf8_owned(File::open(&pth).read_to_end()).unwrap();
494+
let contents = File::open(&pth).read_to_end().unwrap();
495+
let file_content = from_utf8_owned(contents).unwrap();
495496

496497
// FIXME (#9639): This needs to handle non-utf8 paths
497498
prep.declare_input("file", pth.as_str().unwrap(), file_content);
@@ -500,7 +501,7 @@ fn test() {
500501
// FIXME (#9639): This needs to handle non-utf8 paths
501502
run::process_status("gcc", [pth.as_str().unwrap().to_owned(),
502503
~"-o",
503-
out.as_str().unwrap().to_owned()]);
504+
out.as_str().unwrap().to_owned()]).unwrap();
504505

505506
let _proof_of_concept = subcx.prep("subfn");
506507
// Could run sub-rules inside here.

src/libterm/terminfo/searcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn test_get_dbpath_for_term() {
106106
#[test]
107107
#[ignore(reason = "see test_get_dbpath_for_term")]
108108
fn test_open() {
109-
open("screen");
109+
open("screen").unwrap();
110110
let t = open("nonexistent terminal that hopefully does not exist");
111111
assert!(t.is_err());
112112
}

0 commit comments

Comments
 (0)