Commit graph

33 commits

Author SHA1 Message Date
Ellen Marie Dash
af594f5166 [rubygems/rubygems] Have "gem exec" sort executable names in error message.
This decouples `gem exec` behavior (and tests) from the sort order of
the gemspec.

911cd29159
2025-03-27 13:57:25 +09:00
David Rodríguez
4fe882e2c9 [rubygems/rubygems] Let gem exec raise an error in ambiguous cases
When `gem exec foo` is run, and "foo" is a gem that has multiple
executables, none of them named "foo", raise an error explaining the
situation and telling user to be more specific.

Currently the first command in the executables array is run, but this
may come as surprising sometimes, so better raise an error.

acda5d8f6e
2025-03-24 13:25:07 +09:00
David Rodríguez
a1492ffdc2 [rubygems/rubygems] Run specs that now pass on JRuby
2af077ee38
2024-10-10 14:51:30 +00:00
Ellen Marie Dash
5c18b63d00 [rubygems/rubygems] [tests] Don't expect suggestions that aren't actually helpful.
e7d6b92e31
2024-09-28 21:12:25 +00:00
David Rodríguez
72e80c8f29 [rubygems/rubygems] Make gem exec use the standard GEM_HOME
032b3c518a
2024-09-09 08:46:01 +00:00
Jerome Dalbert
bbb4da78c7 [rubygems/rubygems] Use preferred add_dependency instead of add_runtime_dependency
9a08043858
2024-07-05 02:24:53 +00:00
David Rodríguez
2755cb1b2f [rubygems/rubygems] Use modern hashes consistently
bb66253f2c
2023-12-07 22:29:33 +00:00
Vít Ondruch
43b8b88751 [rubygems/rubygems] Report possible error prior checking output of gem uninstall
Originally, the failed test case reported following error:

~~~
Failure: test_gem_exec_gem_uninstall(TestGemCommandsExecCommand):
  <""> was expected to include
  <"Successfully uninstalled a-2\n">.
/mnt/test/rubygems/test_gem_commands_exec_command.rb:742:in `block in test_gem_exec_gem_uninstall'
     739:
     740:       # assert_empty @ui.error
     741:       refute_includes @ui.output, "running gem exec with"
  => 742:       assert_includes @ui.output, "Successfully uninstalled a-2\n"
     743:
     744:       invoke "--verbose", "gem", "uninstall", "b"
     745:       assert_includes @ui.output, "Successfully uninstalled b-2\n"
/mnt/lib/rubygems/user_interaction.rb:46:in `use_ui'
/mnt/lib/rubygems/user_interaction.rb:69:in `use_ui'
/mnt/test/rubygems/test_gem_commands_exec_command.rb:726:in `test_gem_exec_gem_uninstall'
~~~

This does not tell much. Empty string is more often good sign, but not
in this case. However, checking error output first helps with
understanding possible issue:

~~~
Failure: test_gem_exec_gem_uninstall(TestGemCommandsExecCommand):
  <"ERROR:  While executing gem ... (Gem::FilePermissionError)\n" +
  "    You don't have write permissions for the /builddir/bin directory.\n" +
  "\t/mnt/lib/rubygems/uninstaller.rb:213:in `remove_executables'\n" +

... snip ...

/mnt/test/rubygems/test_gem_commands_exec_command.rb:740:in `block in test_gem_exec_gem_uninstall'
     737:         nil
     738:       end
     739:
  => 740:       assert_empty @ui.error
     741:       refute_includes @ui.output, "running gem exec with"
     742:       assert_includes @ui.output, "Successfully uninstalled a-2\n"
     743:
/mnt/lib/rubygems/user_interaction.rb:46:in `use_ui'
/mnt/lib/rubygems/user_interaction.rb:69:in `use_ui'
/mnt/test/rubygems/test_gem_commands_exec_command.rb:726:in `test_gem_exec_gem_uninstall'
~~~

BTW this issue is caused by operating_system.rb overriding
`Gem.operating_system_defaults` method and explicitly adding `--bindir`
option.

