From f0dd1b84791707fbc3958b13b9d8cc68c2951913 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 7 Jan 2014 16:02:15 +0100 Subject: [PATCH] Die when an unknown target is specified --- novaboot | 6 +++++- tests/novaboot.wv | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/novaboot b/novaboot index e273f9a..361b1e0 100755 --- a/novaboot +++ b/novaboot @@ -152,7 +152,11 @@ my %opt_spec; ); # First process target options -GetOptionsFromString($CFG::targets{$explicit_target || $CFG::default_target}, %opt_spec); +{ + my $t = $explicit_target || $CFG::default_target; + exists $CFG::targets{$t} or die("Unknown target '$t' (valid targets are: ".join(", ", sort keys(%CFG::targets)).")"); + GetOptionsFromString($CFG::targets{$t}, %opt_spec); +} # Then process other command line options - some of them may override # what was specified by the target diff --git a/tests/novaboot.wv b/tests/novaboot.wv index 4d8f2b1..40b9a16 100755 --- a/tests/novaboot.wv +++ b/tests/novaboot.wv @@ -74,6 +74,10 @@ EOF WVPASS ./script --gen-only WVPASS test -f build/file +WVSTART Fail with unknown target +create_dummy +WVFAIL sh -c "./script --gen-only -t non-existing-target" + WVSTART BUILDDIR variable WVPASS mkdir -p build create_script <<'EOF' -- 2.39.2