mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-11 14:30:24 +02:00
tests/style: 80 columns, dammit
This commit is contained in:
@ -49,7 +49,11 @@ impl WorkDir {
|
|||||||
|
|
||||||
/// Try to create a new file with the given name and contents in this
|
/// Try to create a new file with the given name and contents in this
|
||||||
/// directory.
|
/// directory.
|
||||||
pub fn try_create<P: AsRef<Path>>(&self, name: P, contents: &str) -> io::Result<()> {
|
pub fn try_create<P: AsRef<Path>>(
|
||||||
|
&self,
|
||||||
|
name: P,
|
||||||
|
contents: &str,
|
||||||
|
) -> io::Result<()> {
|
||||||
let path = self.dir.join(name);
|
let path = self.dir.join(name);
|
||||||
self.try_create_bytes(path, contents.as_bytes())
|
self.try_create_bytes(path, contents.as_bytes())
|
||||||
}
|
}
|
||||||
@ -70,7 +74,11 @@ impl WorkDir {
|
|||||||
|
|
||||||
/// Try to create a new file with the given name and contents in this
|
/// Try to create a new file with the given name and contents in this
|
||||||
/// directory.
|
/// directory.
|
||||||
fn try_create_bytes<P: AsRef<Path>>(&self, path: P, contents: &[u8]) -> io::Result<()> {
|
fn try_create_bytes<P: AsRef<Path>>(
|
||||||
|
&self,
|
||||||
|
path: P,
|
||||||
|
contents: &[u8],
|
||||||
|
) -> io::Result<()> {
|
||||||
let mut file = File::create(&path)?;
|
let mut file = File::create(&path)?;
|
||||||
file.write_all(contents)?;
|
file.write_all(contents)?;
|
||||||
file.flush()
|
file.flush()
|
||||||
@ -190,7 +198,11 @@ impl WorkDir {
|
|||||||
match stdout.parse() {
|
match stdout.parse() {
|
||||||
Ok(t) => t,
|
Ok(t) => t,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
panic!("could not convert from string: {:?}\n\n{}", err, stdout);
|
panic!(
|
||||||
|
"could not convert from string: {:?}\n\n{}",
|
||||||
|
err,
|
||||||
|
stdout
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,7 +233,10 @@ impl WorkDir {
|
|||||||
write!(stdin, "{}", input)
|
write!(stdin, "{}", input)
|
||||||
});
|
});
|
||||||
|
|
||||||
let output = self.expect_success(cmd, child.wait_with_output().unwrap());
|
let output = self.expect_success(
|
||||||
|
cmd,
|
||||||
|
child.wait_with_output().unwrap(),
|
||||||
|
);
|
||||||
worker.join().unwrap().unwrap();
|
worker.join().unwrap().unwrap();
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
@ -277,8 +292,13 @@ impl WorkDir {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs the given command and asserts that its exit code matches expected exit code.
|
/// Runs the given command and asserts that its exit code matches expected
|
||||||
pub fn assert_exit_code(&self, expected_code: i32, cmd: &mut process::Command) {
|
/// exit code.
|
||||||
|
pub fn assert_exit_code(
|
||||||
|
&self,
|
||||||
|
expected_code: i32,
|
||||||
|
cmd: &mut process::Command,
|
||||||
|
) {
|
||||||
let code = cmd.status().unwrap().code().unwrap();
|
let code = cmd.status().unwrap().code().unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
Reference in New Issue
Block a user