d98e36bbe7
2023-11-13 11:06:10 +09:00
Hiroshi SHIBATA
fb822076d7 [rubygems/rubygems] util/rubocop -A --only Style/LineEndConcatenation
67ece7b8b6
2023-04-06 23:33:20 +00:00
MSP-Greg
7149f5763e [rubygems/rubygems] remove test skips/pends on mswin platform
1d52eff8bf
2023-03-24 13:00:53 +00:00
Hiroshi SHIBATA
6ad6ae680a Skip test_gem_with_platform_and_platform_dependencies only ruby/ruby repository 2023-03-23 17:18:49 +09:00
Hiroshi SHIBATA
f24a86d83f util/rubocop -A --only Layout/EmptyLineAfterMagicComment 2023-03-23 17:18:49 +09:00
Hiroshi SHIBATA
6ad269dc39 [rubygems/rubygems] util/rubocop -A --only Style/RescueStandardError
80b57da926
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
70164eec0f [rubygems/rubygems] util/rubocop -A --only Style/RescueModifier
b490379eab
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
d9f92511ad [rubygems/rubygems] util/rubocop -A --only Layout/SpaceInsidePercentLiteralDelimiters
c6de27fc6d
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA
85fd33c526 [rubygems/rubygems] util/rubocop -A --only Layout/SpaceInsideArrayPercentLiteral
75abd2e504
2023-03-17 18:50:55 +09:00
David Rodríguez
90b74d8c65 [rubygems/rubygems] Fix warning about ambiguous /
```
/path/to/rubygems/test/rubygems/test_gem_commands_exec_command.rb:745: warning: ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after `/' operator
```

e6a538b5c8
2023-03-03 13:43:59 +09:00
David Rodríguez
7fea848568 [rubygems/rubygems] Fix warnings about unused variable
```
/path/to/rubygems/test/rubygems/test_gem_commands_exec_command.rb:180: warning: assigned but unused variable - platforms
```

7e022cb5e3
2023-03-03 13:43:59 +09:00
David Rodríguez
b6d914c722 [rubygems/rubygems] Fix warning about ambiguous *
```
/path/to/rubygems/test/rubygems/test_gem_commands_exec_command.rb:42: warning: `*' interpreted as argument prefix
```

0806ebf4e0
2023-03-03 13:43:58 +09:00
David Rodríguez
4467084098 [rubygems/rubygems] Enable Layout/DefEndAlignment
4403613fae
2023-03-02 21:13:12 +00:00
lukeg
ba55706fb6 fix test/rubygems/test_gem_package_task.rb when in -j mode
This test skipped sometimes due to failure to load 'rake/packagetask'.
This is due to manipulation of $LOAD_PATH by other rubygems tests. If
rake is loaded before any rubygems tests run, then it works fine.

To reproduce the skipping behavior:
  $ make test-all TESTOPTS="-j6 --test-order=sorted test/rubygems/test_*.rb"
2023-02-28 06:34:27 +09:00
Nobuyoshi Nakada
b112ae9971
Skip failing test on MSWin 2023-02-22 22:14:26 +09:00
Samuel Giddins
6232e1b9c0 [rubygems/rubygems] Skip extension test on jruby
38ee82c297
2023-02-22 08:42:21 +00:00
Samuel Giddins
151ae9790f [rubygems/rubygems] Better teardown
5fa0ebf09b
2023-02-22 08:42:20 +00:00
Samuel Giddins
a17b1b19b1 [rubygems/rubygems] Always join with a string
Gem.path_separator can also be a regexp...

7e6e56a5f3
2023-02-22 08:42:20 +00:00
Samuel Giddins
616a7e1f6c [rubygems/rubygems] Nil out Gem.configuration after tests
3135ad91d4
2023-02-22 08:42:19 +00:00
Samuel Giddins
ae5deb1ebc [rubygems/rubygems] Use assert_raise instead of assert_raises
For ruby-core compat

c8f85c91a8
2023-02-22 08:42:19 +00:00
Samuel Giddins
931db21208 [rubygems/rubygems] Add tests covering pre-releases for gem exec
f6877c29b9
2023-02-22 08:42:18 +00:00
Samuel Giddins
80bfa1b30a [rubygems/rubygems] Fix resetting env in gem exec, and make sure it is set for gem exec gem
13a6dd4992
2023-02-22 08:42:18 +00:00
Samuel Giddins
2dd9698350 [rubygems/rubygems] Allow gem exec gem
a767f7b9be
2023-02-22 08:42:17 +00:00
Samuel Giddins
47d4f73ee7 [rubygems/rubygems] Remove platform option for gem exec
Also fix native extensions that load dependencies

a06f9870c7
2023-02-22 08:42:17 +00:00
Samuel Giddins
612ebd10c0 [rubygems/rubygems] Ensure dependencies are updated by default when running gem exec
664f3e1e5f
2023-02-22 08:42:16 +00:00
Samuel Giddins
d81be0609b [rubygems/rubygems] Add specs for gem exec
3078e5834e
2023-02-22 08:42:16 +00:00