aboutsummaryrefslogtreecommitdiff
path: root/tests/standard-version
diff options
context:
space:
mode:
Diffstat (limited to 'tests/standard-version')
-rw-r--r--tests/standard-version/driver.cxx23
-rw-r--r--tests/standard-version/testscript137
2 files changed, 150 insertions, 10 deletions
diff --git a/tests/standard-version/driver.cxx b/tests/standard-version/driver.cxx
index 353cc24..72dbb4a 100644
--- a/tests/standard-version/driver.cxx
+++ b/tests/standard-version/driver.cxx
@@ -147,7 +147,7 @@ version (const string& s,
//
// argv[0] (-rl|-pr|-al|-bt|-st|-el|-sn|-fn) <version>
// argv[0] -cm <version> <version>
-// argv[0] -cr
+// argv[0] -cr [<dependent-version>]
// argv[0] -sf <version> <constraint>
// argv[0]
//
@@ -161,7 +161,8 @@ version (const string& s,
// -fn output 'y' for final, 'n' otherwise
//
// -cm output 0 if versions are equal, -1 if the first one is less, 1 otherwise
-// -cr create version constraints from stdin lines, and print them to stdout
+// -cr create version constraints from stdin lines, optionally using the
+// dependent version, and print them to stdout
// -sf output 'y' if version satisfies constraint, 'n' otherwise
//
// If no options are specified, then create versions from stdin lines, and
@@ -241,11 +242,25 @@ try
}
else if (o == "-cr")
{
- assert (argc == 2);
+ assert (argc <= 3);
+
+ optional<standard_version> dv;
+ if (argc == 3)
+ {
+ string s (argv[2]);
+
+ dv = s.empty ()
+ ? standard_version ()
+ : standard_version (s,
+ standard_version::allow_stub |
+ standard_version::allow_earliest);
+ }
string s;
while (getline (cin, s))
- cout << standard_version_constraint (s) << endl;
+ cout << (dv
+ ? standard_version_constraint (s, *dv)
+ : standard_version_constraint (s)) << endl;
}
else if (o == "-sf")
{
diff --git a/tests/standard-version/testscript b/tests/standard-version/testscript
index cfe3b90..8a520a7 100644
--- a/tests/standard-version/testscript
+++ b/tests/standard-version/testscript
@@ -456,16 +456,141 @@
: invalid
:
{
- $* <'-1.2.3' 2>'invalid constraint' == 1 : bad-char
- $* <'~' 2>'no version' == 1 : no-version
- $* <'~1.2' 2>"'.' expected after minor version" == 1 : bad-ver
- $* <'~1.999.0' 2>"invalid minor version" == 1 : bad-min-tilde
- $* <'^0.999.0' 2>"invalid minor version" == 1 : bad-min-caret
- $* <'^999.0.0' 2>"invalid major version" == 1 : bad-maj-caret
+ $* <'-1.2.3' 2>'invalid constraint' == 1 : bad-char
+ $* <'~' 2>'no version' == 1 : no-version
+ $* <'~1.2' 2>"invalid version: '.' expected after minor version" == 1 : bad-ver
+ $* <'~1.999.0' 2>"invalid version: invalid minor version" == 1 : bad-min-tilde
+ $* <'^0.999.0' 2>"invalid version: invalid minor version" == 1 : bad-min-caret
+ $* <'^999.0.0' 2>"invalid version: invalid major version" == 1 : bad-maj-caret
}
}
}
+: constraints-dependent
+:
+{
+ test.options += -cr
+
+ : range
+ :
+ {
+ : valid
+ :
+ $* '1.2.3+1' <<EOI >>EOE
+ [1.2.2 $]
+ (1.2.2 $)
+ [$ 1.2.4]
+ ($ 1.2.4]
+ EOI
+ [1.2.2 1.2.3]
+ (1.2.2 1.2.3)
+ [1.2.3 1.2.4]
+ (1.2.3 1.2.4]
+ EOE
+ }
+
+ : comparison
+ :
+ {
+ : valid
+ :
+ $* '1.2.3+1' <<EOI >>EOE
+ == $
+ >= $
+ <= $
+ > $
+ < $
+ >= $
+ <= $
+ > $
+ < $
+ 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
+ EOE
+
+ : invalid
+ :
+ {
+ $* '' <'== $' 2>'dependent version is empty' == 1 : empty-version
+ $* '1.2.3-' <'== $' 2>'dependent version is earliest' == 1 : earliest-version
+ $* '1.2.3-a.0.z' <'== $' 2>'invalid version: dependent version is latest snapshot' == 1 : latest-version
+ $* '0+1' <'== $' 2>'invalid version: dependent version is stub' == 1 : stub-version
+ }
+ }
+
+ : shortcut
+ :
+ {
+ : final
+ :
+ {
+ $* '1.2.3+1' <<EOI >>EOE
+ ~$
+ ^$
+ EOI
+ ~1.2.0
+ ^1.0.0
+ EOE
+ }
+
+ : pre-release
+ :
+ {
+ : tilda
+ :
+ {
+ $* '1.2.0-b.2' <'~$' >'~1.2.0-a.1' : no-final
+ $* '1.2.1-a.1' <'~$' >'~1.2.0' : final-patch
+ }
+
+ : carrot
+ :
+ {
+ $* '1.0.0-b.2' <'^$' >'^1.0.0-a.1' : no-final
+ $* '1.0.1-a.1' <'^$' >'^1.0.0' : final-patch
+ $* '1.1.0-b.2' <'^$' >'^1.0.0' : final-minor
+ }
+ }
+
+ : snapshot
+ :
+ {
+ : tilda
+ :
+ {
+ $* '1.2.1-a.2.345' <'~$' >'~1.2.0' : patch
+ $* '1.2.0-a.0.345' <'~$' >'[1.2.0-a.0.1 1.2.0-a.1)' : minor
+ $* '1.0.0-a.0.345' <'~$' >'[1.0.0-a.0.1 1.0.0-a.1)' : major
+ }
+
+ : carrot
+ :
+ {
+ $* '1.2.1-a.2.345' <'^$' >'^1.0.0' : patch
+ $* '1.2.0-a.0.345' <'^$' >'[1.2.0-a.0.1 1.2.0-a.1)' : minor
+ $* '1.0.0-a.0.345' <'^$' >'[1.0.0-a.0.1 1.0.0-a.1)' : major
+ }
+ }
+ }
+
+ : invalid
+ :
+ {
+ $* <'[1.2.2 $]' 2>'invalid max version: invalid major version' != 0 : max
+ $* <'[$ 1.2.2]' 2>'invalid min version: invalid major version' != 0 : min
+ $* <'== $' 2>'invalid version: invalid major version' != 0 : eq
+ $* <'~$' 2>'invalid version: invalid major version' != 0 : shortcut
+ }
+}
+
: satisfaction
:
{