From aa0b8e7cd9402d63ddb8ebee14198d448fb488c7 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sun, 13 Oct 2019 08:24:54 -0500 Subject: tests: Add simulator tests --- tests/spec/simulator.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/spec/simulator.rb (limited to 'tests') diff --git a/tests/spec/simulator.rb b/tests/spec/simulator.rb new file mode 100644 index 0000000..7919647 --- /dev/null +++ b/tests/spec/simulator.rb @@ -0,0 +1,39 @@ +require 'aruba/rspec' + +IFILE_PATH = 'installfile' + +def run_simulate(extra = '') + run_command 'hscript-simulate ' + IFILE_PATH + extra +end + +def use_fixture(fixture) + copy '%/' + fixture, IFILE_PATH +end + +RSpec.describe 'HorizonScript Simulator', :type => :aruba do + context "argument passing" do + it "requires an installfile to be specified" do + run_command 'hscript-simulate' + expect(last_command_started).to have_output(/usage/) + 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/) + end + it "outputs the hashbang when redirected" do + run_command 'hscript-simulate foo' + expect(last_command_started.stdout).to start_with("#!/bin/sh") + end + end + context "simulating 'mount' flags" do + it "mounts directories in tree order" do + use_fixture '0057-many-mounts.installfile' + run_simulate + expect(last_command_started.stdout).to include(" +mount /dev/sda1 /target/ +mount /dev/gwyn/home /target/home +mount /dev/sda2 /target/usr +mount /dev/gwyn/source /target/usr/src") + end + end +end -- cgit v1.2.3-60-g2f50