forked from Crockan/MercuryToolbox
chore(release): prepare public source release
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
//! Integration tests for the `sysshape` command.
|
||||
|
||||
use assert_cmd::Command;
|
||||
use predicates::prelude::*;
|
||||
use std::fs;
|
||||
use tempfile::tempdir;
|
||||
|
||||
fn cargo_command() -> Command {
|
||||
Command::cargo_bin("sysshape").expect("binary")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn summarizes_system_as_json() {
|
||||
let mut command = cargo_command();
|
||||
command
|
||||
.args(["--json", "--env", "safe", "--group", "shell"])
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("\"system\""))
|
||||
.stdout(predicate::str::contains("\"architecture\""))
|
||||
.stdout(predicate::str::contains("\"tools\""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detects_only_present_shimmed_tools() {
|
||||
let temp = tempdir().expect("tempdir");
|
||||
let cargo_cmd = temp.path().join("cargo.cmd");
|
||||
let cmake_cmd = temp.path().join("cmake.cmd");
|
||||
fs::write(&cargo_cmd, "@echo off\r\necho cargo 9.9.9\r\n").expect("cargo shim");
|
||||
fs::write(&cmake_cmd, "@echo off\r\necho cmake version 3.99.0\r\n").expect("cmake shim");
|
||||
|
||||
let mut command = cargo_command();
|
||||
command
|
||||
.args(["--json", "--env", "none", "--group", "all"])
|
||||
.env("PATH", temp.path())
|
||||
.env("PATHEXT", ".CMD;.EXE")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("\"name\":\"cargo\""))
|
||||
.stdout(predicate::str::contains("\"version\":\"cargo 9.9.9\""))
|
||||
.stdout(predicate::str::contains("\"name\":\"cmake\""))
|
||||
.stdout(predicate::str::contains(
|
||||
"\"version\":\"cmake version 3.99.0\"",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn help_includes_group_and_env_examples() {
|
||||
let mut command = cargo_command();
|
||||
command
|
||||
.arg("--help")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("--env"))
|
||||
.stdout(predicate::str::contains("--group"))
|
||||
.stdout(predicate::str::contains("sysshape --json"));
|
||||
}
|
||||
Reference in New Issue
Block a user