Skip to content
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

Use absolute paths with autoload #3100

Merged
1 commit merged into from Jan 26, 2020
Merged

Use absolute paths with autoload #3100

1 commit merged into from Jan 26, 2020

Conversation

deivid-rodriguez
Copy link
Member

Description:

Fixes the following flaky test failure under ruby 2.4:

$ rake TESTOPTS="--name=/\(test_activate_via_require_respects_loaded_files\|test_validate_license_values_or_later\)/ --seed=16773"
Run options: "--name=/(test_activate_via_require_respects_loaded_files|test_validate_license_values_or_later)/" --seed=16773

# Running:

.F

Finished in 0.110757s, 18.0575 runs/s, 63.2012 assertions/s.

  1) Failure:
TestGemSpecification#test_validate_license_values_or_later [/home/deivid/Code/rubygems/test/rubygems/test_gem_specification.rb:3159]:
Expected "WARNING:  license value 'GPL-2.0-or-later' is invalid.  Use a license identifier from\n" +
"http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.\n" +
"Did you mean 'GPL-2.0', 'GPL-2.0+'?\n" +
"WARNING:  See https://guides.rubygems.org/specification-reference/ for help\n" to be empty.

2 runs, 7 assertions, 1 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1)

Tasks: TOP => default => test
(See full trace by running task with --trace)

The first test removes lib/ from the $LOAD_PATH for the duration of the test. During the test, Gem::Licenses is autoloaded, but since lib is not in the $LOAD_PATH, it's autoloaded from the rubygems version that comes with the ruby installation (rubygems 2.6). In that rubygems version, GPL-2.0-or-later was not part of the list of licenses, so the following spec about licenses validation fails.

To fix it, we stop relying on the $LOAD_PATH for the Gem::Licenses autoload. For consistency, I also migrated the rest of the autoload's.

Closes #3095.

Tasks:

  • Describe the problem / feature
  • Write tests
  • Write code to solve the problem
  • Get code review from coworkers / friends

I will abide by the code of conduct.

Fixes the following flaky test failure under ruby 2.4:

```
$ rake TESTOPTS="--name=/\(test_activate_via_require_respects_loaded_files\|test_validate_license_values_or_later\)/ --seed=16773"
Run options: "--name=/(test_activate_via_require_respects_loaded_files|test_validate_license_values_or_later)/" --seed=16773

# Running:

.F

Finished in 0.110757s, 18.0575 runs/s, 63.2012 assertions/s.

  1) Failure:
TestGemSpecification#test_validate_license_values_or_later [/home/deivid/Code/rubygems/test/rubygems/test_gem_specification.rb:3159]:
Expected "WARNING:  license value 'GPL-2.0-or-later' is invalid.  Use a license identifier from\n" +
"http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.\n" +
"Did you mean 'GPL-2.0', 'GPL-2.0+'?\n" +
"WARNING:  See https://guides.rubygems.org/specification-reference/ for help\n" to be empty.

2 runs, 7 assertions, 1 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1)

Tasks: TOP => default => test
(See full trace by running task with --trace)
```

The first test removes `lib/` from the $LOAD_PATH for the duration of
the test. During the test, `Gem::Licenses` is autoloaded, but since
`lib` is not in the $LOAD_PATH, it's autoloaded from the rubygems
version that comes with the ruby installation (rubygems 2.6). In that
rubygems version, `GPL-2.0-or-later` was not part of the list of
licenses, so the following spec about licenses validation fails.

To fix it, we stop relying on the $LOAD_PATH for the `Gem::Licenses`
autoload. For consistency, I also migrated the rest of the autoload's.
@deivid-rodriguez
Copy link
Member Author

@bundlerbot merge

ghost pushed a commit that referenced this pull request Jan 26, 2020
3100: Use absolute paths with autoload r=deivid-rodriguez a=deivid-rodriguez

# Description:

Fixes the following flaky test failure under ruby 2.4:

```
$ rake TESTOPTS="--name=/\(test_activate_via_require_respects_loaded_files\|test_validate_license_values_or_later\)/ --seed=16773"
Run options: "--name=/(test_activate_via_require_respects_loaded_files|test_validate_license_values_or_later)/" --seed=16773

# Running:

.F

Finished in 0.110757s, 18.0575 runs/s, 63.2012 assertions/s.

  1) Failure:
TestGemSpecification#test_validate_license_values_or_later [/home/deivid/Code/rubygems/test/rubygems/test_gem_specification.rb:3159]:
Expected "WARNING:  license value 'GPL-2.0-or-later' is invalid.  Use a license identifier from\n" +
"http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.\n" +
"Did you mean 'GPL-2.0', 'GPL-2.0+'?\n" +
"WARNING:  See https://guides.rubygems.org/specification-reference/ for help\n" to be empty.

2 runs, 7 assertions, 1 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1)

Tasks: TOP => default => test
(See full trace by running task with --trace)
```

The first test removes `lib/` from the $LOAD_PATH for the duration of the test. During the test, `Gem::Licenses` is autoloaded, but since `lib` is not in the $LOAD_PATH, it's autoloaded from the rubygems version that comes with the ruby installation (rubygems 2.6). In that rubygems version, `GPL-2.0-or-later` was not part of the list of licenses, so the following spec about licenses validation fails.

To fix it, we stop relying on the $LOAD_PATH for the `Gem::Licenses` autoload. For consistency, I also migrated the rest of the autoload's.

Closes #3095.

# Tasks:

- [x] Describe the problem / feature
- [ ] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
@ghost
Copy link

ghost commented Jan 26, 2020

Build succeeded

  • install (2.3.8)
  • install (2.4.9)
  • install (2.5.7)
  • install (2.6.5)
  • install (jruby-9.2.9.0)
  • macos (2.4.x)
  • macos (2.5.x)
  • macos (2.6.x)
  • ruby_master
  • ubuntu (2.4.x, bundler)
  • ubuntu (2.4.x, rubygems)
  • ubuntu (2.5.x, bundler)
  • ubuntu (2.5.x, rubygems)
  • ubuntu (2.6.x, bundler)
  • ubuntu (2.6.x, rubygems)
  • ubuntu_bundler_master (2.6.x)
  • ubuntu_lint
  • ubuntu_rvm (2.3.8)
  • ubuntu_rvm (jruby-9.2.9.0)
  • ubuntu_rvm (ruby-head)
  • windows (2.4.x)
  • windows (2.5.x)
  • windows (2.6.x)

@ghost ghost merged commit a6dd6ac into master Jan 26, 2020
@ghost ghost deleted the autoload_absolute_paths branch January 26, 2020 09:05
@hsbt hsbt added this to the 3.1.3 milestone May 4, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky test regarding license validation
3 participants