diff options
Diffstat (limited to 'tests/manifest')
-rw-r--r-- | tests/manifest/buildfile | 6 | ||||
-rw-r--r-- | tests/manifest/driver.cxx | 59 | ||||
-rw-r--r-- | tests/manifest/review.testscript | 171 |
3 files changed, 236 insertions, 0 deletions
diff --git a/tests/manifest/buildfile b/tests/manifest/buildfile new file mode 100644 index 0000000..e6f5a85 --- /dev/null +++ b/tests/manifest/buildfile @@ -0,0 +1,6 @@ +# file : tests/manifest/buildfile +# license : MIT; see accompanying LICENSE file + +import libs = lib{brep} + +exe{driver}: {hxx cxx}{*} $libs testscript{*} diff --git a/tests/manifest/driver.cxx b/tests/manifest/driver.cxx new file mode 100644 index 0000000..5c70ea5 --- /dev/null +++ b/tests/manifest/driver.cxx @@ -0,0 +1,59 @@ +// file : tests/manifest/driver.cxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#include <ios> // ios_base::failbit, ios_base::badbit +#include <iostream> + +#include <libbutl/utility.hxx> // operator<<(ostream,exception) +#include <libbutl/manifest-parser.hxx> +#include <libbutl/manifest-serializer.hxx> + +#include <libbrep/review-manifest.hxx> + +#undef NDEBUG +#include <cassert> + +using namespace std; +using namespace butl; +using namespace brep; + +// Usage: argv[0] (-r | -rl) +// +// Read and parse manifest from STDIN and serialize it to STDOUT. The +// following options specify the manifest type. +// +// -r parse review manifest +// -rl parse review manifest list +// +int +main (int argc, char* argv[]) +try +{ + assert (argc == 2); + string opt (argv[1]); + + cin.exceptions (ios_base::failbit | ios_base::badbit); + cout.exceptions (ios_base::failbit | ios_base::badbit); + + manifest_parser p (cin, "stdin"); + manifest_serializer s (cout, "stdout"); + + if (opt == "-r") + review_manifest (p).serialize (s); + else if (opt == "-rl") + review_manifests (p).serialize (s); + else + assert (false); + + return 0; +} +catch (const manifest_parsing& e) +{ + cerr << e << endl; + return 1; +} +catch (const manifest_serialization& e) +{ + cerr << e << endl; + return 1; +} diff --git a/tests/manifest/review.testscript b/tests/manifest/review.testscript new file mode 100644 index 0000000..e3daa66 --- /dev/null +++ b/tests/manifest/review.testscript @@ -0,0 +1,171 @@ +# file : tests/manifest/review.testscript +# license : MIT; see accompanying LICENSE file + +: single-manifest +: +{ + test.options += -r + + : valid + : + : Roundtrip the review manifest. + : + { + $* <<EOF >>EOF + : 1 + reviewed-by: John Doe <john@doe.com> + result-code: pass + result-build: fail + result-doc: unchanged + base-version: 1.0.2+3 + details-url: https://example.com/issues/1 + EOF + } + + : unknown-name + : + { + $* <<EOI 2>"stdin:2:1: error: unknown name 'unknown-name' in review manifest" != 0 + : 1 + unknown-name: John Doe <john@doe.com> + EOI + } + + : redefinition + : + { + : reviewed-by + : + { + $* <<EOI 2>"stdin:3:1: error: reviewer redefinition" != 0 + : 1 + reviewed-by: John Doe <john@doe.com> + reviewed-by: John Doe <john@doe.com> + EOI + } + + : result-code + : + { + $* <<EOI 2>"stdin:3:1: error: code review result redefinition" != 0 + : 1 + result-code: pass + result-code: fail + EOI + } + } + + : invalid + : + { + : reviewed-by-empty + : + { + $* <<EOI 2>"stdin:2:13: error: empty reviewer" != 0 + : 1 + reviewed-by: + EOI + } + + : result-code + : + { + $* <<EOI 2>"stdin:2:14: error: invalid review result 'fails'" != 0 + : 1 + result-code: fails + EOI + } + + : details-url + : + { + $* <<EOI 2>"stdin:2:13: error: empty URL" != 0 + : 1 + details-url: + EOI + } + } + + : mandatory + : + { + : reviewed-by + : + { + $* <<EOI 2>"stdin:2:1: error: no reviewer specified" != 0 + : 1 + EOI + } + + : no-result + : + { + $* <<EOI 2>"stdin:3:1: error: no result specified" != 0 + : 1 + reviewed-by: John Doe <john@doe.com> + EOI + } + + : no-base-version + : + { + $* <<EOI 2>"stdin:4:1: error: no base version specified" != 0 + : 1 + reviewed-by: John Doe <john@doe.com> + result-code: unchanged + EOI + } + + : no-details-url + : + { + $* <<EOI 2>"stdin:4:1: error: no details url specified" != 0 + : 1 + reviewed-by: John Doe <john@doe.com> + result-code: fail + EOI + } + } +} + +: multiple-manifests +: +{ + test.options += -rl + + : valid-manifest-list + : + : Roundtrip the review manifests list. + : + { + $* <<EOF >>EOF + : 1 + reviewed-by: John Doe <john@doe.com> + result-code: pass + : + reviewed-by: John Doe <john@doe.com> + result-build: pass + EOF + } + + : empty-manifest-list + : + : Roundtrip the empty manifests list. + : + { + $* <:'' >:'' + } + + : no-details-url + : + { + $* <<EOI 2>"stdin:7:1: error: no details url specified" != 0 + : 1 + reviewed-by: John Doe <john@doe.com> + result-build: pass + : + reviewed-by: John Doe <john@doe.com> + result-code: fail + EOI + } +} |