Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Failing test cases for requirements range expressions and prereleases #350

Open
wants to merge 6 commits into from

3 participants

@dekellum

Here is an oddity, continued from #349:

Prereleases are included in >=, < requirement ranges, even when they don't have prerelease segments. But anyone specifying for example < 1.5.0 is most certainly not expecting to use 1.5.0.beta.0 if they happen to have it installed.

Failed test output:

 1) Failure:
test_satisfied_by_range_postfix(TestGemRequirement) [./test/rubygems/test_gem_requirement.rb:387]:
[">= 1.4", "< 1.5"] should not be satisfied by 1.5.0.beta.0

  2) Failure:
test_satisfied_by_range_pre_inplace(TestGemRequirement) [./test/rubygems/test_gem_requirement.rb:351]:
[">= 1.4.beta", "< 1.5"] should not be satisfied by 1.5.alpha.0

  3) Failure:
test_satisfied_by_range_3_postfix(TestGemRequirement) [./test/rubygems/test_gem_requirement.rb:402]:
[">= 1.4.0", "< 1.5.0"] should not be satisfied by 1.5.0.beta.0

  4) Failure:
test_satisfied_by_range_with_pre_postfix(TestGemRequirement) [./test/rubygems/test_gem_requirement.rb:420]:
[">= 1.4.0.beta", "< 1.5"] should not be satisfied by 1.5.0.alpha.0

  5) Failure:
test_satisfied_by_range_inplace(TestGemRequirement) [./test/rubygems/test_gem_requirement.rb:371]:
[">= 1.4", "< 1.5"] should not be satisfied by 1.5.alpha.0

Also, a command line example:

% gem list bundler
*** LOCAL GEMS ***
bundler (1.2.0.pre.1, 1.1.3, 1.1.0, 1.1.rc.8)

% ruby -rubygems -e "gem( 'bundler', [ '>= 1.1', '< 1.2' ] ); require 'bundler'; puts Bundler::VERSION"
1.2.0.pre.1

Is this all expected behavior?

@travisbot

This pull request fails (merged 069b6e6 into 1e97cce).

@drbrain drbrain was assigned
@drbrain
Owner

Prereleases were always intended to be a "buyer beware" or "I know what I'm doing" feature. Users of prereleases are expected to pay attention to potential bugs in the releases they install. Due to the potential for bugs they'll need to be sure they're using the latest prerelease and upgrade to the latest version after the official release.

I don't think it's worth our time to attempt to implement a fix for these failing test cases.

We will review a patch that addresses the failures you have created here.

I'm moving this issue from the 2.0 milestone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 201 additions and 2 deletions.
  1. +201 −2 test/rubygems/test_gem_requirement.rb
