Skip to content

Commit 7c8f503

Browse files
committed
auto merge of #9141 : alexcrichton/rust/ignore-fileinput, r=catamorphism
These tests are being very flaky on the bots, and the reason is that files are being created and then when attempted to get read they actually don't exist. I'm not entirely sure why this is happening, but I also don't fully trust the std::io implemention using @-boxes to close/flush/write files at the right time. This moves the tests to using std::rt::io which is hopefully more robust and something that we can actually reason about. Sadly, due to #8810, these tests fail on windows, so they're all ignored on windows right now.
2 parents fd39bd1 + 68a9137 commit 7c8f503

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/libextra/fileinput.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -417,20 +417,23 @@ mod test {
417417

418418
use super::{FileInput, make_path_option_vec, input_vec, input_vec_state};
419419

420-
use std::io;
420+
use std::rt::io;
421+
use std::rt::io::Writer;
422+
use std::rt::io::file;
421423
use std::uint;
422424
use std::vec;
423425

424426
fn make_file(path : &Path, contents: &[~str]) {
425-
let file = io::file_writer(path, [io::Create, io::Truncate]).unwrap();
427+
let mut file = file::open(path, io::CreateOrTruncate, io::Write).unwrap();
426428

427429
for str in contents.iter() {
428-
file.write_str(*str);
429-
file.write_char('\n');
430+
file.write(str.as_bytes());
431+
file.write(['\n' as u8]);
430432
}
431433
}
432434

433435
#[test]
436+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
434437
fn test_make_path_option_vec() {
435438
let strs = [~"some/path",
436439
~"some/other/path"];
@@ -445,6 +448,7 @@ mod test {
445448
}
446449
447450
#[test]
451+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
448452
fn test_fileinput_read_byte() {
449453
let filenames = make_path_option_vec(vec::from_fn(
450454
3,
@@ -475,6 +479,7 @@ mod test {
475479
}
476480
477481
#[test]
482+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
478483
fn test_fileinput_read() {
479484
let filenames = make_path_option_vec(vec::from_fn(
480485
3,
@@ -495,6 +500,7 @@ mod test {
495500
}
496501

497502
#[test]
503+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
498504
fn test_input_vec() {
499505
let mut all_lines = ~[];
500506
let filenames = make_path_option_vec(vec::from_fn(
@@ -518,6 +524,7 @@ mod test {
518524
}
519525

520526
#[test]
527+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
521528
fn test_input_vec_state() {
522529
let filenames = make_path_option_vec(vec::from_fn(
523530
3,
@@ -540,6 +547,7 @@ mod test {
540547
}
541548

542549
#[test]
550+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
543551
fn test_empty_files() {
544552
let filenames = make_path_option_vec(vec::from_fn(
545553
3,
@@ -564,18 +572,21 @@ mod test {
564572
}
565573
566574
#[test]
575+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
567576
fn test_no_trailing_newline() {
568577
let f1 =
569578
Some(Path("tmp/lib-fileinput-test-no-trailing-newline-1.tmp"));
570579
let f2 =
571580
Some(Path("tmp/lib-fileinput-test-no-trailing-newline-2.tmp"));
572581
573-
let wr = io::file_writer(f1.get_ref(),
574-
[io::Create, io::Truncate]).unwrap();
575-
wr.write_str("1\n2");
576-
let wr = io::file_writer(f2.get_ref(),
577-
[io::Create, io::Truncate]).unwrap();
578-
wr.write_str("3\n4");
582+
{
583+
let mut wr = file::open(f1.get_ref(), io::CreateOrTruncate,
584+
io::Write).unwrap();
585+
wr.write("1\n2".as_bytes());
586+
let mut wr = file::open(f2.get_ref(), io::CreateOrTruncate,
587+
io::Write).unwrap();
588+
wr.write("3\n4".as_bytes());
589+
}
579590
580591
let mut lines = ~[];
581592
do input_vec(~[f1, f2]) |line| {
@@ -587,6 +598,7 @@ mod test {
587598
588599
589600
#[test]
601+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
590602
fn test_next_file() {
591603
let filenames = make_path_option_vec(vec::from_fn(
592604
3,
@@ -618,6 +630,7 @@ mod test {
618630
619631
#[test]
620632
#[should_fail]
633+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
621634
fn test_input_vec_missing_file() {
622635
do input_vec(make_path_option_vec([~"this/file/doesnt/exist"], true)) |line| {
623636
println(line);

0 commit comments

Comments
 (0)