From b9308a5296fc0dc8da78cd6f02a5af9c38f0a044 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Wed, 6 Jul 2016 07:22:16 -0400 Subject: refactor parse_cmdline into something more readable This refactors parse_cmdline into a few chunks of code, mainly to separate the work of parsing from the handling of the actual parsed parameters. By default, parse_cmdline_item is used as the callback for handling the parameters, but this could be overriden by other code sourcing init_functions if desirable. Our test harness passes more tests, but we leave behind some expected failures to describe the cases where it still fails. Fortunately I've not yet been able to find any cases which warrant --expect-parse-fail. --- test/test_parse_cmdline | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/test_parse_cmdline') diff --git a/test/test_parse_cmdline b/test/test_parse_cmdline index 9afd9cb..ff855e4 100755 --- a/test/test_parse_cmdline +++ b/test/test_parse_cmdline @@ -130,19 +130,19 @@ test_parse 'foo="bar baz"' \ 'foo' 'bar baz' # single quoting -test_parse --expect-fail "foo='bar'" \ +test_parse "foo='bar'" \ 'foo' 'bar' -test_parse --expect-parse-fail "foo='bar baz'" \ +test_parse "foo='bar baz'" \ 'foo' 'bar baz' # dangling quotes -test_parse --expect-fail 'foo="bar' \ +test_parse 'foo="bar' \ 'foo' '"bar' test_parse 'foo=bar"' \ 'foo' 'bar"' # nested quotes -test_parse --expect-parse-fail "foo='\"bar baz\"' herp='\"de\"rp'" \ +test_parse "foo='\"bar baz\"' herp='\"de\"rp'" \ 'foo' '"bar baz"' \ 'herp' '"de"rp' @@ -174,9 +174,9 @@ test_parse 'foo="bar #baz" parse=this' \ # shell metachars test_parse 'foo=*' \ 'foo' '\*' -test_parse --expect-fail 'Make*' \ +test_parse 'Make*' \ 'Makefile' '' -test_parse --expect-fail '[Makefile]*' \ +test_parse '[Makefile]*' \ 'Makefile' '' \ 'init' '' \ 'functions' '' @@ -184,7 +184,7 @@ test_parse --expect-fail '[Makefile]*' \ # invalid names test_parse 'in-valid=name' test_parse '6foo=bar' -test_parse --expect-parse-fail '"gar bage"' \ +test_parse '"gar bage"' \ 'gar' '' \ 'bage' '' @@ -197,7 +197,7 @@ test_parse 'ro' \ 'ro' '' \ 'rw' '' \ 'rwopt' 'ro' -test_parse --expect-fail 'fstype=btrfs' \ +test_parse 'fstype=btrfs' \ 'rootfstype' 'btrfs' test_parse 'fsck.mode=force' \ 'forcefsck' 'y' \ -- cgit v1.2.3-24-g4f1b