diff options
-rw-r--r-- | tests/spec/simulator.rb | 8 | ||||
-rw-r--r-- | tests/spec/validator.rb | 4 | ||||
-rw-r--r-- | tools/hscript-simulate/simulator.cc | 14 |
3 files changed, 20 insertions, 6 deletions
diff --git a/tests/spec/simulator.rb b/tests/spec/simulator.rb index 7919647..25d48f3 100644 --- a/tests/spec/simulator.rb +++ b/tests/spec/simulator.rb @@ -16,6 +16,14 @@ RSpec.describe 'HorizonScript Simulator', :type => :aruba do run_command 'hscript-simulate' expect(last_command_started).to have_output(/usage/) end + it "supports Strict Mode" do + run_command 'hscript-simulate foo -s' + expect(last_command_started).to_not have_output(/usage/) + end + it "doesn't output ANSI colours when instructed not to" do + run_command 'hscript-simulate foo -n' + expect(last_command_started).to_not have_output(/\033/) + end it "doesn't output ANSI colours when redirected" do run_command 'hscript-simulate foo 2>/dev/null' expect(last_command_started).to_not have_output(/\033/) diff --git a/tests/spec/validator.rb b/tests/spec/validator.rb index 11fd4c4..7dfe752 100644 --- a/tests/spec/validator.rb +++ b/tests/spec/validator.rb @@ -19,6 +19,10 @@ RSpec.describe 'HorizonScript Validation Utility', :type => :aruba do run_command 'hscript-validate' expect(last_command_started).to have_output(/usage/) end + it "doesn't output ANSI colours when instructed not to" do + run_command 'hscript-validate foo -n' + expect(last_command_started).to_not have_output(/\033/) + end it "doesn't output ANSI colours when redirected" do run_command 'hscript-validate foo 2>/dev/null' expect(last_command_started).to_not have_output(/\033/) diff --git a/tools/hscript-simulate/simulator.cc b/tools/hscript-simulate/simulator.cc index 95bdde6..e26735e 100644 --- a/tools/hscript-simulate/simulator.cc +++ b/tools/hscript-simulate/simulator.cc @@ -45,15 +45,17 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } + if(!isatty(1)) { + std::cout << "#!/bin/sh" << std::endl << std::endl; + } + bold_if_pretty(std::cout); + if(!isatty(1)) std::cout << "# Generated by "; + std::cout << "HorizonScript Simulation Utility version 0.1.0"; + reset_if_pretty(std::cout); + std::cout << std::endl; if(isatty(1)) { - bold_if_pretty(std::cout); - std::cout << "HorizonScript Simulation Utility version 0.1.0"; - reset_if_pretty(std::cout); - std::cout << std::endl; std::cout << "Copyright (c) 2019 Adélie Linux and contributors. AGPL-3.0 license." << std::endl; std::cout << std::endl; - } else { - std::cout << "#!/bin/sh" << std::endl << std::endl; } my_script = Horizon::Script::load(installfile, opts); |