use super::*;
pub(super) fn go_binary() -> PathBuf {
crate::proc::find::go().unwrap_or_else(|| PathBuf::from("go"))
}
pub(super) fn go_cmd<S: AsRef<std::ffi::OsStr>>(root: &Path, args: &[S]) -> Command {
let mut cmd = Command::new(go_binary());
cmd.args(["test", "-json"])
.args(args)
.current_dir(root)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
cmd
}
pub(super) fn run_go<S: AsRef<str>>(tx: &EpochTx, root: &Path, args: &[S]) -> Option<bool> {
let modules = crate::testing::gotest::Modules::of(root);
let cmd = go_cmd(root, &modules.expand(args));
run_streaming_shown(tx, cmd, crate::testing::gotest::shown, |line| {
crate::testing::gotest::parse_event(&modules, line)
.into_iter()
.collect()
})
}
pub(super) fn run_codeql(tx: &EpochTx, root: &Path, args: &[String]) -> Option<bool> {
let mut cmd = Command::new(tx.codeql);
cmd.args(args)
.current_dir(root)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let stream = std::cell::RefCell::new(crate::testing::codeqltest::RunStream::new(root));
let report = |o: crate::testing::codeqltest::Outcome| {
if let Some(summary) = o.failure_summary() {
output::push(output::CHANNEL_TESTS, OutputLevel::Error, &summary);
}
o.case()
};
let ok = run_streaming(tx, cmd, |line| {
stream
.borrow_mut()
.feed(line)
.map(report)
.into_iter()
.collect()
});
if let Some(o) = stream.borrow_mut().finish() {
tx.send(TestResponse::Case(report(o)));
}
ok
}
pub(super) fn codeql_markers() -> Vec<String> {
vec![String::from("qlpack.yml"), String::from("codeql-pack.yml")]
}