From 72945d9c8eee18aed1550c3f42dc41e6a8a0f029 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 22 Jul 2019 22:37:40 +0300 Subject: Use CLI-generated classes to parse testscript builtin options --- doc/testscript.cli | 89 +- libbuild2/buildfile | 40 +- libbuild2/config/utility.hxx | 2 +- libbuild2/config/utility.txx | 2 +- libbuild2/test/script/builtin-options.cxx | 3759 ++++++++++++++++++++++++++++ libbuild2/test/script/builtin-options.hxx | 1025 ++++++++ libbuild2/test/script/builtin-options.ixx | 326 +++ libbuild2/test/script/builtin.cli | 103 + libbuild2/test/script/builtin.cxx | 601 ++--- libbuild2/test/script/runner.cxx | 57 +- tests/test/script/builtin/cat.testscript | 6 + tests/test/script/builtin/cp.testscript | 6 + tests/test/script/builtin/ln.testscript | 8 +- tests/test/script/builtin/mkdir.testscript | 8 +- tests/test/script/builtin/mv.testscript | 6 + tests/test/script/builtin/rm.testscript | 6 + tests/test/script/builtin/rmdir.testscript | 6 + tests/test/script/builtin/sed.testscript | 10 +- tests/test/script/builtin/sleep.testscript | 6 + tests/test/script/builtin/test.testscript | 58 +- tests/test/script/builtin/touch.testscript | 8 +- tests/test/script/runner/exit.testscript | 2 +- tests/test/script/runner/set.testscript | 18 + 23 files changed, 5727 insertions(+), 425 deletions(-) create mode 100644 libbuild2/test/script/builtin-options.cxx create mode 100644 libbuild2/test/script/builtin-options.hxx create mode 100644 libbuild2/test/script/builtin-options.ixx create mode 100644 libbuild2/test/script/builtin.cli diff --git a/doc/testscript.cli b/doc/testscript.cli index 4433375..8b9509d 100644 --- a/doc/testscript.cli +++ b/doc/testscript.cli @@ -2311,7 +2311,11 @@ if the \i{dst-dir/src-name} filesystem entry already exists. \dl| -\li|\n\c{-p} +\li|\n\c{-R|-r|--recursive} + + Copy directories recursively.| + +\li|\n\c{-p|--preserve} Copy permissions as well as modification and access times.|| @@ -2323,18 +2327,27 @@ registered for cleanup. \h#builtins-diff|\c{diff}| \ -diff [-u] [-U ] +diff [-u|-U ] \ Compare the contents of \i{file1} and \i{file2}. The \c{diff} utility is not a builtin. Instead, the test platform is expected to provide a (reasonably) POSIX-compatible implementation. It should at least -supports the \c{-u} (unified output format) and \c{-U} (unified output format -with \i{num} lines of context) options and recognize the \c{-} file name as +supports the \c{-u} and \c{-U} options and recognize the \c{-} file name as an instruction to read from \c{stdin}. On Windows, GNU \c{diff} can be assumed (provided as part of the \c{build2} toolchain). +\dl| + +\li|\n\c{-u} + + Produce output in the unified format.| + +\li|\n\c{-U } + + Produce output in the unified output format with \i{num} lines of context.|| + \h#builtins-echo|\c{echo}| @@ -2408,6 +2421,13 @@ creation is not supported. If hard link creation is not supported either, then \c{ln} falls back to copying the content, recursively in case of a directory target. +\dl| + +\li|\n\c{-s|--symbolic} + + Create symbolic links. Note that creation of hard links is currently not + supported, so this option is always required.|| + Unless the \c{--no-cleanup} option is specified, created filesystem entries that are inside the script working directory are automatically registered for cleanup. @@ -2424,7 +2444,7 @@ directories must exist and the directory itself must not exist. \dl| -\li|\n\c{-p} +\li|\n\c{-p|--parents} Create missing leading directories and ignore directories that already exist.|| @@ -2462,7 +2482,7 @@ Where \i{src-name} is the last path component in \i{src-path}. \dl| -\li|\n\c{-f} +\li|\n\c{-f|--force} Do not fail if a source path is outside the script working directory.|| @@ -2495,11 +2515,11 @@ is specified. \dl| -\li|\n\c{-r} +\li|\n\c{-r|--recursive} Remove directories and their contents recursively.| -\li|\n\c{-f} +\li|\n\c{-f|--force} Do not fail if no path is specified, the path does not exist, or is outside the script working directory.|| @@ -2522,7 +2542,7 @@ working directory unless the \c{-f} option is specified. \dl| -\li|\n\c{-f} +\li|\n\c{-f|--force} Do not fail if no directory is specified, the directory does not exist, or is outside the script working directory.|| @@ -2546,16 +2566,16 @@ is ECMAScript (more specifically, ECMA-262-based C++11 regular expressions). \dl| -\li|\n\c{-n} +\li|\n\c{-n|--quiet} Suppress automatic printing of the pattern space at the end of the script execution.| -\li|\n\c{-i} +\li|\n\c{-i|--in-place} Edit \i{file} in place.| -\li|\n\c{-e