From 5bb170316ebad036ee5b8b18dee7ce3d09c72df4 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 27 Apr 2017 19:36:58 +0300 Subject: Add support for standard version earliest pre-release --- tests/standard-version/driver.cxx | 15 +++++++----- tests/standard-version/testscript | 50 +++++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/standard-version/driver.cxx b/tests/standard-version/driver.cxx index d301c8c..e6a21ef 100644 --- a/tests/standard-version/driver.cxx +++ b/tests/standard-version/driver.cxx @@ -17,9 +17,9 @@ using namespace butl; // Create standard version from string, and also test another ctors. // static standard_version -version (const string& s) +version (const string& s, bool allow_earliest = true) { - standard_version r (s); + standard_version r (s, allow_earliest); try { @@ -28,7 +28,8 @@ version (const string& s) r.snapshot () ? r.string_snapshot () : string (), - r.revision); + r.revision, + allow_earliest); assert (r == v); @@ -37,12 +38,13 @@ version (const string& s) standard_version v (r.version, r.snapshot () ? r.string_snapshot () - : string ()); + : string (), + allow_earliest); assert (r == v); if (!r.snapshot ()) { - standard_version v (r.version); + standard_version v (r.version, allow_earliest); assert (r == v); } } @@ -53,7 +55,8 @@ version (const string& s) r.version, r.snapshot_sn, r.snapshot_id, - r.revision); + r.revision, + allow_earliest); assert (r == v); } diff --git a/tests/standard-version/testscript b/tests/standard-version/testscript index 9c80ddb..e5e3248 100644 --- a/tests/standard-version/testscript +++ b/tests/standard-version/testscript @@ -30,6 +30,12 @@ 1.2.3-a.0.456 1.2.3-a.1.456.340c0a26a5ef EOF + + : earliest + : + $* <>EOF + 1.2.3- + EOF } : revision @@ -76,11 +82,7 @@ : $* <'1~0.0.0' 2>'0.0.0 version' == 1 - : a-b-expected1 - : - $* <'1.2.3-' 2>"'a' or 'b' expected in pre-release" == 1 - - : a-b-expected2 + : a-b-expected : $* <'1.2.3-k' 2>"'a' or 'b' expected in pre-release" == 1 @@ -122,6 +124,10 @@ : snapshot-id : $* <'1.2.3-a.0.1.83jdgsf+0' 2>'invalid revision' == 1 + + : earliest-prerelease + : + $* <'1.2.3-+1' 2>"'a' or 'b' expected in pre-release" == 1 } : trailing-junk-after @@ -146,6 +152,7 @@ $* '1.2.3-b.1' >n: beta $* '1.2.3-a.1' >y: final $* '1.2.3-a.0.1' >y: snapshot + $* '1.2.3-' >y: earliest } : beta @@ -157,6 +164,7 @@ $* '1.2.3-a.1' >n: alpha $* '1.2.3-b.1' >y: final $* '1.2.3-b.0.1' >y: snapshot + $* '1.2.3-' >n: earliest } : compare @@ -182,10 +190,16 @@ : { $* '1.2.3-a.1' '1.2.3-a.1' >'0' : equal - $* '1.2.3' '1.2.3-a.1' >'1' : release-gt-prereleas + $* '1.2.3' '1.2.3-a.1' >'1' : release-gt-prerelease $* '1.2.3-a.2' '1.2.3-b.1' >'-1' : a-lt-b $* '1.2.3-a.1' '1.2.3-a.1.2' >'-1' : final-lt-snapshot $* '1.2.3-a.1.2.xy' '1.2.3-a.1.2' >'0' : ignore-snapshot-id + $* '1.2.3' '1.2.3-a.0.1' >'1' : release-gt-snapshot + $* '1.2.3-a.0.1' '1.2.3-a.1' >'-1' : snapshot-lt-final + $* '1.2.3' '1.2.3-' >'1' : release-gt-earliest + $* '1.2.3-a.1' '1.2.3-' >'1' : final-gt-earliest + $* '1.2.3-a.0.1' '1.2.3-' >'1' : snapshot-gt-earliest + $* '1.2.2-b.499.z' '1.2.3-' >'-1' : prev-max-snapshot-lt-earliest } } @@ -202,11 +216,11 @@ $* <>EOE [1.2.3 1.2.4] (1.2.3 1.2.4) - [ 1.2.3 1.2.4 ] + [ 1.2.3- 1.2.4- ] EOI [1.2.3 1.2.4] (1.2.3 1.2.4) - [1.2.3 1.2.4] + [1.2.3- 1.2.4-] EOE : invalid @@ -234,6 +248,10 @@ : open-end : $* <'[1.2.3 1.2.3)' 2>'equal version endpoints not closed' == 1 + + : earliest-prerelease + : + $* <'[1.2.3- 1.2.3-]' 2>'equal version endpoints are earliest' == 1 } } @@ -248,16 +266,20 @@ <= 1.2.3 > 1.2.3 < 1.2.3 - <=1.2.3 - <1.2.3 + >=1.2.3- + <=1.2.3- + >1.2.3- + <1.2.3- EOI == 1.2.3 >= 1.2.3 <= 1.2.3 > 1.2.3 < 1.2.3 - <= 1.2.3 - < 1.2.3 + >= 1.2.3- + <= 1.2.3- + > 1.2.3- + < 1.2.3- EOE : invalid @@ -265,6 +287,10 @@ { $* <'>=' 2>'no version' == 1 : no-version + : eq-earliest + : + $* <'==1.2.3-' 2>"invalid version: 'a' or 'b' expected in pre-release" == 1 + : junk : $* <'>= 1.2.3-a.1.1.ads@' 2>'invalid version: junk after version' == 1 -- cgit v1.1