View
203 test/rubygems/test_gem_requirement.rb
@@ -225,6 +225,205 @@ def test_satisfied_by_eh_boxed
refute_satisfied_by "2.0.a", "~> 2.0"
end
+ def test_satisfied_by_spermy_inplace_pre
+ req = "~> 1.4.beta"
+
+ refute_satisfied_by "1.3.beta.0", req
+ refute_satisfied_by "1.3", req
+ refute_satisfied_by "1.3.0", req
+
+ refute_satisfied_by "1.4.alpha", req
+ refute_satisfied_by "1.4.alpha.0", req
+
+ assert_satisfied_by "1.4.beta", req
+ assert_satisfied_by "1.4.beta.0", req
+ assert_satisfied_by "1.4", req
+ assert_satisfied_by "1.4.0", req
+ assert_satisfied_by "1.4.1", req
+
+ # See more delicate versions compared below
+
+ refute_satisfied_by "2.0", req
+ refute_satisfied_by "2.0.0", req
+ end
+
+ def test_satisfied_by_spermy_inplace_pre_next_minor
+ skip "Spermy won't match as expected with inplace prerelease versions"
+ req = "~> 1.4.beta"
+ refute_satisfied_by "1.5.alpha", req
+ refute_satisfied_by "1.5.beta.0", req
+ refute_satisfied_by "1.5", req
+ refute_satisfied_by "1.5.0", req
+ refute_satisfied_by "1.5.1", req
+ end
+
+ def test_satisfied_by_spermy_postfix_pre
+ req = "~> 1.4.0.beta"
+
+ refute_satisfied_by "1.3.0.beta.0", req
+ refute_satisfied_by "1.3", req
+ refute_satisfied_by "1.3.0", req
+
+ refute_satisfied_by "1.4.alpha", req
+ refute_satisfied_by "1.4.alpha.0", req
+ refute_satisfied_by "1.4.0.alpha", req
+ refute_satisfied_by "1.4.0.alpha.0", req
+
+ assert_satisfied_by "1.4.0.beta", req
+ assert_satisfied_by "1.4.0.beta.0", req
+ assert_satisfied_by "1.4", req
+ assert_satisfied_by "1.4.0", req
+ assert_satisfied_by "1.4.1", req
+
+ refute_satisfied_by "2.0", req
+ refute_satisfied_by "2.0.0", req
+
+ refute_satisfied_by "1.5", req
+ refute_satisfied_by "1.5.0.alpha", req
+ refute_satisfied_by "1.5.0.beta.0", req
+ refute_satisfied_by "1.5.0", req
+ refute_satisfied_by "1.5.1", req
+ end
+
+ def test_satisfied_by_spermy_postfix_pre_sub
+ req = "~> 1.4.0.beta.1"
+
+ refute_satisfied_by "1.3.0.beta.0", req
+ refute_satisfied_by "1.3", req
+ refute_satisfied_by "1.3.0", req
+
+ refute_satisfied_by "1.4.alpha", req
+ refute_satisfied_by "1.4.alpha.0", req
+ refute_satisfied_by "1.4.0.alpha", req
+ refute_satisfied_by "1.4.0.alpha.0", req
+
+ refute_satisfied_by "1.4.0.beta", req
+ refute_satisfied_by "1.4.0.beta.0", req
+
+ assert_satisfied_by "1.4.0.beta.1", req
+ assert_satisfied_by "1.4", req
+ assert_satisfied_by "1.4.0", req
+ assert_satisfied_by "1.4.1", req
+
+ refute_satisfied_by "2.0", req
+ refute_satisfied_by "2.0.0", req
+
+ refute_satisfied_by "1.5", req
+ refute_satisfied_by "1.5.0.alpha", req
+ refute_satisfied_by "1.5.0.beta.0", req
+ refute_satisfied_by "1.5.0", req
+ refute_satisfied_by "1.5.1", req
+ end
+
+ def test_satisfied_by_spermy_release
+ req = "~> 1.4.0"
+
+ refute_satisfied_by "1.3.beta.0", req
+ refute_satisfied_by "1.3", req
+ refute_satisfied_by "1.3.0", req
+ refute_satisfied_by "1.3.alpha.0", req
+
+ refute_satisfied_by "1.4.beta.0", req
+ assert_satisfied_by "1.4", req
+ assert_satisfied_by "1.4.0", req
+ assert_satisfied_by "1.4.1", req
+
+ refute_satisfied_by "1.5.alpha.0", req
+ refute_satisfied_by "1.5.beta.0", req
+ refute_satisfied_by "1.5", req
+ refute_satisfied_by "1.5.0", req
+ refute_satisfied_by "1.5.1", req
+ end
+
+ def test_satisfied_by_range_pre_inplace
+ req = [ ">= 1.4.beta", "< 1.5" ]
+
+ refute_satisfied_by "1.3.alpha.0", req
+ refute_satisfied_by "1.4.alpha.0", req
+
+ assert_satisfied_by "1.4.beta.0", req
+ assert_satisfied_by "1.4.beta.1", req
+
+ assert_satisfied_by "1.4", req
+ assert_satisfied_by "1.4.0", req
+ assert_satisfied_by "1.4.1", req
+
+ refute_satisfied_by "1.5.alpha.0", req
+ refute_satisfied_by "1.5.beta.0", req
+ refute_satisfied_by "1.5", req
+ refute_satisfied_by "1.5.0", req
+ refute_satisfied_by "1.5.1", req
+ end
+
+ def test_satisfied_by_range_inplace
+ req = [ ">= 1.4", "< 1.5" ]
+
+ refute_satisfied_by "1.3.alpha.0", req
+ refute_satisfied_by "1.4.alpha.0", req
+
+ refute_satisfied_by "1.4.beta.0", req
+ refute_satisfied_by "1.4.beta.1", req
+
+ assert_satisfied_by "1.4", req
+ assert_satisfied_by "1.4.0", req
+ assert_satisfied_by "1.4.1", req
+
+ refute_satisfied_by "1.5.alpha.0", req
+ refute_satisfied_by "1.5.beta.0", req
+ refute_satisfied_by "1.5", req
+ refute_satisfied_by "1.5.0", req
+ refute_satisfied_by "1.5.1", req
+ end
+
+ def test_satisfied_by_range_postfix
+ req = [ ">= 1.4", "< 1.5" ]
+
+ refute_satisfied_by "1.4.0.beta.0", req
+
+ assert_satisfied_by "1.4", req
+ assert_satisfied_by "1.4.0", req
+ assert_satisfied_by "1.4.1", req
+
+ refute_satisfied_by "1.5.0.beta.0", req
+ refute_satisfied_by "1.5", req
+ refute_satisfied_by "1.5.0", req
+ refute_satisfied_by "1.5.1", req
+ end
+
+ def test_satisfied_by_range_3_postfix
+ req = [ ">= 1.4.0", "< 1.5.0" ]
+
+ refute_satisfied_by "1.4.0.beta.0", req
+
+ assert_satisfied_by "1.4", req
+ assert_satisfied_by "1.4.0", req
+ assert_satisfied_by "1.4.1", req
+
+ refute_satisfied_by "1.5.0.beta.0", req
+ refute_satisfied_by "1.5", req
+ refute_satisfied_by "1.5.0", req
+ refute_satisfied_by "1.5.1", req
+ end
+
+ def test_satisfied_by_range_with_pre_postfix
+ req = [ ">= 1.4.0.beta", "< 1.5" ]
+
+ refute_satisfied_by "1.3.0.alpha.0", req
+ refute_satisfied_by "1.4.0.alpha.0", req
+
+ assert_satisfied_by "1.4.0.beta.0", req
+ assert_satisfied_by "1.4.0.beta.1", req
+
+ assert_satisfied_by "1.4.0", req
+ assert_satisfied_by "1.4.1", req
+
+ refute_satisfied_by "1.5.0.alpha.0", req
+ refute_satisfied_by "1.5.0.beta.0", req
+ refute_satisfied_by "1.5", req
+ refute_satisfied_by "1.5.0", req
+ refute_satisfied_by "1.5.1", req
+ end
+
def test_satisfied_by_eh_multiple
req = [">= 1.4", "<= 1.6", "!= 1.5"]
@@ -291,7 +490,7 @@ def assert_requirement_equal expected, actual
def assert_satisfied_by version, requirement
assert req(requirement).satisfied_by?(v(version)),
- "#{requirement} is satisfied by #{version}"
+ "#{requirement} should be satisfied by #{version}"
end
# Refute the assumption that two requirements are equal.
@@ -304,6 +503,6 @@ def refute_requirement_equal unexpected, actual
def refute_satisfied_by version, requirement
refute req(requirement).satisfied_by?(v(version)),
- "#{requirement} is not satisfied by #{version}"
+ "#{requirement} should not be satisfied by #{version}"
end
end
Something went wrong with that request. Please try again.