forked from conan-io/conan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
include_prerelease
and loose
option to version range expressi…
…on (conan-io#3898) * Add `include_prerelease` and `loose` option to version range expression (New to node-semver 0.5.0) Usage example: [~1.2.2,include_prerelease=True,loose=False] Change-Id: I056ac89bf37949701f67abe57455a519d14310ee * Change keywords to "strict" (loose=False) and "prerelease" (instead of include_prerelease) Reactive test for invalid semver expression. Change-Id: I2f75293f9c0b498eab6ff8d8a2be381f15cf406f * Move parsing of version expression into separate function Change-Id: Ib5209ef611295ce71c4b94f2b93e09a99c56c636 * Change back to "include_prerelease=True" and "loose=False" option. Change-Id: I388e9eba183e640fcf462546bb502e137997111f * Use python 2.7 compatible regex syntax Change-Id: I21765c9086ca192f90e5ed7e46a608e8d765a922 * Update 'node-semver' version to 0.6.1 Change-Id: I182bb1190f78d9648d30a5fe5dbc2a0a441334f6 * Add deprecated message for comma usage in version range Change-Id: Ifc2872ad1c4f9d40328e360777015727fdf20357 * Add unit tests for '_parse_versionexpr' function Change-Id: I85804296068d2252553e1c84ba4b753b957cfb34 * Check version range in 'satisfying' function Added some tests for invalid version ranges Updated warning message, when using commas in version range. Change-Id: Ie76dfa0769f434e710fc21ddcaab48841ec5b54e * work on version ranges * Updated version range regex and corrected test to fail correctly with ConanException Change-Id: If4f3123ef2ae3061b6556d89417d0cd4c898e197 * Reverted some tests, because "" is a valid range. Add asterix and caret symbol to version regex Change-Id: I3fa9cae1a6b8801e252e9bca2efe860a0ec38d68 * Add round brackets to version range regex Change-Id: I9024e63a8387a388cd8f486b05051fc5197228c8 * minor improvements * missing init.py * Add deprecated message for comma usage in version range. Change assertion to raise ConanException in '_parse_versionexpr'. Used named groups in regex matching. Change-Id: Ife07c32062eb192997b5ca1700392111519b93b9
- Loading branch information
1 parent
523e8b8
commit e3e7b35
Showing
7 changed files
with
159 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import unittest | ||
|
||
from conans.client.graph.range_resolver import _parse_versionexpr | ||
from conans.errors import ConanException | ||
from conans.test.utils.tools import TestBufferConanOutput | ||
|
||
|
||
class ParseVersionExprTest(unittest.TestCase): | ||
def test_backwards_compatibility(self): | ||
output = TestBufferConanOutput() | ||
self.assertEqual(_parse_versionexpr("2.3, 3.2", output), ("2.3 3.2", True, False)) | ||
self.assertTrue(str(output).startswith("WARN: Commas as separator")) | ||
output = TestBufferConanOutput() | ||
self.assertEqual(_parse_versionexpr("2.3, <=3.2", output), ("2.3 <=3.2", True, False)) | ||
self.assertTrue(str(output).startswith("WARN: Commas as separator")) | ||
|
||
def test_only_spaces_without_warning(self): | ||
output = TestBufferConanOutput() | ||
self.assertEqual(_parse_versionexpr("2.3 3.2", output), ("2.3 3.2", True, False)) | ||
self.assertEqual(str(output), "") | ||
|
||
def test_standard_semver(self): | ||
output = TestBufferConanOutput() | ||
self.assertEqual(_parse_versionexpr("*", output), ("*", True, False)) | ||
self.assertEqual(_parse_versionexpr("", output), ("", True, False)) # Defaults to '*' | ||
self.assertEqual(_parse_versionexpr("~1", output), ("~1", True, False)) | ||
self.assertEqual(_parse_versionexpr("~1.2.3-beta.2", output), ("~1.2.3-beta.2", True, False)) | ||
self.assertEqual(_parse_versionexpr("^0.0", output), ("^0.0", True, False)) | ||
self.assertEqual(_parse_versionexpr("1.2.3 - 2.3.4", output), ("1.2.3 - 2.3.4", True, False)) | ||
self.assertEqual(_parse_versionexpr(">=1.2.3 <1.(2+1).0", output), | ||
(">=1.2.3 <1.(2+1).0", True, False)) | ||
|
||
def test_only_loose(self): | ||
output = TestBufferConanOutput() | ||
self.assertEqual(_parse_versionexpr("2.3 ,3.2, loose=True", output), ("2.3 3.2", True, False)) | ||
self.assertEqual(_parse_versionexpr("2.3 3.2, loose=False", output), ("2.3 3.2", False, False)) | ||
self.assertEqual(_parse_versionexpr("2.3 3.2, loose = False", output), ("2.3 3.2", False, False)) | ||
self.assertEqual(_parse_versionexpr("2.3 3.2, loose = True", output), ("2.3 3.2", True, False)) | ||
|
||
def test_only_prerelease(self): | ||
output = TestBufferConanOutput() | ||
self.assertEqual(_parse_versionexpr("2.3, 3.2, include_prerelease=False", output), | ||
("2.3 3.2", True, False)) | ||
self.assertEqual(_parse_versionexpr("2.3, 3.2, include_prerelease=True", output), | ||
("2.3 3.2", True, True)) | ||
|
||
def test_both(self): | ||
output = TestBufferConanOutput() | ||
self.assertEqual(_parse_versionexpr("2.3, 3.2, loose=False, include_prerelease=True", output), | ||
("2.3 3.2", False, True)) | ||
self.assertEqual(_parse_versionexpr("2.3, 3.2, include_prerelease=True, loose=False", output), | ||
("2.3 3.2", False, True)) | ||
|
||
def test_invalid(self): | ||
output = TestBufferConanOutput() | ||
self.assertRaises(ConanException, _parse_versionexpr, "loose=False, include_prerelease=True", output) | ||
self.assertRaises(ConanException, _parse_versionexpr, "2.3, 3.2, unexpected=True", output) | ||
self.assertRaises(ConanException, _parse_versionexpr, "2.3, 3.2, loose=Other", output) | ||
self.assertRaises(ConanException, _parse_versionexpr, "2.3, 3.2, ", output) | ||
self.assertRaises(ConanException, _parse_versionexpr, "2.3, 3.2, 1.2.3", output) | ||
self.assertRaises(ConanException, _parse_versionexpr, | ||
"2.3 3.2; loose=True, include_prerelease=True", output) | ||
self.assertRaises(ConanException, _parse_versionexpr, "loose=True, 2.3 3.3", output) | ||
self.assertRaises(ConanException, _parse_versionexpr, | ||
"2.3, 3.2, 1.4, loose=False, include_prerelease=True", output) |