From cd40097447ff2400cb420ec973c16dadd26e6cda Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Oct 2016 10:10:08 +0200 Subject: Implement description support in testscript --- unit-tests/test/script/lexer/buildfile | 4 ++-- unit-tests/test/script/lexer/description-line.test | 17 +++++++++++++++++ unit-tests/test/script/lexer/driver.cxx | 22 ++++++++++++---------- unit-tests/test/script/lexer/first-token.test | 5 +++++ unit-tests/test/script/lexer/script-line.test | 19 +++++++++++++++++++ unit-tests/test/script/lexer/second-token.test | 5 +++++ 6 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 unit-tests/test/script/lexer/description-line.test (limited to 'unit-tests/test/script/lexer') diff --git a/unit-tests/test/script/lexer/buildfile b/unit-tests/test/script/lexer/buildfile index 30f6b9f..d9b17e8 100644 --- a/unit-tests/test/script/lexer/buildfile +++ b/unit-tests/test/script/lexer/buildfile @@ -8,7 +8,7 @@ import libs = libbutl%lib{butl} src = token lexer diagnostics utility variable name test/script/{token lexer} exe{driver}: cxx{driver} ../../../../build2/cxx{$src} $libs \ -test{script-line command-line first-token second-token variable-line variable \ - comment} +test{script-line command-line first-token second-token variable-line \ + description-line variable comment} include ../../../../build2/ diff --git a/unit-tests/test/script/lexer/description-line.test b/unit-tests/test/script/lexer/description-line.test new file mode 100644 index 0000000..f0f0c9f --- /dev/null +++ b/unit-tests/test/script/lexer/description-line.test @@ -0,0 +1,17 @@ +test.arguments += description-line + +$* <" foo bar " >>EOO # full +' foo bar ' +EOO + +$* <" " >>EOO # space +' ' +EOO + +$* <"" >>EOO # empty +'' +EOO + +$* <:"foo" 2>>EOE != 0 # eof +stdin:1:4: error: expected newline at the end of description line +EOE diff --git a/unit-tests/test/script/lexer/driver.cxx b/unit-tests/test/script/lexer/driver.cxx index c5beebb..abd32ba 100644 --- a/unit-tests/test/script/lexer/driver.cxx +++ b/unit-tests/test/script/lexer/driver.cxx @@ -29,13 +29,14 @@ namespace build2 assert (argc == 2); string s (argv[1]); - if (s == "script-line") m = lexer_mode::script_line; - else if (s == "first-token") m = lexer_mode::first_token; - else if (s == "second-token") m = lexer_mode::second_token; - else if (s == "variable-line") m = lexer_mode::variable_line; - else if (s == "command-line") m = lexer_mode::command_line; - else if (s == "here-line") m = lexer_mode::here_line; - else if (s == "variable") m = lexer_mode::variable; + if (s == "script-line") m = lexer_mode::script_line; + else if (s == "first-token") m = lexer_mode::first_token; + else if (s == "second-token") m = lexer_mode::second_token; + else if (s == "variable-line") m = lexer_mode::variable_line; + else if (s == "command-line") m = lexer_mode::command_line; + else if (s == "here-line") m = lexer_mode::here_line; + else if (s == "description-line") m = lexer_mode::description_line; + else if (s == "variable") m = lexer_mode::variable; else assert (false); } @@ -45,9 +46,10 @@ namespace build2 // Some modes auto-expire so we need something underneath. // - bool u (m == lexer_mode::first_token || - m == lexer_mode::second_token || - m == lexer_mode::variable_line || + bool u (m == lexer_mode::first_token || + m == lexer_mode::second_token || + m == lexer_mode::variable_line || + m == lexer_mode::description_line || m == lexer_mode::variable); lexer l (cin, path ("stdin"), u ? lexer_mode::script_line : m); diff --git a/unit-tests/test/script/lexer/first-token.test b/unit-tests/test/script/lexer/first-token.test index a433362..456ef6d 100644 --- a/unit-tests/test/script/lexer/first-token.test +++ b/unit-tests/test/script/lexer/first-token.test @@ -7,6 +7,11 @@ $* <";" >>EOO # semi EOO +$* <":" >>EOO # colon +: + +EOO + $* <"{" >>EOO # lcbrace { diff --git a/unit-tests/test/script/lexer/script-line.test b/unit-tests/test/script/lexer/script-line.test index 6c5038a..96eb19c 100644 --- a/unit-tests/test/script/lexer/script-line.test +++ b/unit-tests/test/script/lexer/script-line.test @@ -17,6 +17,25 @@ $* <";" >>EOO # semi-only EOO +$* <"cmd: dsc" >>EOO # colon +'cmd' +: +'dsc' + +EOO + +$* <"cmd :dsc" >>EOO # colon-separated +'cmd' +: +'dsc' + +EOO + +$* <":" >>EOO # colon-only +: + +EOO + $* <"cmd <+ 1>+" >>EOO # pass-redirect 'cmd' <+ diff --git a/unit-tests/test/script/lexer/second-token.test b/unit-tests/test/script/lexer/second-token.test index 058dc65..5238a82 100644 --- a/unit-tests/test/script/lexer/second-token.test +++ b/unit-tests/test/script/lexer/second-token.test @@ -7,6 +7,11 @@ $* <";" >>EOO # semi EOO +$* <":" >>EOO # colon +: + +EOO + $* <"=foo" >>EOO # assign = 'foo' -- cgit v1.1