Move the filetest harness into its own crate.

This allows us to run the tests via a library call rather than just
as a command execution. And, it's a step toward a broader goal, which
is to keep the code in the top-level src directory minimal, with
important functionality exposed as crates.
This commit is contained in:
Dan Gohman
2018-03-15 13:00:29 -07:00
parent 00af7a28f3
commit 965b93bd2a
31 changed files with 161 additions and 163 deletions

View File

@@ -1,34 +0,0 @@
//! Run `cton-util test` on all available testcases.
use std::process::{Command, Output};
use std::env;
use std::path::PathBuf;
use std::io::{self, Write};
/// Returns the target directory, where we can find build artifacts
/// and such for the current configuration.
fn get_target_dir() -> PathBuf {
let mut path = env::current_exe().unwrap();
path.pop(); // chop off exe name
path.pop(); // chop off deps name
path
}
#[test]
fn cton_util_test() {
let mut cmd = Command::new(&get_target_dir().join("cton-util"));
cmd.arg("test");
// We have testcases in the following directories:
cmd.arg("filetests");
cmd.arg("docs");
let Output {
status,
stdout,
stderr,
} = cmd.output().unwrap();
io::stdout().write(&stdout).unwrap();
io::stderr().write(&stderr).unwrap();
assert!(status.success(), "failed with exit status {}", status);
}

View File

@@ -0,0 +1,7 @@
extern crate cton_filetests;
#[test]
fn filetests() {
// Run all the filetests in the following directories.
cton_filetests::run(false, vec!["filetests".into(), "docs".into()]).expect("test harness");
}