diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-01-15 00:04:16 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-01-24 00:10:15 +0300 |
commit | 22fe6dd12a36fd8369966a9b042eb53dfa85c1eb (patch) | |
tree | 7bcaabc74fa479a158ae935f5865dda6a2722cde /tests/manifest | |
parent | c8128e524255d15ae2c3fc80a89b7c05362427d9 (diff) |
Move manifest parsing/serializing tests to testscript
Diffstat (limited to 'tests/manifest')
-rw-r--r-- | tests/manifest/.gitignore | 3 | ||||
-rw-r--r-- | tests/manifest/buildfile | 25 | ||||
-rw-r--r-- | tests/manifest/driver.cxx | 63 | ||||
-rw-r--r-- | tests/manifest/packages | 51 | ||||
-rw-r--r-- | tests/manifest/repositories | 44 | ||||
-rw-r--r-- | tests/manifest/signature | 13 | ||||
-rw-r--r-- | tests/manifest/testscript | 144 |
7 files changed, 178 insertions, 165 deletions
diff --git a/tests/manifest/.gitignore b/tests/manifest/.gitignore deleted file mode 100644 index d9c2bbc..0000000 --- a/tests/manifest/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -pdriver -rdriver -sdriver diff --git a/tests/manifest/buildfile b/tests/manifest/buildfile index d3c55f8..c35024c 100644 --- a/tests/manifest/buildfile +++ b/tests/manifest/buildfile @@ -2,31 +2,8 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -#exe{driver}: cxx{driver} ../../bpkg/lib{bpkg} -#exe{driver}: test.roundtrip = manifest - -# @@ Hack until build2 supports multiple tests. Also remove .gitignore. -# -./: exe{pdriver} exe{rdriver} exe{sdriver} - -exe{pdriver}: obj{pdriver} -exe{pdriver}: test.roundtrip = packages - -exe{rdriver}: obj{rdriver} -exe{rdriver}: test.roundtrip = repositories - -exe{sdriver}: obj{sdriver} -exe{sdriver}: test.roundtrip = signature - -obj{pdriver rdriver sdriver}: cxx{driver} - import libs += libbutl%lib{butl} -exe{pdriver rdriver sdriver} obj{pdriver rdriver sdriver}: \ - ../../bpkg/lib{bpkg} $libs - -obj{pdriver}: cxx.poptions += -DTEST_PACKAGES -obj{rdriver}: cxx.poptions += -DTEST_REPOSITORIES -obj{sdriver}: cxx.poptions += -DTEST_SIGNATURE +exe{driver}: cxx{driver} ../../bpkg/lib{bpkg} $libs test{testscript} include ../../bpkg/ diff --git a/tests/manifest/driver.cxx b/tests/manifest/driver.cxx index 380bd04..8f3ffef 100644 --- a/tests/manifest/driver.cxx +++ b/tests/manifest/driver.cxx @@ -2,11 +2,11 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file +#include <ios> // ios_base::failbit, ios_base::badbit +#include <string> #include <cassert> #include <iostream> -#include <butl/utility> // operator<<(ostream, exception) -#include <butl/fdstream> #include <butl/manifest-parser> #include <butl/manifest-serializer> @@ -19,32 +19,35 @@ using namespace bpkg; int main (int argc, char* argv[]) { - if (argc != 2) - { - cerr << "usage: " << argv[0] << " <file>" << endl; - return 1; - } - - try - { - ifdstream ifs (argv[1]); - manifest_parser p (ifs, argv[1]); - -#ifdef TEST_PACKAGES - package_manifests ms (p); -#elif TEST_REPOSITORIES - repository_manifests ms (p); -#else - signature_manifest ms (p); -#endif - - stdout_fdmode (fdstream_mode::binary); // Write in binary mode. - manifest_serializer s (cout, "stdout"); - ms.serialize (s); - } - catch (const exception& e) - { - cerr << e << endl; - return 1; - } + // Usage: driver (-p|-r|-s) + // + // Read and parse manifest from STDIN and serialize it to STDOUT. The + // following options specify the manifest type. + // + // -p + // Parse package manifest list. + // + // -r + // Parse repository manifest list. + // + // -s + // Parse signature manifest. + // + 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 == "-p") + package_manifests (p).serialize (s); + else if (opt == "-r") + repository_manifests (p).serialize (s); + else if (opt == "-s") + signature_manifest (p).serialize (s); + else + assert (false); } diff --git a/tests/manifest/packages b/tests/manifest/packages deleted file mode 100644 index 7c076ea..0000000 --- a/tests/manifest/packages +++ /dev/null @@ -1,51 +0,0 @@ -: 1 -sha256sum: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 -: -name: libfoo -version: 1.2.3+2 -priority: high; Due to critical bug fix. -summary: Modern XML parser -license: LGPLv2, MIT; Both required. -license: BSD -tags: c++, xml, parser, serializer, pull, streaming, modern -description: libfoo is a very modern C++ XML parser. -changes: 1.2.3+2: applied upstream patch for critical bug bar -changes: 1.2.3+1: applied upstream patch for critical bug foo -url: http://www.example.org/projects/libfoo/; libfoo project page url -package-url: http://www.example.org/projects/libbar/1.2.3+2; package url -email: libfoo-users@example.org; Public mailing list, posts by non-members\ - are allowed but moderated. -package-email: libfoo-1.2.3+2@example.org; Bug reports are welcome. -depends: libz -depends: libgnutls <= 1.2.3 | libopenssl >= 2.3.4 -depends: ? libboost-regex >= 1.52.0; Only if C++ compiler doesn't support\ - C++11 <regex>. -depends: ? libqtcore >= 5.0.0; Only if GUI is enabled. -requires: linux | windows | macosx; symbian is coming. -requires: c++11 -requires: ? ; VC++ 12.0 or later if targeting Windows. -requires: ? ; libc++ standard library if using Clang on Mac OS X. -requires: zlib; Most Linux/UNIX systems already have one; or get it at\ - www.zlib.net. -location: libfoo-1.2.3+2.tar.bz2 -sha256sum: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 -: -name: libbar -version: 3.4A.5+6 -summary: Modern bar management framework -license: LGPLv2 -tags: c++, xml, modern -url: http://www.example.org/projects/libbar/ -email: libbar-users@example.org -depends: libbaz (1- 2-) | libbaz [3 4-) | libbaz (5 6] | libbaz [7 8] -location: bar/libbar-3.4A.5+6.tbz -sha256sum: d4b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 -: -name: libbaz -version: 2~3.4A.5+3 -summary: Modern baz system -license: LGPLv2 -url: http://www.example.org/projects/libbar/ -email: libbaz-users@example.org -location: libbaz/libbaz-2~3.4A.5+3.tar.gz -sha256sum: b5b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 diff --git a/tests/manifest/repositories b/tests/manifest/repositories deleted file mode 100644 index 06eb8a0..0000000 --- a/tests/manifest/repositories +++ /dev/null @@ -1,44 +0,0 @@ -: 1 -location: http://pkg.example.org/1/math -role: prerequisite -: -location: ../stable -role: complement -: -url: http://cppget.org -email: repoman@cppget.org; General mailing list. -summary: General C++ package repository -description: This is the awesome C++ package repository full of exciting\ - stuff. -certificate: \ ------BEGIN CERTIFICATE----- -MIIFLzCCAxegAwIBAgIJAJ71rMp8mDy1MA0GCSqGSIb3DQEBCwUAMDMxFzAVBgNV -BAoMDkNvZGUgU3ludGhlc2lzMRgwFgYDVQQDDA9uYW1lOmNwcGdldC5vcmcwHhcN -MTYwNDA4MTc1NTUwWhcNMTcwNDA4MTc1NTUwWjAzMRcwFQYDVQQKDA5Db2RlIFN5 -bnRoZXNpczEYMBYGA1UEAwwPbmFtZTpjcHBnZXQub3JnMIICIjANBgkqhkiG9w0B -AQEFAAOCAg8AMIICCgKCAgEAwj7lwxkr19ygfNIzQsiKkmyyRG0c5AwMrwvldEk7 -2UIwz5kNb04zveUzQcfNFhau60+xC980Y4TKA4/ScfinyaDfp1I3pmiv4OSDUoBw -9e8a+4Jyo5fuiAXoAYaQyAdwvH1mIbYq1ObRfKW2MTrUXp/HRJAWHHBnv3VmCYBZ -dllY1hasA+SBDMBv6iTXkKUIfEdNDk8cjUR3FjxaefIdip9pHR3G0y4iWctS1drq -AKLE1J0KIJyPsJCvoZnzIeePaCNL/UtRup9mYi2vxHHFD4Ml5Bbp+gE6vq5XhcQz -LeCcGYKB3UjVWuszcpFIoHACw9ja2JUumbTiclUDgLBk8WXJvLjOCNLp9i/MKQws -p5CDfrNe2P6u63ZmtW2v0Qpj/6b6JQmqJaMgHQdDEBUFO3bjwm7yyXyvEjj/EAEJ -pGziWZ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vmciuJwhyUkbifLrHU= ------END CERTIFICATE----- -\ diff --git a/tests/manifest/signature b/tests/manifest/signature deleted file mode 100644 index 5a83eeb..0000000 --- a/tests/manifest/signature +++ /dev/null @@ -1,13 +0,0 @@ -: 1 -sha256sum: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 -signature: \ -geWdw7Gm+Rt+CLDMBby5Y796E8rxwImb0bmcZwGWar9D3vkFm9Kjh00Buuo1PuU7tP1dV6yvRbH8 -NzC0IryEoUJHx9909AJ449ET9Zb+C3ykEeBlKH2wonj7cAVK9ZEDpPEGAtp56XWZQEawl50mwq6t -XkZAABxtOswXiicdh3HK7kaPHp38/9CBMc0rva6wDnkbTigUYA2ULqLtP5a5mLovVc48zI9A/hmb -Qx1/Nr7nzTZNDGK7CwTAb1fPam9rZklTfCTPSPUUjvWjM9XdY8cbRE1FrE14TXdyQPxCLzHO2dUO -YWH5/qMikEoCYhYXQ6KhekoT/MUiVC3PMcYQbYOrOtSxq6RcgnymexBe1XIyld5Rfo1eXu8TK11r -QPULIqAGy6RwEUhGznuEiGHQwb1UymNyJ/qgr4vBPjJtlvptqG5XNmtiJ22f07nmeVRi2Vg2UyOw -HoVpy5t/w0tEnUXPA39Vt0v1bUm7Knhc8qL4JFEqK/j/CzEHzEtAjn0aoGuKubCO0WUa+v6ZlkLU -YrNUIdgT1wgj4yEhLO3g+NsnxFH05D2sfR16rrkI2E6st5crAHR8FOl2FDsWxgKqNbzXZw7rl+Fa -TobGycX7MDf2mbBmR/KmEkMBJ4mziWLAycSAGyE5VRYDwHPJlQE0143wBzT8eNw4VLm/r+88VYw= -\ diff --git a/tests/manifest/testscript b/tests/manifest/testscript new file mode 100644 index 0000000..263e5ef --- /dev/null +++ b/tests/manifest/testscript @@ -0,0 +1,144 @@ +# file : tests/manifest/testscript -*- C++ -*- +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: packages +: +: Roundtrip the package manifest list. +: +{ + : manifest + : + $* -p <<EOF >>EOF + : 1 + sha256sum: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + : + name: libfoo + version: 1.2.3+2 + priority: high; Due to critical bug fix. + summary: Modern XML parser + license: LGPLv2, MIT; Both required. + license: BSD + tags: c++, xml, parser, serializer, pull, streaming, modern + description: libfoo is a very modern C++ XML parser. + changes: 1.2.3+2: applied upstream patch for critical bug bar + changes: 1.2.3+1: applied upstream patch for critical bug foo + url: http://www.example.org/projects/libfoo/; libfoo project page url + package-url: http://www.example.org/projects/libbar/1.2.3+2; package url + email: libfoo-users@example.org; Public mailing list, posts by non-members\ + are allowed but moderated. + package-email: libfoo-1.2.3+2@example.org; Bug reports are welcome. + depends: libz + depends: libgnutls <= 1.2.3 | libopenssl >= 2.3.4 + depends: ? libboost-regex >= 1.52.0; Only if C++ compiler does not support\ + C++11 <regex>. + depends: ? libqtcore >= 5.0.0; Only if GUI is enabled. + requires: linux | windows | macosx; symbian is coming. + requires: c++11 + requires: ? ; VC++ 12.0 or later if targeting Windows. + requires: ? ; libc++ standard library if using Clang on Mac OS X. + requires: zlib; Most Linux/UNIX systems already have one; or get it at\ + www.zlib.net. + location: libfoo-1.2.3+2.tar.bz2 + sha256sum: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + : + name: libbar + version: 3.4A.5+6 + summary: Modern bar management framework + license: LGPLv2 + tags: c++, xml, modern + url: http://www.example.org/projects/libbar/ + email: libbar-users@example.org + depends: libbaz (1- 2-) | libbaz [3 4-) | libbaz (5 6] | libbaz [7 8] + location: bar/libbar-3.4A.5+6.tbz + sha256sum: d4b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + : + name: libbaz + version: 2~3.4A.5+3 + summary: Modern baz system + license: LGPLv2 + url: http://www.example.org/projects/libbar/ + email: libbaz-users@example.org + location: libbaz/libbaz-2~3.4A.5+3.tar.gz + sha256sum: b5b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + EOF +} + +: repositories +: +: Roundtrip the repository manifest list. +: +{ + : manifest + : + $* -r <<EOF >>EOF + : 1 + location: http://pkg.example.org/1/math + role: prerequisite + : + location: ../stable + role: complement + : + url: http://cppget.org + email: repoman@cppget.org; General mailing list. + summary: General C++ package repository + description: This is the awesome C++ package repository full of exciting\ + stuff. + certificate: \ + -----BEGIN CERTIFICATE----- + MIIFLzCCAxegAwIBAgIJAJ71rMp8mDy1MA0GCSqGSIb3DQEBCwUAMDMxFzAVBgNV + BAoMDkNvZGUgU3ludGhlc2lzMRgwFgYDVQQDDA9uYW1lOmNwcGdldC5vcmcwHhcN + MTYwNDA4MTc1NTUwWhcNMTcwNDA4MTc1NTUwWjAzMRcwFQYDVQQKDA5Db2RlIFN5 + bnRoZXNpczEYMBYGA1UEAwwPbmFtZTpjcHBnZXQub3JnMIICIjANBgkqhkiG9w0B + AQEFAAOCAg8AMIICCgKCAgEAwj7lwxkr19ygfNIzQsiKkmyyRG0c5AwMrwvldEk7 + 2UIwz5kNb04zveUzQcfNFhau60+xC980Y4TKA4/ScfinyaDfp1I3pmiv4OSDUoBw + 9e8a+4Jyo5fuiAXoAYaQyAdwvH1mIbYq1ObRfKW2MTrUXp/HRJAWHHBnv3VmCYBZ + dllY1hasA+SBDMBv6iTXkKUIfEdNDk8cjUR3FjxaefIdip9pHR3G0y4iWctS1drq + AKLE1J0KIJyPsJCvoZnzIeePaCNL/UtRup9mYi2vxHHFD4Ml5Bbp+gE6vq5XhcQz + LeCcGYKB3UjVWuszcpFIoHACw9ja2JUumbTiclUDgLBk8WXJvLjOCNLp9i/MKQws + p5CDfrNe2P6u63ZmtW2v0Qpj/6b6JQmqJaMgHQdDEBUFO3bjwm7yyXyvEjj/EAEJ + pGziWZjan5NKGgKCX1JChQJloMHhzr42YMvceWTMJjAr07Es9vCsCS2KPvAKY7Mv + yewAyK9ucFRDObZVuaFjU+WUTXB1munwO3Jso56EMxeFvu+W1B+m49XS3k/TlBvF + HGnkiSaMwLEJvgFVgQPpG2gD39WDFqX28pWdLL4hM+hXUfdeH0OdXfq66CLu7P8d + cgkZdHRs5UauxLzm1Qo06aLsm2HXrfDnmsd5ENi7RkiFMx1aLh3/cjZD0uHndQUC + LEcCAwEAAaNGMEQwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQMMAoGCCsGAQUF + BwMDMBoGA1UdEQQTMBGBD2luZm9AY3BwZ2V0Lm9yZzANBgkqhkiG9w0BAQsFAAOC + AgEAHLfv2w82bBMgDgsRX8GU/3eK6CnyfRu4Auto1XjyHCrD6qcIdmebC0hihpSg + 5xSlfVwjPRWBmg3z5/K8ln5jM6KKiWHd47OCfx+DW7wbesq2+6lS1btXpRR2pv7j + zG+41Cncu/xVNs9F4CQluVn5xyWFVDUxQfkQqAE46EbkjAmq42y+1ZQnq2Zm47Wr + iMRXQtg1yx7Fs2EpVU+sbW4ImuXgv0YbyYbI1lPhvmx8rIL6lybN3evEfIj7crh7 + 5abWPDZzA+1aNL5tiaSNrn3nS/BfJyEYhGMyy0bsekPZiaqGB1q/mgv2rmR/2SRL + Tx+T7sthy/IHTOUbDTY0lUhjc6thQMncgGTaD4TC3QaXhdLWzO9XTh0K7U8BOMwh + wppr1G5aTXY0PUB0+Hs+IQZ4mVfBvKO0Wn6GgoDAs/mW9qvbWP3ZnpdvhB52a49P + g07JQ+R0QgBNQY7t0lT0mOpAPx79Dwc5R8jQCkx4gTr1bWtgyCvza+gpTgUQDOH5 + nawOIIDOnRv4heFdvgfEQs2oKa3X4bM+BsgOx7OTvnWCzJy0IXo0uBbcTrMv9Z62 + +KVwnghQdpURRnUpomt03cTwjqVJVrq287owGv8qqnuGcTTi1SgzNNYREFoljY58 + CCj4yYvTUzXjcAUXaNC5YNw3JEQp8vmciuJwhyUkbifLrHU= + -----END CERTIFICATE----- + \ + EOF +} + +: signature +: +: Roundtrip the signature manifest. +: +{ + : manifest + : + $* -s <<EOF >>EOF + : 1 + sha256sum: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + signature: \ + geWdw7Gm+Rt+CLDMBby5Y796E8rxwImb0bmcZwGWar9D3vkFm9Kjh00Buuo1PuU7tP1dV6yvRbH8 + NzC0IryEoUJHx9909AJ449ET9Zb+C3ykEeBlKH2wonj7cAVK9ZEDpPEGAtp56XWZQEawl50mwq6t + XkZAABxtOswXiicdh3HK7kaPHp38/9CBMc0rva6wDnkbTigUYA2ULqLtP5a5mLovVc48zI9A/hmb + Qx1/Nr7nzTZNDGK7CwTAb1fPam9rZklTfCTPSPUUjvWjM9XdY8cbRE1FrE14TXdyQPxCLzHO2dUO + YWH5/qMikEoCYhYXQ6KhekoT/MUiVC3PMcYQbYOrOtSxq6RcgnymexBe1XIyld5Rfo1eXu8TK11r + QPULIqAGy6RwEUhGznuEiGHQwb1UymNyJ/qgr4vBPjJtlvptqG5XNmtiJ22f07nmeVRi2Vg2UyOw + HoVpy5t/w0tEnUXPA39Vt0v1bUm7Knhc8qL4JFEqK/j/CzEHzEtAjn0aoGuKubCO0WUa+v6ZlkLU + YrNUIdgT1wgj4yEhLO3g+NsnxFH05D2sfR16rrkI2E6st5crAHR8FOl2FDsWxgKqNbzXZw7rl+Fa + TobGycX7MDf2mbBmR/KmEkMBJ4mziWLAycSAGyE5VRYDwHPJlQE0143wBzT8eNw4VLm/r+88VYw= + \ + EOF +} |