From 615278f3365087e436ee5ea13e0d15bd60718038 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Tue, 10 Oct 2023 23:30:18 -0500 Subject: hscript: Allow multiple inheritance This allows a HorizonScript to inherit from multiple files. Files are parsed in a system-defined, unspecified order, but all scripts of a given depth are guaranteed to be parsed before the next depth. --- tests/spec/simulator_spec.rb | 7 +++++++ tests/spec/validator_spec.rb | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'tests/spec') diff --git a/tests/spec/simulator_spec.rb b/tests/spec/simulator_spec.rb index 6c2d095..8ccf98e 100644 --- a/tests/spec/simulator_spec.rb +++ b/tests/spec/simulator_spec.rb @@ -448,4 +448,11 @@ mtu 9001 expect(last_command_started.stdout).to include("cp /usr/share/user-manager/avatars/circles/Cat.png /target/var/lib/AccountsService/icons/awilfox") end end + context "simulating inheritance" do + it "overrides keys correctly when multiple values are specified" do + use_fixture '0238-inherit-override.installfile' + run_simulate + expect(last_command_started.stdout).to include("hostname overridden.hostname.local") + end + end end diff --git a/tests/spec/validator_spec.rb b/tests/spec/validator_spec.rb index 282d7ca..3a491a0 100644 --- a/tests/spec/validator_spec.rb +++ b/tests/spec/validator_spec.rb @@ -80,6 +80,35 @@ RSpec.describe 'HorizonScript validation', :type => :aruba do run_validate expect(last_command_started).to have_output(/error: .*length/) end + context "inheritance" do + it "supports basic single inheritance" do + use_fixture '0232-inherit-basic.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "requires inherited files to exist" do + use_fixture '0233-inherit-missing.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*non-existent/) + end + it "doesn't get stuck in a loop" do + use_fixture '0264-inherit-test-loop.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*already inherited/) + end + it "supports relative paths" do + use_fixture '0236-inherit-relative.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "still knows incomplete files are incomplete" do + use_fixture '0237-inherit-incomplete.installfile' + run_validate + expect(last_command_started).to have_output(/error: expected/) + end + end context "required keys" do # Runner.Validate.Required. # Runner.Validate.network. -- cgit v1.2.3-70-g09d2