Skip to content

Commit 56d5f94

Browse files
committed
Move off of std::old_io and std::old_path.
1 parent 4808d0e commit 56d5f94

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ license = "MPL-2.0"
1414

1515
[dev-dependencies]
1616
rustc-serialize = "0.3"
17+
tempdir = "0.3"
1718

1819

1920
[dependencies]

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![crate_type = "rlib"]
77

88
#![feature(core, collections)]
9-
#![cfg_attr(test, feature(test, old_io, old_path))]
9+
#![cfg_attr(test, feature(test, path, io))]
1010
#![deny(missing_docs)]
1111

1212
/*!
@@ -68,6 +68,7 @@ fn parse_border_spacing(_context: &ParserContext, input: &mut Parser)
6868
extern crate encoding;
6969
extern crate text_writer;
7070
#[macro_use] extern crate matches;
71+
#[cfg(test)] extern crate tempdir;
7172
#[cfg(test)] extern crate test;
7273
#[cfg(test)] extern crate "rustc-serialize" as serialize;
7374

src/tests.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
use std::borrow::Cow::Borrowed;
6-
use std::old_io::{File, Command, Writer, TempDir, IoResult};
7-
use std::old_io as io;
6+
use std::fs::File;
7+
use std::io::{self, Write};
8+
use std::path::Path;
9+
use std::process::Command;
810
use std::num::Float;
911
use std::mem;
1012
use serialize::json::{self, Json, ToJson};
13+
use tempdir::TempDir;
1114
use test;
1215

1316
use encoding::label::encoding_from_whatwg_label;
@@ -26,30 +29,25 @@ macro_rules! JArray {
2629
}
2730

2831

29-
fn write_whole_file(path: &Path, data: &str) -> IoResult<()> {
30-
(try!(File::open_mode(path, io::Open, io::Write))).write_all(data.as_bytes())
32+
fn write_whole_file(path: &Path, data: &str) -> io::Result<()> {
33+
(try!(File::create(path))).write_all(data.as_bytes())
3134
}
3235

3336

34-
fn print_json_diff(results: &Json, expected: &Json) -> IoResult<()> {
35-
use std::old_io::stdio::stdout;
36-
37+
fn print_json_diff(results: &Json, expected: &Json) -> io::Result<()> {
3738
let temp = try!(TempDir::new("rust-cssparser-tests"));
3839
let results = results.pretty().to_string() + "\n";
3940
let expected = expected.pretty().to_string() + "\n";
40-
let mut result_path = temp.path().clone();
41-
result_path.push("results.json");
42-
let mut expected_path = temp.path().clone();
43-
expected_path.push("expected.json");
41+
let result_path = temp.path().join("results.json");
42+
let expected_path = temp.path().join("expected.json");
4443
try!(write_whole_file(&result_path, results.as_slice()));
4544
try!(write_whole_file(&expected_path, expected.as_slice()));
46-
stdout().write_all(try!(Command::new("colordiff")
45+
try!(Command::new("colordiff")
4746
.arg("-u1000")
48-
.arg(result_path.display().to_string())
49-
.arg(expected_path.display().to_string())
50-
.output()
51-
.map_err(|_| io::standard_error(io::OtherIoError))
52-
).output.as_slice())
47+
.arg(&result_path)
48+
.arg(&expected_path)
49+
.status());
50+
Ok(())
5351
}
5452

5553

0 commit comments

Comments
 (0)