-
Notifications
You must be signed in to change notification settings - Fork 989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add include_prerelease
and loose
option to version range expression
#3898
Conversation
…on (New to node-semver 0.5.0) Usage example: [~1.2.2,include_prerelease=True,loose=False] Change-Id: I056ac89bf37949701f67abe57455a519d14310ee
…f include_prerelease) Reactive test for invalid semver expression. Change-Id: I2f75293f9c0b498eab6ff8d8a2be381f15cf406f
include_prerelease
and loose
option to version range expressionprerelease
and strict
option to version range expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, but I need tests for the first part of the function satisfying
, the one you are discussing. I would change the function to:
def satisfying(list_versions, versionexpr, output):
version_range, loose, include_prerelase = _parse_versionexpr(versionexpr)
candidates = {}
for v in list_versions:
...
result = max_satisfying(candidates, version_range, loose=loose, include_prerelease=include_prerelease)
return candidates.get(result)
Then, I need unittests for _parse_versionexpr
and max_satisfying
. The satisfying
function will be covered enough with existing tests.
Change-Id: Ib5209ef611295ce71c4b94f2b93e09a99c56c636
@jgsogo: Thanks for your review. I will do the tests later, but before I need some feedback for the syntax as described in the above comments |
Commas are only used for version range AFAIK a expression like this would not be possible 🚫 |
I'm trying things here (https://semver.npmjs.com/) and in fact, commas are never used (we remove them in our code). Anyway, we should keep the possibility of having one comma (it is documented), but remove it for Conan 2.0. About the parameters, they have these meanings (from the docs):
With the |
The commas are just a Conan implementation and removed anyway, before using the semver library. The The Both parameter are valid for all configurations. Only
Should be the same |
Here are the options to go:
Which way to go? Anything else? |
Yes, I think those are all the options. I vote to keep closer to the implementation, so I will go for: |
I also go for number 1. |
After talking with the team, we agree that the verbose option should be the best/safest way to go. Final syntax examples should include:
by default, PD.- I'm adding dependency on #3964 as that one should be fixed first (we cannot remove commas) |
Change-Id: I388e9eba183e640fcf462546bb502e137997111f
prerelease
and strict
option to version range expressioninclude_prerelease
and loose
option to version range expression
Change-Id: I21765c9086ca192f90e5ed7e46a608e8d765a922
Change-Id: I182bb1190f78d9648d30a5fe5dbc2a0a441334f6
@jgsogo Could you give me a hint, how to write test for protected method '_parse_versionexpr'? |
Yes, of course. As we are going to separate tests into functional and unittests soon, maybe it is a good time to start. So, create a file import unittest
from conans.client.graph.range_resolver import _parse_versionexpr
class ParseVerionExpr(unittest.TestCase):
def test_backwards_compatibility(self):
self.assertEqual(_parse_versionexpr("2.3, 3.2"), ("2.3 3.2", True, False))
self.assertEqual(_parse_versionexpr("2.3, <=3.2"), ("2.3 <=3.2", True, False))
def test_only_loose(self):
self.assertEqual(_parse_versionexpr("2.3 ,3.2, loose=True"), ("2.3 3.2", True, False))
self.assertEqual(_parse_versionexpr("2.3 3.2, loose=False"), ("2.3 3.2", False, False))
self.assertEqual(_parse_versionexpr("2.3 3.2, loose = False"), ("2.3 3.2", False, False))
self.assertEqual(_parse_versionexpr("2.3 3.2, loose = True"), ("2.3 3.2", True, False))
...
def test_only_prerelease(self):
self.assertEqual(_parse_versionexpr("2.3, 3.2, include_prerelease=False"), ("2.3 3.2", True, False))
self.assertEqual(_parse_versionexpr("2.3, 3.2, include_prerelease=True"), ("2.3 3.2", True, False))
...
def test_both(self):
self.assertEqual(_parse_versionexpr("2.3, 3.2, loose=False, include_prerelease=True"), ("2.3 3.2", False, True))
self.assertEqual(_parse_versionexpr("2.3, 3.2, include_prerelease=True, loose=False"), ("2.3 3.2", False, True))
...
def test_invalid(self):
self. assertRaisesRegexp(<ExceptionType>, "expected msg", _parse_versionexpr, "2.3, 3.2, unexpected=True")
self. assertRaisesRegexp(<ExceptionType>, "expected msg", _parse_versionexpr, "2.3, 3.2, loose=Other")
self. assertRaisesRegexp(<ExceptionType>, "expected msg", _parse_versionexpr, "2.3, 3.2,")
... Our code will be solid like a rock; and this tests, as they are running a very specific function, will run very fast (add as many tests as you want). And more important, as we know that any issue related to the version-range string is correctly handled in this function, we don't have to worry about invalid strings in other tests, each test class should be testing just one functionality. 💪 |
Change-Id: Ifc2872ad1c4f9d40328e360777015727fdf20357
There is the following error on the linux test server: |
Thanks!
|
conans/test/unittests/test_client/test_graph/test_range_resolver.py
Outdated
Show resolved
Hide resolved
conans/test/unittests/test_client/test_graph/test_range_resolver.py
Outdated
Show resolved
Hide resolved
@jgsogo Are you able to check, what happen to your linux build server (out of memory)? |
After running again our CI system, it is working (green check 🙌 ) |
Added some tests for invalid version ranges Updated warning message, when using commas in version range. Change-Id: Ie76dfa0769f434e710fc21ddcaab48841ec5b54e
… ConanException Change-Id: If4f3123ef2ae3061b6556d89417d0cd4c898e197
Add asterix and caret symbol to version regex Change-Id: I3fa9cae1a6b8801e252e9bca2efe860a0ec38d68
Change-Id: I9024e63a8387a388cd8f486b05051fc5197228c8
@jgsogo Could you rerun the last test. This is not an issue from my side. |
@lasote @jgsogo @memsharded Please check your reviews again. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, btw, what's the meaning of a version range like >=1.2.3 <1.(2+1).0
?
conans/test/unittests/test_client/test_graph/test_range_resolver.py
Outdated
Show resolved
Hide resolved
Hi @climblinne Sorry, by mistake, while reviewing, I wanted to do a PR to your branch and instead pushed to it directly, which is something that github allows. The commit is: 3d9b65a It does:
Please check and tell me if something wrong, should I revert something? Thanks! |
Change assertion to raise ConanException in '_parse_versionexpr'. Used named groups in regex matching. Change-Id: Ife07c32062eb192997b5ca1700392111519b93b9
I put back the 'output' in the code and added again the warning message for #3964. The message was lost on the way. I also added some tests for it. |
…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
Require node-semver 0.6.1
Usage example: [~1.2.2,include_prerelease=True,loose=False]
Changelog: (Feature): Add
include_prerelease
andloose
option to version range expressiondevelop
branch, documenting this one. See Addinclude_prerelease
andloose
option to version range expression docs#937Connects to issue #3798