Skip to content

Commit

Permalink
Switch to is-terminal crate for test due to MSRV
Browse files Browse the repository at this point in the history
  • Loading branch information
cyqsimon committed Dec 19, 2024
1 parent 70b975e commit 8c3fdb2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
9 changes: 9 additions & 0 deletions tests/data/stdin_is_terminal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "stdin_is_terminal"
version = "0.0.0"
edition = "2021"

[workspace]

[dependencies]
is-terminal = "0.4.13"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{
io::{stdin, IsTerminal},
process::exit,
};
use std::{io::stdin, process::exit};

// TODO: switch to `std::io::IsTerminal` when MSRV >= 1.70.0
use is_terminal::IsTerminal;

fn main() {
if stdin().is_terminal() {
Expand Down
23 changes: 17 additions & 6 deletions tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,33 @@ fn setup() -> Shell {
static ONCE: std::sync::Once = std::sync::Once::new();

let sh = Shell::new().unwrap();
let source_files = [
sh.current_dir().join("./tests/data/xecho.rs"),
sh.current_dir().join("./tests/data/stdin_is_terminal.rs"),
];
let single_file_sources = [sh.current_dir().join("./tests/data/xecho.rs")];
let crate_sources = [sh.current_dir().join("./tests/data/stdin_is_terminal/")];
let target_dir = sh.current_dir().join("./target/");

ONCE.call_once(|| {
for src in source_files {
for src in single_file_sources {
cmd!(sh, "rustc {src} --out-dir {target_dir}")
.quiet()
.run()
.unwrap_or_else(|err| panic!("failed to install binaries from mock_bin: {}", err))
}
for src_dir in crate_sources {
sh.change_dir(src_dir);
cmd!(sh, "cargo build -q --target-dir {target_dir}")
.quiet()
.run()
.unwrap_or_else(|err| panic!("failed to build mock crate: {err}"));
}
});

sh.set_var("PATH", target_dir);
let path_env = std::env::join_paths([
&target_dir,
&target_dir.join("debug/"),
&target_dir.join("release/"),
])
.unwrap();
sh.set_var("PATH", path_env);
sh
}

Expand Down

0 comments on commit 8c3fdb2

Please sign in to comment.