From dc57b489ea1b8dc4f23713718f0fb828493c85c5 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Sat, 4 Dec 2021 01:03:26 -0800 Subject: [PATCH] progress: Restore tty-detection after refactoring --- integration-tests/apply-local/default.nix | 2 +- integration-tests/apply/test-script.py | 4 ++-- integration-tests/exec/default.nix | 2 +- integration-tests/parallel/default.nix | 4 ++-- src/progress/mod.rs | 4 +++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/integration-tests/apply-local/default.nix b/integration-tests/apply-local/default.nix index b5c9f24..9e8b46b 100644 --- a/integration-tests/apply-local/default.nix +++ b/integration-tests/apply-local/default.nix @@ -6,7 +6,7 @@ in tools.makeTest { bundle = ./.; testScript = '' - deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply-local -v") + deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply-local") deployer.succeed("grep SUCCESS /etc/deployment") ''; } diff --git a/integration-tests/apply/test-script.py b/integration-tests/apply/test-script.py index 3eb85a6..a6c76cf 100644 --- a/integration-tests/apply/test-script.py +++ b/integration-tests/apply/test-script.py @@ -7,7 +7,7 @@ deployer.succeed(f"sed -i 's|@poison@|{poison}|g' /tmp/bundle/hive.nix") targets = [alpha, beta, gamma] logs = deployer.succeed("cd /tmp/bundle &&" \ - f"run-copy-stderr {colmena} apply -v --eval-node-limit 4 --on @target") + f"run-copy-stderr {colmena} apply --eval-node-limit 4 --on @target") with subtest("Check that evaluation messages were logged correctly"): assert "must appear during evaluation" in logs @@ -66,7 +66,7 @@ with subtest("Check that we can correctly deploy to remaining nodes despite fail deployer.succeed("sed -i s/FIRST/SECOND/g /tmp/bundle/hive.nix") deployer.fail("cd /tmp/bundle &&" \ - f"{colmena} apply -v --eval-node-limit 4 --on @target") + f"{colmena} apply --eval-node-limit 4 --on @target") alpha.succeed("grep SECOND /etc/deployment") beta.succeed("grep FIRST /etc/deployment") diff --git a/integration-tests/exec/default.nix b/integration-tests/exec/default.nix index da02238..2ca1f6e 100644 --- a/integration-tests/exec/default.nix +++ b/integration-tests/exec/default.nix @@ -6,7 +6,7 @@ in tools.makeTest { bundle = ./.; testScript = '' - logs = deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} exec -v --on @target -- echo output from '$(hostname)' 2>&1") + logs = deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} exec --on @target -- echo output from '$(hostname)' 2>&1") assert "output from alpha" in logs assert "output from beta" in logs diff --git a/integration-tests/parallel/default.nix b/integration-tests/parallel/default.nix index 6d1b17a..92eb14a 100644 --- a/integration-tests/parallel/default.nix +++ b/integration-tests/parallel/default.nix @@ -7,10 +7,10 @@ in tools.makeTest { testScript = '' deployer.succeed("cd /tmp/bundle &&" \ - "${tools.colmenaExec} apply push -v --eval-node-limit 4 --on @target") + "${tools.colmenaExec} apply push --eval-node-limit 4 --on @target") logs = deployer.succeed("cd /tmp/bundle &&" \ - "run-copy-stderr ${tools.colmenaExec} apply switch -v --eval-node-limit 4 --parallel 4 --on @target") + "run-copy-stderr ${tools.colmenaExec} apply switch --eval-node-limit 4 --parallel 4 --on @target") for node in [alpha, beta, gamma]: node.succeed("grep SUCCESS /etc/deployment") diff --git a/src/progress/mod.rs b/src/progress/mod.rs index 0ca7f52..74f0ae9 100644 --- a/src/progress/mod.rs +++ b/src/progress/mod.rs @@ -93,7 +93,9 @@ pub enum LineStyle { impl SimpleProgressOutput { pub fn new(verbose: bool) -> Self { - if verbose { + let tty = atty::is(atty::Stream::Stdout); + + if verbose || !tty { Self::Plain(PlainOutput::new()) } else { Self::Spinner(SpinnerOutput::new())