rubygems-update 3.4.21 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +132 -2
- data/Manifest.txt +39 -221
- data/README.md +1 -3
- data/bundler/CHANGELOG.md +74 -0
- data/bundler/README.md +1 -2
- data/bundler/bundler.gemspec +4 -2
- data/bundler/exe/bundle +1 -10
- data/bundler/lib/bundler/build_metadata.rb +3 -3
- data/bundler/lib/bundler/capistrano.rb +1 -1
- data/bundler/lib/bundler/checksum.rb +245 -0
- data/bundler/lib/bundler/ci_detector.rb +75 -0
- data/bundler/lib/bundler/cli/add.rb +3 -3
- data/bundler/lib/bundler/cli/binstubs.rb +4 -4
- data/bundler/lib/bundler/cli/cache.rb +1 -1
- data/bundler/lib/bundler/cli/check.rb +1 -1
- data/bundler/lib/bundler/cli/common.rb +9 -1
- data/bundler/lib/bundler/cli/config.rb +8 -7
- data/bundler/lib/bundler/cli/console.rb +3 -2
- data/bundler/lib/bundler/cli/doctor.rb +2 -2
- data/bundler/lib/bundler/cli/exec.rb +1 -1
- data/bundler/lib/bundler/cli/gem.rb +31 -23
- data/bundler/lib/bundler/cli/info.rb +2 -13
- data/bundler/lib/bundler/cli/install.rb +5 -4
- data/bundler/lib/bundler/cli/issue.rb +1 -1
- data/bundler/lib/bundler/cli/lock.rb +4 -4
- data/bundler/lib/bundler/cli/open.rb +1 -1
- data/bundler/lib/bundler/cli/outdated.rb +6 -6
- data/bundler/lib/bundler/cli/plugin.rb +7 -14
- data/bundler/lib/bundler/cli/pristine.rb +38 -30
- data/bundler/lib/bundler/cli/show.rb +2 -2
- data/bundler/lib/bundler/cli/update.rb +5 -5
- data/bundler/lib/bundler/cli.rb +215 -263
- data/bundler/lib/bundler/compact_index_client/cache.rb +29 -9
- data/bundler/lib/bundler/compact_index_client/cache_file.rb +153 -0
- data/bundler/lib/bundler/compact_index_client/gem_parser.rb +7 -3
- data/bundler/lib/bundler/compact_index_client/updater.rb +79 -81
- data/bundler/lib/bundler/compact_index_client.rb +14 -7
- data/bundler/lib/bundler/constants.rb +1 -1
- data/bundler/lib/bundler/current_ruby.rb +5 -21
- data/bundler/lib/bundler/definition.rb +43 -16
- data/bundler/lib/bundler/dependency.rb +16 -12
- data/bundler/lib/bundler/digest.rb +2 -2
- data/bundler/lib/bundler/dsl.rb +43 -25
- data/bundler/lib/bundler/endpoint_specification.rb +6 -2
- data/bundler/lib/bundler/env.rb +1 -3
- data/bundler/lib/bundler/errors.rb +58 -0
- data/bundler/lib/bundler/fetcher/base.rb +3 -1
- data/bundler/lib/bundler/fetcher/compact_index.rb +4 -4
- data/bundler/lib/bundler/fetcher/downloader.rb +13 -11
- data/bundler/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
- data/bundler/lib/bundler/fetcher/index.rb +1 -1
- data/bundler/lib/bundler/fetcher.rb +28 -25
- data/bundler/lib/bundler/friendly_errors.rb +5 -5
- data/bundler/lib/bundler/gem_helper.rb +1 -1
- data/bundler/lib/bundler/gem_helpers.rb +12 -2
- data/bundler/lib/bundler/graph.rb +9 -9
- data/bundler/lib/bundler/index.rb +1 -2
- data/bundler/lib/bundler/injector.rb +1 -1
- data/bundler/lib/bundler/inline.rb +3 -3
- data/bundler/lib/bundler/installer/gem_installer.rb +10 -10
- data/bundler/lib/bundler/installer/parallel_installer.rb +16 -8
- data/bundler/lib/bundler/installer/standalone.rb +2 -3
- data/bundler/lib/bundler/installer.rb +9 -9
- data/bundler/lib/bundler/lazy_specification.rb +28 -17
- data/bundler/lib/bundler/lockfile_generator.rb +9 -0
- data/bundler/lib/bundler/lockfile_parser.rb +81 -10
- data/bundler/lib/bundler/man/bundle-add.1 +3 -26
- data/bundler/lib/bundler/man/bundle-binstubs.1 +4 -16
- data/bundler/lib/bundler/man/bundle-cache.1 +3 -24
- data/bundler/lib/bundler/man/bundle-check.1 +3 -12
- data/bundler/lib/bundler/man/bundle-clean.1 +3 -10
- data/bundler/lib/bundler/man/bundle-config.1 +20 -211
- data/bundler/lib/bundler/man/bundle-config.1.ronn +6 -0
- data/bundler/lib/bundler/man/bundle-console.1 +4 -22
- data/bundler/lib/bundler/man/bundle-doctor.1 +4 -18
- data/bundler/lib/bundler/man/bundle-exec.1 +12 -73
- data/bundler/lib/bundler/man/bundle-gem.1 +13 -49
- data/bundler/lib/bundler/man/bundle-help.1 +3 -7
- data/bundler/lib/bundler/man/bundle-info.1 +3 -9
- data/bundler/lib/bundler/man/bundle-init.1 +3 -12
- data/bundler/lib/bundler/man/bundle-inject.1 +6 -19
- data/bundler/lib/bundler/man/bundle-install.1 +27 -125
- data/bundler/lib/bundler/man/bundle-install.1.ronn +1 -0
- data/bundler/lib/bundler/man/bundle-list.1 +4 -19
- data/bundler/lib/bundler/man/bundle-lock.1 +5 -29
- data/bundler/lib/bundler/man/bundle-open.1 +7 -27
- data/bundler/lib/bundler/man/bundle-outdated.1 +3 -55
- data/bundler/lib/bundler/man/bundle-outdated.1.ronn +1 -0
- data/bundler/lib/bundler/man/bundle-platform.1 +5 -27
- data/bundler/lib/bundler/man/bundle-plugin.1 +3 -29
- data/bundler/lib/bundler/man/bundle-pristine.1 +5 -16
- data/bundler/lib/bundler/man/bundle-remove.1 +4 -14
- data/bundler/lib/bundler/man/bundle-show.1 +3 -10
- data/bundler/lib/bundler/man/bundle-update.1 +18 -137
- data/bundler/lib/bundler/man/bundle-version.1 +3 -16
- data/bundler/lib/bundler/man/bundle-viz.1 +4 -16
- data/bundler/lib/bundler/man/bundle.1 +5 -44
- data/bundler/lib/bundler/man/gemfile.5 +24 -301
- data/bundler/lib/bundler/man/gemfile.5.ronn +4 -0
- data/bundler/lib/bundler/match_metadata.rb +4 -0
- data/bundler/lib/bundler/match_platform.rb +1 -1
- data/bundler/lib/bundler/plugin/api/source.rb +3 -2
- data/bundler/lib/bundler/plugin/index.rb +8 -0
- data/bundler/lib/bundler/plugin/installer.rb +1 -1
- data/bundler/lib/bundler/plugin.rb +12 -5
- data/bundler/lib/bundler/resolver/base.rb +1 -1
- data/bundler/lib/bundler/resolver/incompatibility.rb +1 -1
- data/bundler/lib/bundler/resolver/spec_group.rb +1 -4
- data/bundler/lib/bundler/resolver.rb +16 -16
- data/bundler/lib/bundler/ruby_dsl.rb +20 -12
- data/bundler/lib/bundler/ruby_version.rb +1 -1
- data/bundler/lib/bundler/rubygems_ext.rb +27 -54
- data/bundler/lib/bundler/rubygems_gem_installer.rb +23 -58
- data/bundler/lib/bundler/rubygems_integration.rb +25 -94
- data/bundler/lib/bundler/runtime.rb +2 -2
- data/bundler/lib/bundler/self_manager.rb +23 -7
- data/bundler/lib/bundler/settings.rb +27 -7
- data/bundler/lib/bundler/setup.rb +4 -1
- data/bundler/lib/bundler/shared_helpers.rb +35 -13
- data/bundler/lib/bundler/source/git/git_proxy.rb +22 -14
- data/bundler/lib/bundler/source/git.rb +4 -3
- data/bundler/lib/bundler/source/metadata.rb +16 -16
- data/bundler/lib/bundler/source/path.rb +7 -6
- data/bundler/lib/bundler/source/rubygems.rb +21 -14
- data/bundler/lib/bundler/source.rb +2 -0
- data/bundler/lib/bundler/spec_set.rb +43 -12
- data/bundler/lib/bundler/stub_specification.rb +1 -0
- data/bundler/lib/bundler/templates/Executable.bundler +1 -1
- data/bundler/lib/bundler/templates/newgem/README.md.tt +3 -3
- data/bundler/lib/bundler/templates/newgem/Rakefile.tt +2 -6
- data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
- data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
- data/bundler/lib/bundler/templates/newgem/standard.yml.tt +1 -1
- data/bundler/lib/bundler/ui/shell.rb +2 -2
- data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
- data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +53 -6
- data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +8 -20
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +4 -3
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +23 -11
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +36 -36
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +8 -10
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +15 -4
- data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +15 -15
- data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
- data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
- data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +4 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +16 -25
- data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
- data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +44 -6
- data/bundler/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
- data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +26 -150
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +4 -46
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -45
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/lcs_diff.rb +49 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
- data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
- data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/bundler/lib/bundler/vendor/thor/lib/thor.rb +155 -8
- data/bundler/lib/bundler/vendor/tsort/lib/tsort.rb +3 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +256 -132
- data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +1 -0
- data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +95 -31
- data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
- data/bundler/lib/bundler/vendored_net_http.rb +8 -0
- data/bundler/lib/bundler/vendored_persistent.rb +0 -4
- data/bundler/lib/bundler/vendored_timeout.rb +8 -0
- data/bundler/lib/bundler/version.rb +1 -1
- data/bundler/lib/bundler/vlad.rb +1 -1
- data/bundler/lib/bundler/yaml_serializer.rb +9 -4
- data/bundler/lib/bundler.rb +38 -35
- data/lib/rubygems/available_set.rb +4 -4
- data/lib/rubygems/basic_specification.rb +35 -37
- data/lib/rubygems/bundler_version_finder.rb +4 -4
- data/lib/rubygems/ci_detector.rb +75 -0
- data/lib/rubygems/command.rb +15 -17
- data/lib/rubygems/command_manager.rb +5 -4
- data/lib/rubygems/commands/build_command.rb +2 -2
- data/lib/rubygems/commands/cert_command.rb +2 -3
- data/lib/rubygems/commands/check_command.rb +4 -4
- data/lib/rubygems/commands/cleanup_command.rb +12 -14
- data/lib/rubygems/commands/contents_command.rb +5 -5
- data/lib/rubygems/commands/dependency_command.rb +4 -5
- data/lib/rubygems/commands/environment_command.rb +3 -5
- data/lib/rubygems/commands/exec_command.rb +1 -1
- data/lib/rubygems/commands/fetch_command.rb +2 -2
- data/lib/rubygems/commands/generate_index_command.rb +39 -74
- data/lib/rubygems/commands/help_command.rb +4 -4
- data/lib/rubygems/commands/info_command.rb +2 -2
- data/lib/rubygems/commands/install_command.rb +8 -16
- data/lib/rubygems/commands/list_command.rb +2 -2
- data/lib/rubygems/commands/lock_command.rb +1 -1
- data/lib/rubygems/commands/open_command.rb +1 -1
- data/lib/rubygems/commands/owner_command.rb +1 -1
- data/lib/rubygems/commands/pristine_command.rb +13 -15
- data/lib/rubygems/commands/push_command.rb +2 -2
- data/lib/rubygems/commands/query_command.rb +4 -5
- data/lib/rubygems/commands/rdoc_command.rb +2 -2
- data/lib/rubygems/commands/search_command.rb +2 -2
- data/lib/rubygems/commands/setup_command.rb +33 -36
- data/lib/rubygems/commands/sources_command.rb +12 -12
- data/lib/rubygems/commands/specification_command.rb +10 -10
- data/lib/rubygems/commands/stale_command.rb +1 -1
- data/lib/rubygems/commands/uninstall_command.rb +13 -14
- data/lib/rubygems/commands/unpack_command.rb +7 -7
- data/lib/rubygems/commands/update_command.rb +11 -13
- data/lib/rubygems/commands/which_command.rb +1 -1
- data/lib/rubygems/commands/yank_command.rb +1 -1
- data/lib/rubygems/compatibility.rb +5 -6
- data/lib/rubygems/config_file.rb +7 -7
- data/lib/rubygems/core_ext/kernel_gem.rb +0 -2
- data/lib/rubygems/core_ext/kernel_require.rb +20 -49
- data/lib/rubygems/core_ext/kernel_warn.rb +1 -1
- data/lib/rubygems/core_ext/tcpsocket_init.rb +1 -1
- data/lib/rubygems/defaults.rb +15 -3
- data/lib/rubygems/dependency.rb +12 -14
- data/lib/rubygems/dependency_installer.rb +30 -31
- data/lib/rubygems/dependency_list.rb +1 -1
- data/lib/rubygems/deprecate.rb +16 -15
- data/lib/rubygems/doctor.rb +6 -6
- data/lib/rubygems/errors.rb +2 -6
- data/lib/rubygems/exceptions.rb +2 -1
- data/lib/rubygems/ext/builder.rb +15 -10
- data/lib/rubygems/ext/cargo_builder.rb +5 -5
- data/lib/rubygems/ext/ext_conf_builder.rb +2 -4
- data/lib/rubygems/ext/rake_builder.rb +1 -1
- data/lib/rubygems/gem_runner.rb +4 -4
- data/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb +3 -3
- data/lib/rubygems/gemcutter_utilities/webauthn_poller.rb +3 -3
- data/lib/rubygems/gemcutter_utilities.rb +18 -19
- data/lib/rubygems/install_update_options.rb +18 -19
- data/lib/rubygems/installer.rb +66 -45
- data/lib/rubygems/installer_uninstaller_utils.rb +0 -2
- data/lib/rubygems/local_remote_options.rb +8 -11
- data/lib/rubygems/name_tuple.rb +7 -9
- data/lib/rubygems/net/http.rb +3 -0
- data/lib/rubygems/net-http/LICENSE.txt +22 -0
- data/lib/rubygems/net-http/lib/net/http/backward.rb +40 -0
- data/lib/rubygems/net-http/lib/net/http/exceptions.rb +34 -0
- data/lib/rubygems/net-http/lib/net/http/generic_request.rb +414 -0
- data/lib/rubygems/net-http/lib/net/http/header.rb +981 -0
- data/lib/rubygems/net-http/lib/net/http/proxy_delta.rb +17 -0
- data/lib/rubygems/net-http/lib/net/http/request.rb +88 -0
- data/lib/rubygems/net-http/lib/net/http/requests.rb +425 -0
- data/lib/rubygems/net-http/lib/net/http/response.rb +738 -0
- data/lib/rubygems/net-http/lib/net/http/responses.rb +1174 -0
- data/lib/rubygems/net-http/lib/net/http/status.rb +84 -0
- data/lib/rubygems/net-http/lib/net/http.rb +2496 -0
- data/lib/rubygems/net-http/lib/net/https.rb +23 -0
- data/lib/rubygems/net-protocol/LICENSE.txt +22 -0
- data/lib/rubygems/net-protocol/lib/net/protocol.rb +544 -0
- data/lib/rubygems/optparse/lib/optparse.rb +39 -17
- data/lib/rubygems/package/digest_io.rb +1 -1
- data/lib/rubygems/package/old.rb +2 -2
- data/lib/rubygems/package/tar_header.rb +45 -39
- data/lib/rubygems/package/tar_reader/entry.rb +5 -4
- data/lib/rubygems/package/tar_reader.rb +14 -5
- data/lib/rubygems/package/tar_writer.rb +20 -18
- data/lib/rubygems/package.rb +28 -27
- data/lib/rubygems/package_task.rb +2 -2
- data/lib/rubygems/path_support.rb +10 -11
- data/lib/rubygems/platform.rb +65 -48
- data/lib/rubygems/query_utils.rb +7 -9
- data/lib/rubygems/remote_fetcher.rb +17 -17
- data/lib/rubygems/request/connection_pools.rb +3 -3
- data/lib/rubygems/request.rb +20 -17
- data/lib/rubygems/request_set/gem_dependency_api.rb +120 -123
- data/lib/rubygems/request_set/lockfile/parser.rb +9 -9
- data/lib/rubygems/request_set/lockfile/tokenizer.rb +20 -12
- data/lib/rubygems/request_set/lockfile.rb +6 -11
- data/lib/rubygems/request_set.rb +5 -5
- data/lib/rubygems/requirement.rb +7 -7
- data/lib/rubygems/resolv/LICENSE.txt +22 -0
- data/lib/rubygems/resolv/lib/resolv.rb +3387 -0
- data/lib/rubygems/resolver/activation_request.rb +1 -3
- data/lib/rubygems/resolver/api_set/gem_parser.rb +7 -3
- data/lib/rubygems/resolver/best_set.rb +1 -1
- data/lib/rubygems/resolver/composed_set.rb +1 -1
- data/lib/rubygems/resolver/conflict.rb +4 -12
- data/lib/rubygems/resolver/index_set.rb +4 -4
- data/lib/rubygems/resolver/index_specification.rb +2 -2
- data/lib/rubygems/resolver/installer_set.rb +5 -6
- data/lib/rubygems/resolver/lock_set.rb +1 -1
- data/lib/rubygems/resolver.rb +6 -13
- data/lib/rubygems/s3_uri_signer.rb +6 -6
- data/lib/rubygems/safe_marshal/elements.rb +138 -0
- data/lib/rubygems/safe_marshal/reader.rb +306 -0
- data/lib/rubygems/safe_marshal/visitors/stream_printer.rb +31 -0
- data/lib/rubygems/safe_marshal/visitors/to_ruby.rb +385 -0
- data/lib/rubygems/safe_marshal/visitors/visitor.rb +74 -0
- data/lib/rubygems/safe_marshal.rb +74 -0
- data/lib/rubygems/safe_yaml.rb +5 -28
- data/lib/rubygems/security/policies.rb +36 -38
- data/lib/rubygems/security/policy.rb +7 -11
- data/lib/rubygems/security/signer.rb +1 -1
- data/lib/rubygems/security/trust_dir.rb +4 -4
- data/lib/rubygems/security.rb +8 -22
- data/lib/rubygems/source/git.rb +1 -3
- data/lib/rubygems/source/installed.rb +0 -2
- data/lib/rubygems/source/local.rb +7 -9
- data/lib/rubygems/source/lock.rb +1 -3
- data/lib/rubygems/source/specific_file.rb +0 -1
- data/lib/rubygems/source/vendor.rb +0 -2
- data/lib/rubygems/source.rb +12 -12
- data/lib/rubygems/source_list.rb +5 -5
- data/lib/rubygems/spec_fetcher.rb +31 -31
- data/lib/rubygems/specification.rb +145 -150
- data/lib/rubygems/specification_policy.rb +61 -31
- data/lib/rubygems/stub_specification.rb +4 -5
- data/lib/rubygems/text.rb +1 -2
- data/lib/rubygems/timeout/LICENSE.txt +22 -0
- data/lib/rubygems/timeout/lib/timeout.rb +199 -0
- data/lib/rubygems/timeout.rb +3 -0
- data/lib/rubygems/tsort/lib/tsort.rb +3 -0
- data/lib/rubygems/uninstaller.rb +9 -11
- data/lib/rubygems/update_suggestion.rb +5 -18
- data/lib/rubygems/uri_formatter.rb +1 -1
- data/lib/rubygems/user_interaction.rb +17 -23
- data/lib/rubygems/util/licenses.rb +113 -35
- data/lib/rubygems/util/list.rb +3 -1
- data/lib/rubygems/util.rb +2 -4
- data/lib/rubygems/validator.rb +6 -4
- data/lib/rubygems/version.rb +35 -29
- data/lib/rubygems/version_option.rb +2 -5
- data/lib/rubygems/yaml_serializer.rb +9 -4
- data/lib/rubygems.rb +42 -42
- data/rubygems-update.gemspec +4 -4
- data/setup.rb +2 -2
- metadata +43 -225
- data/lib/rubygems/indexer.rb +0 -428
- data/lib/rubygems/mock_gem_ui.rb +0 -86
- data/test/rubygems/alternate_cert.pem +0 -19
- data/test/rubygems/alternate_cert_32.pem +0 -19
- data/test/rubygems/alternate_key.pem +0 -27
- data/test/rubygems/bad_rake.rb +0 -3
- data/test/rubygems/bundler_test_gem.rb +0 -424
- data/test/rubygems/ca_cert.pem +0 -77
- data/test/rubygems/child_cert.pem +0 -19
- data/test/rubygems/child_cert_32.pem +0 -19
- data/test/rubygems/child_key.pem +0 -27
- data/test/rubygems/client.pem +0 -107
- data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
- data/test/rubygems/data/gem-private_key.pem +0 -27
- data/test/rubygems/data/gem-public_cert.pem +0 -20
- data/test/rubygems/data/null-required-ruby-version.gemspec.rz +0 -0
- data/test/rubygems/data/null-required-rubygems-version.gemspec.rz +0 -0
- data/test/rubygems/data/pry-0.4.7.gemspec.rz +0 -0
- data/test/rubygems/encrypted_private_key.pem +0 -30
- data/test/rubygems/expired_cert.pem +0 -19
- data/test/rubygems/fake_certlib/openssl.rb +0 -9
- data/test/rubygems/foo/discover.rb +0 -1
- data/test/rubygems/future_cert.pem +0 -19
- data/test/rubygems/future_cert_32.pem +0 -19
- data/test/rubygems/good_rake.rb +0 -3
- data/test/rubygems/grandchild_cert.pem +0 -19
- data/test/rubygems/grandchild_cert_32.pem +0 -19
- data/test/rubygems/grandchild_key.pem +0 -27
- data/test/rubygems/helper.rb +0 -1649
- data/test/rubygems/installer_test_case.rb +0 -248
- data/test/rubygems/invalid_client.pem +0 -49
- data/test/rubygems/invalid_issuer_cert.pem +0 -20
- data/test/rubygems/invalid_issuer_cert_32.pem +0 -20
- data/test/rubygems/invalid_key.pem +0 -27
- data/test/rubygems/invalid_signer_cert.pem +0 -19
- data/test/rubygems/invalid_signer_cert_32.pem +0 -19
- data/test/rubygems/invalidchild_cert.pem +0 -19
- data/test/rubygems/invalidchild_cert_32.pem +0 -19
- data/test/rubygems/invalidchild_key.pem +0 -27
- data/test/rubygems/multifactor_auth_utilities.rb +0 -111
- data/test/rubygems/package/tar_test_case.rb +0 -175
- data/test/rubygems/packages/Bluebie-legs-0.6.2.gem +0 -0
- data/test/rubygems/packages/ascii_binder-0.1.10.1.gem +0 -0
- data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
- data/test/rubygems/plugin/exception/rubygems_plugin.rb +0 -4
- data/test/rubygems/plugin/load/rubygems_plugin.rb +0 -5
- data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +0 -4
- data/test/rubygems/private3072_key.pem +0 -40
- data/test/rubygems/private_ec_key.pem +0 -9
- data/test/rubygems/private_key.pem +0 -27
- data/test/rubygems/public3072_cert.pem +0 -25
- data/test/rubygems/public_cert.pem +0 -20
- data/test/rubygems/public_cert_32.pem +0 -19
- data/test/rubygems/public_key.pem +0 -9
- data/test/rubygems/rubygems/commands/crash_command.rb +0 -5
- data/test/rubygems/rubygems_plugin.rb +0 -24
- data/test/rubygems/sff/discover.rb +0 -1
- data/test/rubygems/simple_gem.rb +0 -68
- data/test/rubygems/specifications/bar-0.0.2.gemspec +0 -9
- data/test/rubygems/specifications/foo-0.0.1-x86-mswin32.gemspec +0 -0
- data/test/rubygems/specifications/rubyforge-0.0.1.gemspec +0 -14
- data/test/rubygems/ssl_cert.pem +0 -80
- data/test/rubygems/ssl_key.pem +0 -27
- data/test/rubygems/test_bundled_ca.rb +0 -61
- data/test/rubygems/test_config.rb +0 -28
- data/test/rubygems/test_deprecate.rb +0 -158
- data/test/rubygems/test_exit.rb +0 -17
- data/test/rubygems/test_gem.rb +0 -1799
- data/test/rubygems/test_gem_available_set.rb +0 -130
- data/test/rubygems/test_gem_bundler_version_finder.rb +0 -127
- data/test/rubygems/test_gem_command.rb +0 -403
- data/test/rubygems/test_gem_command_manager.rb +0 -400
- data/test/rubygems/test_gem_commands_build_command.rb +0 -739
- data/test/rubygems/test_gem_commands_cert_command.rb +0 -866
- data/test/rubygems/test_gem_commands_check_command.rb +0 -68
- data/test/rubygems/test_gem_commands_cleanup_command.rb +0 -292
- data/test/rubygems/test_gem_commands_contents_command.rb +0 -271
- data/test/rubygems/test_gem_commands_dependency_command.rb +0 -228
- data/test/rubygems/test_gem_commands_environment_command.rb +0 -169
- data/test/rubygems/test_gem_commands_exec_command.rb +0 -857
- data/test/rubygems/test_gem_commands_fetch_command.rb +0 -258
- data/test/rubygems/test_gem_commands_generate_index_command.rb +0 -81
- data/test/rubygems/test_gem_commands_help_command.rb +0 -94
- data/test/rubygems/test_gem_commands_info_command.rb +0 -70
- data/test/rubygems/test_gem_commands_install_command.rb +0 -1573
- data/test/rubygems/test_gem_commands_list_command.rb +0 -33
- data/test/rubygems/test_gem_commands_lock_command.rb +0 -67
- data/test/rubygems/test_gem_commands_mirror.rb +0 -20
- data/test/rubygems/test_gem_commands_open_command.rb +0 -101
- data/test/rubygems/test_gem_commands_outdated_command.rb +0 -50
- data/test/rubygems/test_gem_commands_owner_command.rb +0 -503
- data/test/rubygems/test_gem_commands_pristine_command.rb +0 -708
- data/test/rubygems/test_gem_commands_push_command.rb +0 -603
- data/test/rubygems/test_gem_commands_query_command.rb +0 -858
- data/test/rubygems/test_gem_commands_search_command.rb +0 -16
- data/test/rubygems/test_gem_commands_server_command.rb +0 -20
- data/test/rubygems/test_gem_commands_setup_command.rb +0 -474
- data/test/rubygems/test_gem_commands_signin_command.rb +0 -259
- data/test/rubygems/test_gem_commands_signout_command.rb +0 -30
- data/test/rubygems/test_gem_commands_sources_command.rb +0 -534
- data/test/rubygems/test_gem_commands_specification_command.rb +0 -277
- data/test/rubygems/test_gem_commands_stale_command.rb +0 -43
- data/test/rubygems/test_gem_commands_uninstall_command.rb +0 -522
- data/test/rubygems/test_gem_commands_unpack_command.rb +0 -224
- data/test/rubygems/test_gem_commands_update_command.rb +0 -836
- data/test/rubygems/test_gem_commands_which_command.rb +0 -85
- data/test/rubygems/test_gem_commands_yank_command.rb +0 -299
- data/test/rubygems/test_gem_config_file.rb +0 -551
- data/test/rubygems/test_gem_dependency.rb +0 -398
- data/test/rubygems/test_gem_dependency_installer.rb +0 -1190
- data/test/rubygems/test_gem_dependency_list.rb +0 -265
- data/test/rubygems/test_gem_dependency_resolution_error.rb +0 -27
- data/test/rubygems/test_gem_doctor.rb +0 -195
- data/test/rubygems/test_gem_ext_builder.rb +0 -337
- data/test/rubygems/test_gem_ext_cargo_builder/custom_name/.gitignore +0 -1
- data/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +0 -10
- data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock +0 -249
- data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml +0 -10
- data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/src/lib.rs +0 -27
- data/test/rubygems/test_gem_ext_cargo_builder/custom_name/lib/custom_name.rb +0 -3
- data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/.gitignore +0 -1
- data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +0 -249
- data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +0 -10
- data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec +0 -10
- data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/src/lib.rs +0 -51
- data/test/rubygems/test_gem_ext_cargo_builder.rb +0 -167
- data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +0 -34
- data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +0 -60
- data/test/rubygems/test_gem_ext_cmake_builder.rb +0 -84
- data/test/rubygems/test_gem_ext_configure_builder.rb +0 -80
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +0 -229
- data/test/rubygems/test_gem_ext_rake_builder.rb +0 -113
- data/test/rubygems/test_gem_gem_runner.rb +0 -119
- data/test/rubygems/test_gem_gemcutter_utilities.rb +0 -361
- data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -60
- data/test/rubygems/test_gem_indexer.rb +0 -381
- data/test/rubygems/test_gem_install_update_options.rb +0 -208
- data/test/rubygems/test_gem_installer.rb +0 -2512
- data/test/rubygems/test_gem_local_remote_options.rb +0 -133
- data/test/rubygems/test_gem_name_tuple.rb +0 -43
- data/test/rubygems/test_gem_package.rb +0 -1306
- data/test/rubygems/test_gem_package_old.rb +0 -91
- data/test/rubygems/test_gem_package_tar_header.rb +0 -226
- data/test/rubygems/test_gem_package_tar_reader.rb +0 -135
- data/test/rubygems/test_gem_package_tar_reader_entry.rb +0 -350
- data/test/rubygems/test_gem_package_tar_writer.rb +0 -331
- data/test/rubygems/test_gem_package_task.rb +0 -118
- data/test/rubygems/test_gem_path_support.rb +0 -139
- data/test/rubygems/test_gem_platform.rb +0 -497
- data/test/rubygems/test_gem_rdoc.rb +0 -137
- data/test/rubygems/test_gem_remote_fetcher.rb +0 -1227
- data/test/rubygems/test_gem_request.rb +0 -547
- data/test/rubygems/test_gem_request_connection_pools.rb +0 -152
- data/test/rubygems/test_gem_request_set.rb +0 -672
- data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +0 -853
- data/test/rubygems/test_gem_request_set_lockfile.rb +0 -469
- data/test/rubygems/test_gem_request_set_lockfile_parser.rb +0 -544
- data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +0 -307
- data/test/rubygems/test_gem_requirement.rb +0 -505
- data/test/rubygems/test_gem_resolver.rb +0 -859
- data/test/rubygems/test_gem_resolver_activation_request.rb +0 -43
- data/test/rubygems/test_gem_resolver_api_set.rb +0 -210
- data/test/rubygems/test_gem_resolver_api_specification.rb +0 -167
- data/test/rubygems/test_gem_resolver_best_set.rb +0 -159
- data/test/rubygems/test_gem_resolver_composed_set.rb +0 -44
- data/test/rubygems/test_gem_resolver_conflict.rb +0 -82
- data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -83
- data/test/rubygems/test_gem_resolver_git_set.rb +0 -188
- data/test/rubygems/test_gem_resolver_git_specification.rb +0 -114
- data/test/rubygems/test_gem_resolver_index_set.rb +0 -88
- data/test/rubygems/test_gem_resolver_index_specification.rb +0 -93
- data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -47
- data/test/rubygems/test_gem_resolver_installer_set.rb +0 -320
- data/test/rubygems/test_gem_resolver_local_specification.rb +0 -44
- data/test/rubygems/test_gem_resolver_lock_set.rb +0 -62
- data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -98
- data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -19
- data/test/rubygems/test_gem_resolver_specification.rb +0 -63
- data/test/rubygems/test_gem_resolver_vendor_set.rb +0 -82
- data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -82
- data/test/rubygems/test_gem_security.rb +0 -341
- data/test/rubygems/test_gem_security_policy.rb +0 -535
- data/test/rubygems/test_gem_security_signer.rb +0 -218
- data/test/rubygems/test_gem_security_trust_dir.rb +0 -99
- data/test/rubygems/test_gem_silent_ui.rb +0 -123
- data/test/rubygems/test_gem_source.rb +0 -254
- data/test/rubygems/test_gem_source_fetch_problem.rb +0 -37
- data/test/rubygems/test_gem_source_git.rb +0 -310
- data/test/rubygems/test_gem_source_installed.rb +0 -35
- data/test/rubygems/test_gem_source_list.rb +0 -119
- data/test/rubygems/test_gem_source_local.rb +0 -107
- data/test/rubygems/test_gem_source_lock.rb +0 -113
- data/test/rubygems/test_gem_source_specific_file.rb +0 -76
- data/test/rubygems/test_gem_source_subpath_problem.rb +0 -50
- data/test/rubygems/test_gem_source_vendor.rb +0 -30
- data/test/rubygems/test_gem_spec_fetcher.rb +0 -338
- data/test/rubygems/test_gem_specification.rb +0 -3856
- data/test/rubygems/test_gem_stream_ui.rb +0 -255
- data/test/rubygems/test_gem_stub_specification.rb +0 -278
- data/test/rubygems/test_gem_text.rb +0 -103
- data/test/rubygems/test_gem_uninstaller.rb +0 -675
- data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -31
- data/test/rubygems/test_gem_update_suggestion.rb +0 -209
- data/test/rubygems/test_gem_uri.rb +0 -41
- data/test/rubygems/test_gem_uri_formatter.rb +0 -27
- data/test/rubygems/test_gem_util.rb +0 -91
- data/test/rubygems/test_gem_validator.rb +0 -42
- data/test/rubygems/test_gem_version.rb +0 -305
- data/test/rubygems/test_gem_version_option.rb +0 -165
- data/test/rubygems/test_kernel.rb +0 -124
- data/test/rubygems/test_project_sanity.rb +0 -49
- data/test/rubygems/test_remote_fetch_error.rb +0 -20
- data/test/rubygems/test_require.rb +0 -732
- data/test/rubygems/test_rubygems.rb +0 -76
- data/test/rubygems/test_webauthn_listener.rb +0 -143
- data/test/rubygems/test_webauthn_listener_response.rb +0 -93
- data/test/rubygems/test_webauthn_poller.rb +0 -124
- data/test/rubygems/utilities.rb +0 -436
- data/test/rubygems/wrong_key_cert.pem +0 -19
- data/test/rubygems/wrong_key_cert_32.pem +0 -19
- data/test/test_changelog_generator.rb +0 -17
@@ -1,2512 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "installer_test_case"
|
4
|
-
|
5
|
-
class TestGemInstaller < Gem::InstallerTestCase
|
6
|
-
def setup
|
7
|
-
super
|
8
|
-
common_installer_setup
|
9
|
-
|
10
|
-
@config = Gem.configuration
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
common_installer_teardown
|
15
|
-
|
16
|
-
super
|
17
|
-
|
18
|
-
Gem.configuration = instance_variable_defined?(:@config) ? @config : nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_app_script_text
|
22
|
-
load_relative "no" do
|
23
|
-
installer = setup_base_installer
|
24
|
-
|
25
|
-
util_make_exec @spec, ""
|
26
|
-
|
27
|
-
expected = <<-EOF
|
28
|
-
#!#{Gem.ruby}
|
29
|
-
#
|
30
|
-
# This file was generated by RubyGems.
|
31
|
-
#
|
32
|
-
# The application 'a' is installed as part of a gem, and
|
33
|
-
# this file is here to facilitate running it.
|
34
|
-
#
|
35
|
-
|
36
|
-
require 'rubygems'
|
37
|
-
|
38
|
-
Gem.use_gemdeps
|
39
|
-
|
40
|
-
version = \">= 0.a\"
|
41
|
-
|
42
|
-
str = ARGV.first
|
43
|
-
if str
|
44
|
-
str = str.b[/\\A_(.*)_\\z/, 1]
|
45
|
-
if str and Gem::Version.correct?(str)
|
46
|
-
version = str
|
47
|
-
ARGV.shift
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
if Gem.respond_to?(:activate_bin_path)
|
52
|
-
load Gem.activate_bin_path('a', 'executable', version)
|
53
|
-
else
|
54
|
-
gem "a", version
|
55
|
-
load Gem.bin_path("a", "executable", version)
|
56
|
-
end
|
57
|
-
EOF
|
58
|
-
|
59
|
-
wrapper = installer.app_script_text "executable"
|
60
|
-
assert_equal expected, wrapper
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_check_executable_overwrite
|
65
|
-
installer = setup_base_installer
|
66
|
-
|
67
|
-
installer.generate_bin
|
68
|
-
|
69
|
-
@spec = Gem::Specification.new do |s|
|
70
|
-
s.files = ["lib/code.rb"]
|
71
|
-
s.name = "a"
|
72
|
-
s.version = "3"
|
73
|
-
s.summary = "summary"
|
74
|
-
s.description = "desc"
|
75
|
-
s.require_path = "lib"
|
76
|
-
end
|
77
|
-
|
78
|
-
util_make_exec
|
79
|
-
installer.gem_dir = @spec.gem_dir
|
80
|
-
installer.wrappers = true
|
81
|
-
installer.generate_bin
|
82
|
-
|
83
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
84
|
-
assert_path_exist installed_exec
|
85
|
-
|
86
|
-
wrapper = File.read installed_exec
|
87
|
-
assert_match %r{generated by RubyGems}, wrapper
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_check_executable_overwrite_default_bin_dir
|
91
|
-
installer = setup_base_installer(false)
|
92
|
-
|
93
|
-
bindir(Gem.bindir) do
|
94
|
-
util_conflict_executable false
|
95
|
-
|
96
|
-
ui = Gem::MockGemUi.new "n\n"
|
97
|
-
use_ui ui do
|
98
|
-
e = assert_raise Gem::InstallError do
|
99
|
-
installer.generate_bin
|
100
|
-
end
|
101
|
-
|
102
|
-
conflicted = File.join @gemhome, "bin", "executable"
|
103
|
-
assert_match %r{\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z},
|
104
|
-
e.message
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_check_executable_overwrite_format_executable
|
110
|
-
installer = setup_base_installer
|
111
|
-
|
112
|
-
installer.generate_bin
|
113
|
-
|
114
|
-
@spec = Gem::Specification.new do |s|
|
115
|
-
s.files = ["lib/code.rb"]
|
116
|
-
s.name = "a"
|
117
|
-
s.version = "3"
|
118
|
-
s.summary = "summary"
|
119
|
-
s.description = "desc"
|
120
|
-
s.require_path = "lib"
|
121
|
-
end
|
122
|
-
|
123
|
-
File.open File.join(util_inst_bindir, "executable"), "w" do |io|
|
124
|
-
io.write <<-EXEC
|
125
|
-
#!/usr/local/bin/ruby
|
126
|
-
#
|
127
|
-
# This file was generated by RubyGems
|
128
|
-
|
129
|
-
gem 'other', version
|
130
|
-
EXEC
|
131
|
-
end
|
132
|
-
|
133
|
-
util_make_exec
|
134
|
-
Gem::Installer.exec_format = "foo-%s-bar"
|
135
|
-
installer.gem_dir = @spec.gem_dir
|
136
|
-
installer.wrappers = true
|
137
|
-
installer.format_executable = true
|
138
|
-
|
139
|
-
installer.generate_bin # should not raise
|
140
|
-
|
141
|
-
installed_exec = File.join util_inst_bindir, "foo-executable-bar"
|
142
|
-
assert_path_exist installed_exec
|
143
|
-
|
144
|
-
wrapper = File.read installed_exec
|
145
|
-
assert_match %r{generated by RubyGems}, wrapper
|
146
|
-
ensure
|
147
|
-
Gem::Installer.exec_format = nil
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_check_executable_overwrite_other_gem
|
151
|
-
installer = setup_base_installer(false)
|
152
|
-
|
153
|
-
util_conflict_executable true
|
154
|
-
|
155
|
-
ui = Gem::MockGemUi.new "n\n"
|
156
|
-
|
157
|
-
use_ui ui do
|
158
|
-
e = assert_raise Gem::InstallError do
|
159
|
-
installer.generate_bin
|
160
|
-
end
|
161
|
-
|
162
|
-
assert_equal '"executable" from a conflicts with installed executable from conflict',
|
163
|
-
e.message
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_check_executable_overwrite_other_gem_force
|
168
|
-
installer = setup_base_installer
|
169
|
-
|
170
|
-
util_conflict_executable true
|
171
|
-
installer.wrappers = true
|
172
|
-
installer.force = true
|
173
|
-
|
174
|
-
installer.generate_bin
|
175
|
-
|
176
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
177
|
-
assert_path_exist installed_exec
|
178
|
-
|
179
|
-
wrapper = File.read installed_exec
|
180
|
-
assert_match %r{generated by RubyGems}, wrapper
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_check_executable_overwrite_other_non_gem
|
184
|
-
installer = setup_base_installer
|
185
|
-
|
186
|
-
util_conflict_executable false
|
187
|
-
installer.wrappers = true
|
188
|
-
|
189
|
-
installer.generate_bin
|
190
|
-
|
191
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
192
|
-
assert_path_exist installed_exec
|
193
|
-
|
194
|
-
wrapper = File.read installed_exec
|
195
|
-
assert_match %r{generated by RubyGems}, wrapper
|
196
|
-
end unless Gem.win_platform?
|
197
|
-
|
198
|
-
def test_check_that_user_bin_dir_is_in_path
|
199
|
-
installer = setup_base_installer
|
200
|
-
|
201
|
-
bin_dir = installer.bin_dir
|
202
|
-
|
203
|
-
if Gem.win_platform?
|
204
|
-
bin_dir = bin_dir.downcase
|
205
|
-
end
|
206
|
-
|
207
|
-
orig_PATH = ENV["PATH"]
|
208
|
-
ENV["PATH"] = [ENV["PATH"], bin_dir].join(File::PATH_SEPARATOR)
|
209
|
-
|
210
|
-
use_ui @ui do
|
211
|
-
installer.check_that_user_bin_dir_is_in_path
|
212
|
-
end
|
213
|
-
|
214
|
-
assert_empty @ui.error
|
215
|
-
|
216
|
-
return unless win_platform?
|
217
|
-
|
218
|
-
ENV["PATH"] = [orig_PATH, bin_dir.tr(File::SEPARATOR, File::ALT_SEPARATOR)].join(File::PATH_SEPARATOR)
|
219
|
-
|
220
|
-
use_ui @ui do
|
221
|
-
installer.check_that_user_bin_dir_is_in_path
|
222
|
-
end
|
223
|
-
|
224
|
-
assert_empty @ui.error
|
225
|
-
ensure
|
226
|
-
ENV["PATH"] = orig_PATH
|
227
|
-
end
|
228
|
-
|
229
|
-
def test_check_that_user_bin_dir_is_in_path_tilde
|
230
|
-
pend "Tilde is PATH is not supported under MS Windows" if win_platform?
|
231
|
-
|
232
|
-
orig_PATH = ENV["PATH"]
|
233
|
-
ENV["PATH"] = [ENV["PATH"], "~/bin"].join(File::PATH_SEPARATOR)
|
234
|
-
|
235
|
-
installer = setup_base_installer
|
236
|
-
installer.bin_dir.replace File.join @userhome, "bin"
|
237
|
-
|
238
|
-
use_ui @ui do
|
239
|
-
installer.check_that_user_bin_dir_is_in_path
|
240
|
-
end
|
241
|
-
|
242
|
-
assert_empty @ui.error
|
243
|
-
ensure
|
244
|
-
ENV["PATH"] = orig_PATH unless win_platform?
|
245
|
-
end
|
246
|
-
|
247
|
-
def test_check_that_user_bin_dir_is_in_path_not_in_path
|
248
|
-
installer = setup_base_installer
|
249
|
-
|
250
|
-
use_ui @ui do
|
251
|
-
installer.check_that_user_bin_dir_is_in_path
|
252
|
-
end
|
253
|
-
|
254
|
-
expected = installer.bin_dir
|
255
|
-
|
256
|
-
if Gem.win_platform?
|
257
|
-
expected = expected.downcase
|
258
|
-
end
|
259
|
-
|
260
|
-
assert_match expected, @ui.error
|
261
|
-
end
|
262
|
-
|
263
|
-
def test_ensure_dependency
|
264
|
-
installer = setup_base_installer
|
265
|
-
|
266
|
-
util_spec "a"
|
267
|
-
|
268
|
-
dep = Gem::Dependency.new "a", ">= 2"
|
269
|
-
assert installer.ensure_dependency(@spec, dep)
|
270
|
-
|
271
|
-
dep = Gem::Dependency.new "b", "> 2"
|
272
|
-
e = assert_raise Gem::InstallError do
|
273
|
-
installer.ensure_dependency @spec, dep
|
274
|
-
end
|
275
|
-
|
276
|
-
assert_equal "a requires b (> 2)", e.message
|
277
|
-
end
|
278
|
-
|
279
|
-
def test_ensure_loadable_spec
|
280
|
-
a, a_gem = util_gem "a", 2 do |s|
|
281
|
-
s.add_dependency "garbage ~> 5"
|
282
|
-
end
|
283
|
-
|
284
|
-
installer = Gem::Installer.at a_gem
|
285
|
-
|
286
|
-
e = assert_raise Gem::InstallError do
|
287
|
-
installer.ensure_loadable_spec
|
288
|
-
end
|
289
|
-
|
290
|
-
assert_equal "The specification for #{a.full_name} is corrupt " +
|
291
|
-
"(SyntaxError)", e.message
|
292
|
-
end
|
293
|
-
|
294
|
-
def test_ensure_loadable_spec_security_policy
|
295
|
-
pend "openssl is missing" unless Gem::HAVE_OPENSSL
|
296
|
-
|
297
|
-
_, a_gem = util_gem "a", 2 do |s|
|
298
|
-
s.add_dependency "garbage ~> 5"
|
299
|
-
end
|
300
|
-
|
301
|
-
policy = Gem::Security::HighSecurity
|
302
|
-
installer = Gem::Installer.at a_gem, :security_policy => policy
|
303
|
-
|
304
|
-
assert_raise Gem::Security::Exception do
|
305
|
-
installer.ensure_loadable_spec
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
def test_extract_files
|
310
|
-
installer = setup_base_installer
|
311
|
-
|
312
|
-
installer.extract_files
|
313
|
-
|
314
|
-
assert_path_exist File.join @spec.gem_dir, "bin/executable"
|
315
|
-
end
|
316
|
-
|
317
|
-
def test_generate_bin_bindir
|
318
|
-
installer = setup_base_installer
|
319
|
-
|
320
|
-
installer.wrappers = true
|
321
|
-
|
322
|
-
@spec.executables = %w[executable]
|
323
|
-
@spec.bindir = "bin"
|
324
|
-
|
325
|
-
exec_file = installer.formatted_program_filename "executable"
|
326
|
-
exec_path = File.join @spec.gem_dir, exec_file
|
327
|
-
File.open exec_path, "w" do |f|
|
328
|
-
f.puts "#!/usr/bin/ruby"
|
329
|
-
end
|
330
|
-
|
331
|
-
installer.gem_dir = @spec.gem_dir
|
332
|
-
|
333
|
-
installer.generate_bin
|
334
|
-
|
335
|
-
assert_directory_exists util_inst_bindir
|
336
|
-
installed_exec = File.join(util_inst_bindir, "executable")
|
337
|
-
assert_path_exist installed_exec
|
338
|
-
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
|
339
|
-
|
340
|
-
wrapper = File.read installed_exec
|
341
|
-
assert_match %r{generated by RubyGems}, wrapper
|
342
|
-
end
|
343
|
-
|
344
|
-
def test_generate_bin_bindir_with_user_install_warning
|
345
|
-
bin_dir = Gem.win_platform? ? File.expand_path(ENV["WINDIR"]).upcase :
|
346
|
-
"/usr/bin"
|
347
|
-
|
348
|
-
old_path = ENV["PATH"]
|
349
|
-
ENV["PATH"] = [ENV["PATH"], bin_dir].compact.join(File::PATH_SEPARATOR)
|
350
|
-
|
351
|
-
options = {
|
352
|
-
:bin_dir => bin_dir,
|
353
|
-
:install_dir => "/non/existent",
|
354
|
-
}
|
355
|
-
|
356
|
-
inst = Gem::Installer.at "", options
|
357
|
-
|
358
|
-
Gem::Installer.path_warning = false
|
359
|
-
|
360
|
-
use_ui @ui do
|
361
|
-
inst.check_that_user_bin_dir_is_in_path
|
362
|
-
end
|
363
|
-
|
364
|
-
assert_equal "", @ui.error
|
365
|
-
|
366
|
-
ensure
|
367
|
-
ENV["PATH"] = old_path
|
368
|
-
end
|
369
|
-
|
370
|
-
def test_generate_bin_script
|
371
|
-
installer = setup_base_installer
|
372
|
-
|
373
|
-
installer.wrappers = true
|
374
|
-
util_make_exec
|
375
|
-
installer.gem_dir = @spec.gem_dir
|
376
|
-
|
377
|
-
installer.generate_bin
|
378
|
-
assert_directory_exists util_inst_bindir
|
379
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
380
|
-
assert_path_exist installed_exec
|
381
|
-
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
|
382
|
-
|
383
|
-
wrapper = File.read installed_exec
|
384
|
-
assert_match %r{generated by RubyGems}, wrapper
|
385
|
-
end
|
386
|
-
|
387
|
-
def test_generate_bin_script_format
|
388
|
-
installer = setup_base_installer
|
389
|
-
|
390
|
-
installer.format_executable = true
|
391
|
-
installer.wrappers = true
|
392
|
-
util_make_exec
|
393
|
-
installer.gem_dir = @spec.gem_dir
|
394
|
-
|
395
|
-
Gem::Installer.exec_format = "foo-%s-bar"
|
396
|
-
installer.generate_bin
|
397
|
-
assert_directory_exists util_inst_bindir
|
398
|
-
installed_exec = File.join util_inst_bindir, "foo-executable-bar"
|
399
|
-
assert_path_exist installed_exec
|
400
|
-
ensure
|
401
|
-
Gem::Installer.exec_format = nil
|
402
|
-
end
|
403
|
-
|
404
|
-
def test_generate_bin_script_format_disabled
|
405
|
-
installer = setup_base_installer
|
406
|
-
|
407
|
-
installer.wrappers = true
|
408
|
-
util_make_exec
|
409
|
-
installer.gem_dir = @spec.gem_dir
|
410
|
-
|
411
|
-
Gem::Installer.exec_format = "foo-%s-bar"
|
412
|
-
installer.generate_bin
|
413
|
-
assert_directory_exists util_inst_bindir
|
414
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
415
|
-
assert_path_exist installed_exec
|
416
|
-
ensure
|
417
|
-
Gem::Installer.exec_format = nil
|
418
|
-
end
|
419
|
-
|
420
|
-
def test_generate_bin_script_install_dir
|
421
|
-
installer = setup_base_installer
|
422
|
-
|
423
|
-
installer.wrappers = true
|
424
|
-
|
425
|
-
gem_dir = File.join("#{@gemhome}2", "gems", @spec.full_name)
|
426
|
-
gem_bindir = File.join gem_dir, "bin"
|
427
|
-
FileUtils.mkdir_p gem_bindir
|
428
|
-
File.open File.join(gem_bindir, "executable"), "w" do |f|
|
429
|
-
f.puts "#!/bin/ruby"
|
430
|
-
end
|
431
|
-
|
432
|
-
installer.gem_home = "#{@gemhome}2"
|
433
|
-
installer.gem_dir = gem_dir
|
434
|
-
installer.bin_dir = File.join "#{@gemhome}2", "bin"
|
435
|
-
|
436
|
-
installer.generate_bin
|
437
|
-
|
438
|
-
installed_exec = File.join("#{@gemhome}2", "bin", "executable")
|
439
|
-
assert_path_exist installed_exec
|
440
|
-
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
|
441
|
-
|
442
|
-
wrapper = File.read installed_exec
|
443
|
-
assert_match %r{generated by RubyGems}, wrapper
|
444
|
-
end
|
445
|
-
|
446
|
-
def test_generate_bin_script_no_execs
|
447
|
-
installer = setup_base_installer
|
448
|
-
|
449
|
-
installer = util_execless
|
450
|
-
|
451
|
-
installer.wrappers = true
|
452
|
-
installer.generate_bin
|
453
|
-
|
454
|
-
assert_path_not_exist util_inst_bindir, "bin dir was created when not needed"
|
455
|
-
end
|
456
|
-
|
457
|
-
def test_generate_bin_script_no_perms
|
458
|
-
installer = setup_base_installer
|
459
|
-
|
460
|
-
installer.wrappers = true
|
461
|
-
util_make_exec
|
462
|
-
|
463
|
-
Dir.mkdir util_inst_bindir
|
464
|
-
|
465
|
-
if win_platform?
|
466
|
-
pend("test_generate_bin_script_no_perms skipped on MS Windows")
|
467
|
-
elsif Process.uid.zero?
|
468
|
-
pend("test_generate_bin_script_no_perms skipped in root privilege")
|
469
|
-
else
|
470
|
-
FileUtils.chmod 0o000, util_inst_bindir
|
471
|
-
|
472
|
-
assert_raise Gem::FilePermissionError do
|
473
|
-
installer.generate_bin
|
474
|
-
end
|
475
|
-
end
|
476
|
-
ensure
|
477
|
-
FileUtils.chmod 0o755, util_inst_bindir unless ($DEBUG || win_platform?)
|
478
|
-
end
|
479
|
-
|
480
|
-
def test_generate_bin_script_no_shebang
|
481
|
-
installer = setup_base_installer
|
482
|
-
|
483
|
-
installer.wrappers = true
|
484
|
-
@spec.executables = %w[executable]
|
485
|
-
|
486
|
-
gem_dir = File.join @gemhome, "gems", @spec.full_name
|
487
|
-
gem_bindir = File.join gem_dir, "bin"
|
488
|
-
FileUtils.mkdir_p gem_bindir
|
489
|
-
File.open File.join(gem_bindir, "executable"), "w" do |f|
|
490
|
-
f.puts "blah blah blah"
|
491
|
-
end
|
492
|
-
|
493
|
-
installer.generate_bin
|
494
|
-
|
495
|
-
installed_exec = File.join @gemhome, "bin", "executable"
|
496
|
-
assert_path_exist installed_exec
|
497
|
-
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
|
498
|
-
|
499
|
-
wrapper = File.read installed_exec
|
500
|
-
assert_match %r{generated by RubyGems}, wrapper
|
501
|
-
# HACK some gems don't have #! in their executables, restore 2008/06
|
502
|
-
#assert_no_match %r|generated by RubyGems|, wrapper
|
503
|
-
end
|
504
|
-
|
505
|
-
def test_generate_bin_script_wrappers
|
506
|
-
installer = setup_base_installer
|
507
|
-
|
508
|
-
installer.wrappers = true
|
509
|
-
util_make_exec
|
510
|
-
installer.gem_dir = @spec.gem_dir
|
511
|
-
installed_exec = File.join(util_inst_bindir, "executable")
|
512
|
-
|
513
|
-
real_exec = File.join @spec.gem_dir, "bin", "executable"
|
514
|
-
|
515
|
-
# fake --no-wrappers for previous install
|
516
|
-
unless Gem.win_platform?
|
517
|
-
FileUtils.mkdir_p File.dirname(installed_exec)
|
518
|
-
FileUtils.ln_s real_exec, installed_exec
|
519
|
-
end
|
520
|
-
|
521
|
-
installer.generate_bin
|
522
|
-
assert_directory_exists util_inst_bindir
|
523
|
-
assert_path_exist installed_exec
|
524
|
-
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
|
525
|
-
|
526
|
-
assert_match %r{generated by RubyGems}, File.read(installed_exec)
|
527
|
-
|
528
|
-
refute_match %r{generated by RubyGems}, File.read(real_exec),
|
529
|
-
"real executable overwritten"
|
530
|
-
end
|
531
|
-
|
532
|
-
def test_generate_bin_symlink
|
533
|
-
pend "Symlinks not supported or not enabled" unless symlink_supported?
|
534
|
-
|
535
|
-
installer = setup_base_installer
|
536
|
-
|
537
|
-
installer.wrappers = false
|
538
|
-
util_make_exec
|
539
|
-
installer.gem_dir = @spec.gem_dir
|
540
|
-
|
541
|
-
installer.generate_bin
|
542
|
-
assert_directory_exists util_inst_bindir
|
543
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
544
|
-
assert_equal true, File.symlink?(installed_exec)
|
545
|
-
assert_equal(File.join(@spec.gem_dir, "bin", "executable"),
|
546
|
-
File.readlink(installed_exec))
|
547
|
-
end
|
548
|
-
|
549
|
-
def test_generate_bin_symlink_no_execs
|
550
|
-
installer = setup_base_installer
|
551
|
-
|
552
|
-
installer = util_execless
|
553
|
-
|
554
|
-
installer.wrappers = false
|
555
|
-
installer.generate_bin
|
556
|
-
|
557
|
-
assert_path_not_exist util_inst_bindir
|
558
|
-
end
|
559
|
-
|
560
|
-
def test_generate_bin_symlink_no_perms
|
561
|
-
installer = setup_base_installer
|
562
|
-
|
563
|
-
installer.wrappers = false
|
564
|
-
util_make_exec
|
565
|
-
installer.gem_dir = @spec.gem_dir
|
566
|
-
|
567
|
-
Dir.mkdir util_inst_bindir
|
568
|
-
|
569
|
-
if win_platform?
|
570
|
-
pend("test_generate_bin_symlink_no_perms skipped on MS Windows")
|
571
|
-
elsif Process.uid.zero?
|
572
|
-
pend("test_user_install_disabled_read_only test skipped in root privilege")
|
573
|
-
else
|
574
|
-
FileUtils.chmod 0o000, util_inst_bindir
|
575
|
-
|
576
|
-
assert_raise Gem::FilePermissionError do
|
577
|
-
installer.generate_bin
|
578
|
-
end
|
579
|
-
end
|
580
|
-
ensure
|
581
|
-
FileUtils.chmod 0o755, util_inst_bindir unless ($DEBUG || win_platform?)
|
582
|
-
end
|
583
|
-
|
584
|
-
def test_generate_bin_symlink_update_newer
|
585
|
-
pend "Symlinks not supported or not enabled" unless symlink_supported?
|
586
|
-
|
587
|
-
installer = setup_base_installer
|
588
|
-
|
589
|
-
installer.wrappers = false
|
590
|
-
util_make_exec
|
591
|
-
installer.gem_dir = @spec.gem_dir
|
592
|
-
|
593
|
-
installer.generate_bin
|
594
|
-
installed_exec = File.join(util_inst_bindir, "executable")
|
595
|
-
assert_equal(File.join(@spec.gem_dir, "bin", "executable"),
|
596
|
-
File.readlink(installed_exec))
|
597
|
-
|
598
|
-
@spec = Gem::Specification.new do |s|
|
599
|
-
s.files = ["lib/code.rb"]
|
600
|
-
s.name = "a"
|
601
|
-
s.version = "3"
|
602
|
-
s.summary = "summary"
|
603
|
-
s.description = "desc"
|
604
|
-
s.require_path = "lib"
|
605
|
-
end
|
606
|
-
|
607
|
-
util_make_exec
|
608
|
-
installer.gem_dir = @spec.gem_dir
|
609
|
-
installer.generate_bin
|
610
|
-
installed_exec = File.join(util_inst_bindir, "executable")
|
611
|
-
assert_equal(@spec.bin_file("executable"),
|
612
|
-
File.readlink(installed_exec),
|
613
|
-
"Ensure symlink moved to latest version")
|
614
|
-
end
|
615
|
-
|
616
|
-
def test_generate_bin_symlink_update_older
|
617
|
-
pend "Symlinks not supported or not enabled" unless symlink_supported?
|
618
|
-
|
619
|
-
installer = setup_base_installer
|
620
|
-
|
621
|
-
installer.wrappers = false
|
622
|
-
util_make_exec
|
623
|
-
installer.gem_dir = @spec.gem_dir
|
624
|
-
|
625
|
-
installer.generate_bin
|
626
|
-
installed_exec = File.join(util_inst_bindir, "executable")
|
627
|
-
assert_equal(File.join(@spec.gem_dir, "bin", "executable"),
|
628
|
-
File.readlink(installed_exec))
|
629
|
-
|
630
|
-
spec = Gem::Specification.new do |s|
|
631
|
-
s.files = ["lib/code.rb"]
|
632
|
-
s.name = "a"
|
633
|
-
s.version = "1"
|
634
|
-
s.summary = "summary"
|
635
|
-
s.description = "desc"
|
636
|
-
s.require_path = "lib"
|
637
|
-
end
|
638
|
-
|
639
|
-
util_make_exec
|
640
|
-
one = @spec.dup
|
641
|
-
one.version = 1
|
642
|
-
installer = Gem::Installer.for_spec spec
|
643
|
-
installer.gem_dir = one.gem_dir
|
644
|
-
|
645
|
-
installer.generate_bin
|
646
|
-
|
647
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
648
|
-
expected = File.join @spec.gem_dir, "bin", "executable"
|
649
|
-
assert_equal(expected,
|
650
|
-
File.readlink(installed_exec),
|
651
|
-
"Ensure symlink not moved")
|
652
|
-
end
|
653
|
-
|
654
|
-
def test_generate_bin_symlink_update_remove_wrapper
|
655
|
-
pend "Symlinks not supported or not enabled" unless symlink_supported?
|
656
|
-
|
657
|
-
installer = setup_base_installer
|
658
|
-
|
659
|
-
installer.wrappers = true
|
660
|
-
util_make_exec
|
661
|
-
installer.gem_dir = @spec.gem_dir
|
662
|
-
|
663
|
-
installer.generate_bin
|
664
|
-
|
665
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
666
|
-
assert_path_exist installed_exec
|
667
|
-
|
668
|
-
@spec = Gem::Specification.new do |s|
|
669
|
-
s.files = ["lib/code.rb"]
|
670
|
-
s.name = "a"
|
671
|
-
s.version = "3"
|
672
|
-
s.summary = "summary"
|
673
|
-
s.description = "desc"
|
674
|
-
s.require_path = "lib"
|
675
|
-
end
|
676
|
-
util_make_exec
|
677
|
-
|
678
|
-
util_installer @spec, @gemhome
|
679
|
-
installer.wrappers = false
|
680
|
-
installer.gem_dir = @spec.gem_dir
|
681
|
-
|
682
|
-
installer.generate_bin
|
683
|
-
|
684
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
685
|
-
assert_equal(@spec.bin_file("executable"),
|
686
|
-
File.readlink(installed_exec),
|
687
|
-
"Ensure symlink moved to latest version")
|
688
|
-
end
|
689
|
-
|
690
|
-
def test_generate_bin_symlink_win32
|
691
|
-
old_win_platform = Gem.win_platform?
|
692
|
-
Gem.win_platform = true
|
693
|
-
old_alt_separator = File::ALT_SEPARATOR
|
694
|
-
File.__send__(:remove_const, :ALT_SEPARATOR)
|
695
|
-
File.const_set(:ALT_SEPARATOR, "\\")
|
696
|
-
|
697
|
-
installer = setup_base_installer
|
698
|
-
|
699
|
-
installer.wrappers = false
|
700
|
-
util_make_exec
|
701
|
-
installer.gem_dir = @spec.gem_dir
|
702
|
-
|
703
|
-
use_ui @ui do
|
704
|
-
installer.generate_bin
|
705
|
-
end
|
706
|
-
|
707
|
-
assert_directory_exists util_inst_bindir
|
708
|
-
installed_exec = File.join(util_inst_bindir, "executable")
|
709
|
-
assert_path_exist installed_exec
|
710
|
-
|
711
|
-
if symlink_supported?
|
712
|
-
assert File.symlink?(installed_exec)
|
713
|
-
return
|
714
|
-
end
|
715
|
-
|
716
|
-
assert_match(/Unable to use symlinks, installing wrapper/i,
|
717
|
-
@ui.error)
|
718
|
-
|
719
|
-
wrapper = File.read installed_exec
|
720
|
-
assert_match(/generated by RubyGems/, wrapper)
|
721
|
-
ensure
|
722
|
-
File.__send__(:remove_const, :ALT_SEPARATOR)
|
723
|
-
File.const_set(:ALT_SEPARATOR, old_alt_separator)
|
724
|
-
Gem.win_platform = old_win_platform
|
725
|
-
end
|
726
|
-
|
727
|
-
def test_generate_bin_uses_default_shebang
|
728
|
-
pend "Symlinks not supported or not enabled" unless symlink_supported?
|
729
|
-
|
730
|
-
load_relative "no" do
|
731
|
-
installer = setup_base_installer
|
732
|
-
|
733
|
-
installer.wrappers = true
|
734
|
-
util_make_exec
|
735
|
-
|
736
|
-
installer.generate_bin
|
737
|
-
|
738
|
-
default_shebang = Gem.ruby
|
739
|
-
shebang_line = File.open("#{@gemhome}/bin/executable") {|f| f.readlines.first }
|
740
|
-
assert_match(/\A#!/, shebang_line)
|
741
|
-
assert_match(/#{default_shebang}/, shebang_line)
|
742
|
-
end
|
743
|
-
end
|
744
|
-
|
745
|
-
def test_generate_bin_with_dangling_symlink
|
746
|
-
gem_with_dangling_symlink = File.expand_path("packages/ascii_binder-0.1.10.1.gem", __dir__)
|
747
|
-
|
748
|
-
installer = Gem::Installer.at(
|
749
|
-
gem_with_dangling_symlink,
|
750
|
-
:user_install => false,
|
751
|
-
:force => true
|
752
|
-
)
|
753
|
-
|
754
|
-
build_rake_in do
|
755
|
-
use_ui @ui do
|
756
|
-
installer.install
|
757
|
-
end
|
758
|
-
end
|
759
|
-
|
760
|
-
errors = @ui.error.split("\n")
|
761
|
-
assert_equal "WARNING: ascii_binder-0.1.10.1 ships with a dangling symlink named bin/ascii_binder pointing to missing bin/asciibinder file. Ignoring", errors.shift
|
762
|
-
assert_empty errors
|
763
|
-
|
764
|
-
assert_empty @ui.output
|
765
|
-
end
|
766
|
-
|
767
|
-
def test_generate_plugins
|
768
|
-
installer = util_setup_installer do |spec|
|
769
|
-
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
770
|
-
io.write "# do nothing"
|
771
|
-
end
|
772
|
-
|
773
|
-
spec.files += %w[lib/rubygems_plugin.rb]
|
774
|
-
end
|
775
|
-
|
776
|
-
build_rake_in do
|
777
|
-
installer.install
|
778
|
-
end
|
779
|
-
|
780
|
-
plugin_path = File.join Gem.plugindir, "a_plugin.rb"
|
781
|
-
|
782
|
-
FileUtils.rm plugin_path
|
783
|
-
|
784
|
-
installer.generate_plugins
|
785
|
-
|
786
|
-
assert File.exist?(plugin_path), "plugin not written"
|
787
|
-
end
|
788
|
-
|
789
|
-
def test_generate_plugins_with_install_dir
|
790
|
-
spec = quick_gem "a" do |s|
|
791
|
-
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
792
|
-
io.write "puts __FILE__"
|
793
|
-
end
|
794
|
-
|
795
|
-
s.files += %w[lib/rubygems_plugin.rb]
|
796
|
-
end
|
797
|
-
|
798
|
-
util_build_gem spec
|
799
|
-
|
800
|
-
plugin_path = File.join "#{@gemhome}2", "plugins", "a_plugin.rb"
|
801
|
-
installer = util_installer spec, "#{@gemhome}2"
|
802
|
-
|
803
|
-
assert_equal spec, installer.install
|
804
|
-
|
805
|
-
assert File.exist?(plugin_path), "plugin not written to install_dir"
|
806
|
-
end
|
807
|
-
|
808
|
-
def test_generate_plugins_with_user_install
|
809
|
-
spec = quick_gem "a" do |s|
|
810
|
-
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
811
|
-
io.write "puts __FILE__"
|
812
|
-
end
|
813
|
-
|
814
|
-
s.files += %w[lib/rubygems_plugin.rb]
|
815
|
-
end
|
816
|
-
|
817
|
-
util_build_gem spec
|
818
|
-
|
819
|
-
File.chmod(0o555, Gem.plugindir)
|
820
|
-
system_path = File.join(Gem.plugindir, "a_plugin.rb")
|
821
|
-
user_path = File.join(Gem.plugindir(Gem.user_dir), "a_plugin.rb")
|
822
|
-
installer = util_installer spec, Gem.dir, :user
|
823
|
-
|
824
|
-
assert_equal spec, installer.install
|
825
|
-
|
826
|
-
assert !File.exist?(system_path), "plugin incorrectly written to system plugins_dir"
|
827
|
-
assert File.exist?(user_path), "plugin not written to user plugins_dir"
|
828
|
-
end
|
829
|
-
|
830
|
-
def test_generate_plugins_with_build_root
|
831
|
-
spec = quick_gem "a" do |s|
|
832
|
-
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
833
|
-
io.write "puts __FILE__"
|
834
|
-
end
|
835
|
-
|
836
|
-
s.files += %w[lib/rubygems_plugin.rb]
|
837
|
-
end
|
838
|
-
|
839
|
-
util_build_gem spec
|
840
|
-
|
841
|
-
File.chmod(0o555, Gem.plugindir)
|
842
|
-
system_path = File.join(Gem.plugindir, "a_plugin.rb")
|
843
|
-
|
844
|
-
build_root = File.join(@tempdir, "build_root")
|
845
|
-
build_root_path = File.join(build_root, Gem.plugindir.gsub(/^[a-zA-Z]:/, ""), "a_plugin.rb")
|
846
|
-
|
847
|
-
installer = Gem::Installer.at spec.cache_file, :build_root => build_root
|
848
|
-
|
849
|
-
assert_equal spec, installer.install
|
850
|
-
|
851
|
-
assert !File.exist?(system_path), "plugin written incorrect written to system plugins_dir"
|
852
|
-
assert File.exist?(build_root_path), "plugin not written to build_root"
|
853
|
-
|
854
|
-
refute_includes File.read(build_root_path), build_root
|
855
|
-
end
|
856
|
-
|
857
|
-
class << self
|
858
|
-
attr_accessor :plugin_loaded
|
859
|
-
attr_accessor :post_install_is_called
|
860
|
-
end
|
861
|
-
|
862
|
-
def test_use_plugin_immediately
|
863
|
-
self.class.plugin_loaded = false
|
864
|
-
self.class.post_install_is_called = false
|
865
|
-
spec_version = nil
|
866
|
-
plugin_path = nil
|
867
|
-
installer = util_setup_installer do |spec|
|
868
|
-
spec_version = spec.version
|
869
|
-
plugin_path = File.join("lib", "rubygems_plugin.rb")
|
870
|
-
write_file File.join(@tempdir, plugin_path) do |io|
|
871
|
-
io.write <<-PLUGIN
|
872
|
-
#{self.class}.plugin_loaded = true
|
873
|
-
Gem.post_install do
|
874
|
-
#{self.class}.post_install_is_called = true
|
875
|
-
end
|
876
|
-
PLUGIN
|
877
|
-
end
|
878
|
-
spec.files += [plugin_path]
|
879
|
-
plugin_path = File.join(spec.gem_dir, plugin_path)
|
880
|
-
end
|
881
|
-
build_rake_in do
|
882
|
-
installer.install
|
883
|
-
end
|
884
|
-
assert self.class.plugin_loaded, "plugin is not loaded"
|
885
|
-
assert self.class.post_install_is_called,
|
886
|
-
"post install hook registered by plugin is not called"
|
887
|
-
|
888
|
-
self.class.plugin_loaded = false
|
889
|
-
$LOADED_FEATURES.delete(plugin_path)
|
890
|
-
installer_new = util_setup_installer do |spec_new|
|
891
|
-
spec_new.version = spec_version.version.succ
|
892
|
-
plugin_path = File.join("lib", "rubygems_plugin.rb")
|
893
|
-
write_file File.join(@tempdir, plugin_path) do |io|
|
894
|
-
io.write "#{self.class}.plugin_loaded = true"
|
895
|
-
end
|
896
|
-
spec_new.files += [plugin_path]
|
897
|
-
end
|
898
|
-
build_rake_in do
|
899
|
-
installer_new.install
|
900
|
-
end
|
901
|
-
assert !self.class.plugin_loaded,
|
902
|
-
"plugin is loaded even when old version is already loaded"
|
903
|
-
end
|
904
|
-
|
905
|
-
def test_keeps_plugins_up_to_date
|
906
|
-
# NOTE: version a-2 is already installed by setup hooks
|
907
|
-
|
908
|
-
write_file File.join(@tempdir, "lib", "rubygems_plugin.rb") do |io|
|
909
|
-
io.write "# do nothing"
|
910
|
-
end
|
911
|
-
|
912
|
-
build_rake_in do
|
913
|
-
util_setup_installer do |spec|
|
914
|
-
spec.version = "1"
|
915
|
-
spec.files += %w[lib/rubygems_plugin.rb]
|
916
|
-
end.install
|
917
|
-
|
918
|
-
plugin_path = File.join Gem.plugindir, "a_plugin.rb"
|
919
|
-
refute File.exist?(plugin_path), "old version installed while newer version without plugin also installed, but plugin written"
|
920
|
-
|
921
|
-
util_setup_installer do |spec|
|
922
|
-
spec.version = "2"
|
923
|
-
spec.files += %w[lib/rubygems_plugin.rb]
|
924
|
-
end.install
|
925
|
-
|
926
|
-
plugin_path = File.join Gem.plugindir, "a_plugin.rb"
|
927
|
-
assert File.exist?(plugin_path), "latest version reinstalled, but plugin not written"
|
928
|
-
assert_match %r{\Arequire.*a-2/lib/rubygems_plugin\.rb}, File.read(plugin_path), "written plugin has incorrect content"
|
929
|
-
|
930
|
-
util_setup_installer do |spec|
|
931
|
-
spec.version = "3"
|
932
|
-
spec.files += %w[lib/rubygems_plugin.rb]
|
933
|
-
end.install
|
934
|
-
|
935
|
-
plugin_path = File.join Gem.plugindir, "a_plugin.rb"
|
936
|
-
assert File.exist?(plugin_path), "latest version installed, but plugin removed"
|
937
|
-
assert_match %r{\Arequire.*a-3/lib/rubygems_plugin\.rb}, File.read(plugin_path), "written plugin has incorrect content"
|
938
|
-
|
939
|
-
util_setup_installer do |spec|
|
940
|
-
spec.version = "4"
|
941
|
-
end.install
|
942
|
-
|
943
|
-
refute File.exist?(plugin_path), "new version installed without a plugin while older version with a plugin installed, but plugin not removed"
|
944
|
-
end
|
945
|
-
end
|
946
|
-
|
947
|
-
def test_generates_plugins_dir_under_install_dir_if_not_there
|
948
|
-
Gem.use_paths "#{@gemhome}2" # Set GEM_HOME to an uninitialized repo
|
949
|
-
|
950
|
-
@spec = util_spec "a"
|
951
|
-
|
952
|
-
path = Gem::Package.build @spec
|
953
|
-
|
954
|
-
installer = Gem::Installer.at path, :install_dir => "#{@gemhome}3"
|
955
|
-
assert_equal @spec, installer.install
|
956
|
-
end
|
957
|
-
|
958
|
-
def test_initialize
|
959
|
-
spec = util_spec "a" do |s|
|
960
|
-
s.platform = Gem::Platform.new "mswin32"
|
961
|
-
end
|
962
|
-
|
963
|
-
gem = File.join @tempdir, spec.file_name
|
964
|
-
|
965
|
-
Dir.mkdir util_inst_bindir
|
966
|
-
util_build_gem spec
|
967
|
-
FileUtils.mv spec.cache_file, @tempdir
|
968
|
-
|
969
|
-
installer = Gem::Installer.at gem
|
970
|
-
|
971
|
-
assert_equal File.join(@gemhome, "gems", spec.full_name), installer.gem_dir
|
972
|
-
assert_equal File.join(@gemhome, "bin"), installer.bin_dir
|
973
|
-
end
|
974
|
-
|
975
|
-
def test_initialize_user_install
|
976
|
-
@gem = setup_base_gem
|
977
|
-
|
978
|
-
installer = Gem::Installer.at @gem, :user_install => true
|
979
|
-
|
980
|
-
assert_equal File.join(Gem.user_dir, "gems", @spec.full_name),
|
981
|
-
installer.gem_dir
|
982
|
-
assert_equal Gem.bindir(Gem.user_dir), installer.bin_dir
|
983
|
-
end
|
984
|
-
|
985
|
-
def test_initialize_user_install_bin_dir
|
986
|
-
@gem = setup_base_gem
|
987
|
-
|
988
|
-
installer =
|
989
|
-
Gem::Installer.at @gem, :user_install => true, :bin_dir => @tempdir
|
990
|
-
|
991
|
-
assert_equal File.join(Gem.user_dir, "gems", @spec.full_name),
|
992
|
-
installer.gem_dir
|
993
|
-
assert_equal @tempdir, installer.bin_dir
|
994
|
-
end
|
995
|
-
|
996
|
-
def test_install
|
997
|
-
installer = util_setup_installer
|
998
|
-
|
999
|
-
gemdir = File.join @gemhome, "gems", @spec.full_name
|
1000
|
-
cache_file = File.join @gemhome, "cache", @spec.file_name
|
1001
|
-
stub_exe = File.join @gemhome, "bin", "executable"
|
1002
|
-
rakefile = File.join gemdir, "ext", "a", "Rakefile"
|
1003
|
-
spec_file = File.join @gemhome, "specifications", @spec.spec_name
|
1004
|
-
|
1005
|
-
Gem.pre_install do
|
1006
|
-
assert_path_not_exist cache_file, "cache file must not exist yet"
|
1007
|
-
true
|
1008
|
-
end
|
1009
|
-
|
1010
|
-
Gem.post_build do
|
1011
|
-
assert_path_exist gemdir, "gem install dir must exist"
|
1012
|
-
assert_path_exist rakefile, "gem executable must exist"
|
1013
|
-
assert_path_not_exist stub_exe, "gem executable must not exist"
|
1014
|
-
true
|
1015
|
-
end
|
1016
|
-
|
1017
|
-
Gem.post_install do
|
1018
|
-
assert_path_exist cache_file, "cache file must exist"
|
1019
|
-
end
|
1020
|
-
|
1021
|
-
@newspec = nil
|
1022
|
-
build_rake_in do
|
1023
|
-
use_ui @ui do
|
1024
|
-
@newspec = installer.install
|
1025
|
-
end
|
1026
|
-
end
|
1027
|
-
|
1028
|
-
assert_equal @spec, @newspec
|
1029
|
-
assert_path_exist gemdir
|
1030
|
-
assert_path_exist stub_exe, "gem executable must exist"
|
1031
|
-
|
1032
|
-
exe = File.join gemdir, "bin", "executable"
|
1033
|
-
assert_path_exist exe
|
1034
|
-
|
1035
|
-
exe_mode = File.stat(exe).mode & 0o111
|
1036
|
-
assert_equal 0o111, exe_mode, "0%o" % exe_mode unless win_platform?
|
1037
|
-
|
1038
|
-
assert_path_exist File.join gemdir, "lib", "code.rb"
|
1039
|
-
|
1040
|
-
assert_path_exist rakefile
|
1041
|
-
|
1042
|
-
assert_equal spec_file, @newspec.loaded_from
|
1043
|
-
assert_path_exist spec_file
|
1044
|
-
|
1045
|
-
assert_same installer, @post_build_hook_arg
|
1046
|
-
assert_same installer, @post_install_hook_arg
|
1047
|
-
assert_same installer, @pre_install_hook_arg
|
1048
|
-
end
|
1049
|
-
|
1050
|
-
def test_install_creates_working_binstub
|
1051
|
-
installer = util_setup_installer
|
1052
|
-
|
1053
|
-
installer.wrappers = true
|
1054
|
-
|
1055
|
-
gemdir = File.join @gemhome, "gems", @spec.full_name
|
1056
|
-
|
1057
|
-
@newspec = nil
|
1058
|
-
build_rake_in do
|
1059
|
-
use_ui @ui do
|
1060
|
-
@newspec = installer.install
|
1061
|
-
end
|
1062
|
-
end
|
1063
|
-
|
1064
|
-
exe = File.join gemdir, "bin", "executable"
|
1065
|
-
|
1066
|
-
e = assert_raise RuntimeError do
|
1067
|
-
instance_eval File.read(exe)
|
1068
|
-
end
|
1069
|
-
|
1070
|
-
assert_match(/ran executable/, e.message)
|
1071
|
-
end
|
1072
|
-
|
1073
|
-
def test_conflicting_binstubs
|
1074
|
-
@gem = setup_base_gem
|
1075
|
-
|
1076
|
-
# build old version that has a bin file
|
1077
|
-
installer = util_setup_gem do |spec|
|
1078
|
-
File.open File.join("bin", "executable"), "w" do |f|
|
1079
|
-
f.puts "require 'code'"
|
1080
|
-
end
|
1081
|
-
File.open File.join("lib", "code.rb"), "w" do |f|
|
1082
|
-
f.puts 'raise "I have an executable"'
|
1083
|
-
end
|
1084
|
-
end
|
1085
|
-
|
1086
|
-
installer.wrappers = true
|
1087
|
-
build_rake_in do
|
1088
|
-
use_ui @ui do
|
1089
|
-
@newspec = installer.install
|
1090
|
-
end
|
1091
|
-
end
|
1092
|
-
|
1093
|
-
old_bin_file = File.join installer.bin_dir, "executable"
|
1094
|
-
|
1095
|
-
# build new version that doesn't have a bin file
|
1096
|
-
installer = util_setup_gem do |spec|
|
1097
|
-
FileUtils.rm File.join("bin", "executable")
|
1098
|
-
spec.files.delete File.join("bin", "executable")
|
1099
|
-
spec.executables.delete "executable"
|
1100
|
-
spec.version = @spec.version.bump
|
1101
|
-
File.open File.join("lib", "code.rb"), "w" do |f|
|
1102
|
-
f.puts 'raise "I do not have an executable"'
|
1103
|
-
end
|
1104
|
-
end
|
1105
|
-
|
1106
|
-
build_rake_in do
|
1107
|
-
use_ui @ui do
|
1108
|
-
@newspec = installer.install
|
1109
|
-
end
|
1110
|
-
end
|
1111
|
-
|
1112
|
-
e = assert_raise RuntimeError do
|
1113
|
-
instance_eval File.read(old_bin_file)
|
1114
|
-
end
|
1115
|
-
|
1116
|
-
# We expect the bin stub to activate the version that actually contains
|
1117
|
-
# the binstub.
|
1118
|
-
assert_match("I have an executable", e.message)
|
1119
|
-
end
|
1120
|
-
|
1121
|
-
def test_install_creates_binstub_that_understand_version
|
1122
|
-
installer = util_setup_installer
|
1123
|
-
|
1124
|
-
installer.wrappers = true
|
1125
|
-
|
1126
|
-
@newspec = nil
|
1127
|
-
build_rake_in do
|
1128
|
-
use_ui @ui do
|
1129
|
-
@newspec = installer.install
|
1130
|
-
end
|
1131
|
-
end
|
1132
|
-
|
1133
|
-
exe = File.join @gemhome, "bin", "executable"
|
1134
|
-
|
1135
|
-
ARGV.unshift "_3.0_"
|
1136
|
-
|
1137
|
-
begin
|
1138
|
-
Gem::Specification.reset
|
1139
|
-
|
1140
|
-
e = assert_raise Gem::GemNotFoundException do
|
1141
|
-
instance_eval File.read(exe)
|
1142
|
-
end
|
1143
|
-
ensure
|
1144
|
-
ARGV.shift if ARGV.first == "_3.0_"
|
1145
|
-
end
|
1146
|
-
|
1147
|
-
assert_includes(e.message, "can't find gem a (= 3.0)")
|
1148
|
-
end
|
1149
|
-
|
1150
|
-
def test_install_creates_binstub_that_prefers_user_installed_gem_to_default
|
1151
|
-
default_spec = new_default_spec("default", "2", nil, "exe/executable")
|
1152
|
-
default_spec.executables = "executable"
|
1153
|
-
install_default_gems default_spec
|
1154
|
-
|
1155
|
-
exe = File.join @gemhome, "bin", "executable"
|
1156
|
-
|
1157
|
-
assert_path_exist exe, "default gem's executable not installed"
|
1158
|
-
|
1159
|
-
installer = util_setup_installer do |spec|
|
1160
|
-
spec.name = "default"
|
1161
|
-
spec.version = "2"
|
1162
|
-
end
|
1163
|
-
|
1164
|
-
util_clear_gems
|
1165
|
-
|
1166
|
-
installer.wrappers = true
|
1167
|
-
|
1168
|
-
@newspec = nil
|
1169
|
-
build_rake_in do
|
1170
|
-
use_ui @ui do
|
1171
|
-
@newspec = installer.install
|
1172
|
-
end
|
1173
|
-
end
|
1174
|
-
|
1175
|
-
e = assert_raise RuntimeError do
|
1176
|
-
instance_eval File.read(exe)
|
1177
|
-
end
|
1178
|
-
|
1179
|
-
assert_equal(e.message, "ran executable")
|
1180
|
-
end
|
1181
|
-
|
1182
|
-
def test_install_creates_binstub_that_dont_trust_encoding
|
1183
|
-
installer = util_setup_installer
|
1184
|
-
|
1185
|
-
installer.wrappers = true
|
1186
|
-
|
1187
|
-
@newspec = nil
|
1188
|
-
build_rake_in do
|
1189
|
-
use_ui @ui do
|
1190
|
-
@newspec = installer.install
|
1191
|
-
end
|
1192
|
-
end
|
1193
|
-
|
1194
|
-
exe = File.join @gemhome, "bin", "executable"
|
1195
|
-
|
1196
|
-
extra_arg = "\xE4pfel".dup.force_encoding("UTF-8")
|
1197
|
-
ARGV.unshift extra_arg
|
1198
|
-
|
1199
|
-
begin
|
1200
|
-
Gem::Specification.reset
|
1201
|
-
|
1202
|
-
e = assert_raise RuntimeError do
|
1203
|
-
instance_eval File.read(exe)
|
1204
|
-
end
|
1205
|
-
ensure
|
1206
|
-
ARGV.shift if ARGV.first == extra_arg
|
1207
|
-
end
|
1208
|
-
|
1209
|
-
assert_match(/ran executable/, e.message)
|
1210
|
-
end
|
1211
|
-
|
1212
|
-
def test_install_with_no_prior_files
|
1213
|
-
installer = util_setup_installer
|
1214
|
-
|
1215
|
-
build_rake_in do
|
1216
|
-
use_ui @ui do
|
1217
|
-
assert_equal @spec, installer.install
|
1218
|
-
end
|
1219
|
-
end
|
1220
|
-
|
1221
|
-
gemdir = File.join(@gemhome, "gems", @spec.full_name)
|
1222
|
-
assert_path_exist File.join gemdir, "lib", "code.rb"
|
1223
|
-
|
1224
|
-
installer = util_setup_installer
|
1225
|
-
|
1226
|
-
# Morph spec to have lib/other.rb instead of code.rb and recreate
|
1227
|
-
@spec.files = File.join("lib", "other.rb")
|
1228
|
-
Dir.chdir @tempdir do
|
1229
|
-
File.open File.join("lib", "other.rb"), "w" do |f|
|
1230
|
-
f.puts "1"
|
1231
|
-
end
|
1232
|
-
|
1233
|
-
use_ui ui do
|
1234
|
-
FileUtils.rm @gem
|
1235
|
-
Gem::Package.build @spec
|
1236
|
-
end
|
1237
|
-
end
|
1238
|
-
installer = Gem::Installer.at @gem, :force => true
|
1239
|
-
build_rake_in do
|
1240
|
-
use_ui @ui do
|
1241
|
-
assert_equal @spec, installer.install
|
1242
|
-
end
|
1243
|
-
end
|
1244
|
-
|
1245
|
-
assert_path_exist File.join gemdir, "lib", "other.rb"
|
1246
|
-
assert_path_not_exist File.join gemdir, "lib", "code.rb",
|
1247
|
-
"code.rb from prior install of same gem shouldn't remain here"
|
1248
|
-
end
|
1249
|
-
|
1250
|
-
def test_install_force
|
1251
|
-
_, missing_dep_gem = util_gem "missing_dep", "1" do |s|
|
1252
|
-
s.add_dependency "doesnt_exist", "1"
|
1253
|
-
end
|
1254
|
-
|
1255
|
-
use_ui @ui do
|
1256
|
-
installer = Gem::Installer.at missing_dep_gem, :force => true
|
1257
|
-
installer.install
|
1258
|
-
end
|
1259
|
-
|
1260
|
-
gem_dir = File.join(@gemhome, "gems", "missing_dep-1")
|
1261
|
-
assert_path_exist gem_dir
|
1262
|
-
end
|
1263
|
-
|
1264
|
-
def test_install_build_root
|
1265
|
-
build_root = File.join(@tempdir, "build_root")
|
1266
|
-
|
1267
|
-
@gem = setup_base_gem
|
1268
|
-
installer = Gem::Installer.at @gem, :build_root => build_root
|
1269
|
-
|
1270
|
-
assert_equal @spec, installer.install
|
1271
|
-
end
|
1272
|
-
|
1273
|
-
def test_install_missing_dirs
|
1274
|
-
installer = setup_base_installer
|
1275
|
-
|
1276
|
-
FileUtils.rm_rf File.join(Gem.dir, "doc")
|
1277
|
-
FileUtils.rm_rf File.join(Gem.dir, "specifications")
|
1278
|
-
|
1279
|
-
use_ui @ui do
|
1280
|
-
installer.install
|
1281
|
-
end
|
1282
|
-
|
1283
|
-
assert_directory_exists File.join(Gem.dir, "doc")
|
1284
|
-
assert_directory_exists File.join(Gem.dir, "specifications")
|
1285
|
-
|
1286
|
-
assert_path_exist File.join @gemhome, "cache", @spec.file_name
|
1287
|
-
assert_path_exist File.join @gemhome, "specifications", @spec.spec_name
|
1288
|
-
end
|
1289
|
-
|
1290
|
-
def test_install_post_build_false
|
1291
|
-
@spec = util_spec "a"
|
1292
|
-
|
1293
|
-
util_build_gem @spec
|
1294
|
-
|
1295
|
-
installer = util_installer @spec, @gemhome
|
1296
|
-
|
1297
|
-
Gem.post_build do
|
1298
|
-
false
|
1299
|
-
end
|
1300
|
-
|
1301
|
-
use_ui @ui do
|
1302
|
-
e = assert_raise Gem::InstallError do
|
1303
|
-
installer.install
|
1304
|
-
end
|
1305
|
-
|
1306
|
-
location = "#{__FILE__}:#{__LINE__ - 9}"
|
1307
|
-
|
1308
|
-
assert_equal "post-build hook at #{location} failed for a-2", e.message
|
1309
|
-
end
|
1310
|
-
|
1311
|
-
spec_file = File.join @gemhome, "specifications", @spec.spec_name
|
1312
|
-
assert_path_not_exist spec_file
|
1313
|
-
|
1314
|
-
gem_dir = File.join @gemhome, "gems", @spec.full_name
|
1315
|
-
assert_path_not_exist gem_dir
|
1316
|
-
end
|
1317
|
-
|
1318
|
-
def test_install_post_build_nil
|
1319
|
-
installer = setup_base_installer
|
1320
|
-
|
1321
|
-
Gem.post_build do
|
1322
|
-
nil
|
1323
|
-
end
|
1324
|
-
|
1325
|
-
use_ui @ui do
|
1326
|
-
installer.install
|
1327
|
-
end
|
1328
|
-
|
1329
|
-
spec_file = File.join @gemhome, "specifications", @spec.spec_name
|
1330
|
-
assert_path_exist spec_file
|
1331
|
-
|
1332
|
-
gem_dir = File.join @gemhome, "gems", @spec.full_name
|
1333
|
-
assert_path_exist gem_dir
|
1334
|
-
end
|
1335
|
-
|
1336
|
-
def test_install_pre_install_false
|
1337
|
-
@spec = util_spec "a"
|
1338
|
-
|
1339
|
-
util_build_gem @spec
|
1340
|
-
|
1341
|
-
installer = util_installer @spec, @gemhome
|
1342
|
-
|
1343
|
-
Gem.pre_install do
|
1344
|
-
false
|
1345
|
-
end
|
1346
|
-
|
1347
|
-
use_ui @ui do
|
1348
|
-
e = assert_raise Gem::InstallError do
|
1349
|
-
installer.install
|
1350
|
-
end
|
1351
|
-
|
1352
|
-
location = "#{__FILE__}:#{__LINE__ - 9}"
|
1353
|
-
|
1354
|
-
assert_equal "pre-install hook at #{location} failed for a-2", e.message
|
1355
|
-
end
|
1356
|
-
|
1357
|
-
spec_file = File.join @gemhome, "specifications", @spec.spec_name
|
1358
|
-
assert_path_not_exist spec_file
|
1359
|
-
end
|
1360
|
-
|
1361
|
-
def test_install_pre_install_nil
|
1362
|
-
installer = setup_base_installer
|
1363
|
-
|
1364
|
-
Gem.pre_install do
|
1365
|
-
nil
|
1366
|
-
end
|
1367
|
-
|
1368
|
-
use_ui @ui do
|
1369
|
-
installer.install
|
1370
|
-
end
|
1371
|
-
|
1372
|
-
spec_file = File.join @gemhome, "specifications", @spec.spec_name
|
1373
|
-
assert_path_exist spec_file
|
1374
|
-
end
|
1375
|
-
|
1376
|
-
def test_install_with_message
|
1377
|
-
@spec = setup_base_spec
|
1378
|
-
@spec.post_install_message = "I am a shiny gem!"
|
1379
|
-
|
1380
|
-
use_ui @ui do
|
1381
|
-
path = Gem::Package.build @spec
|
1382
|
-
|
1383
|
-
installer = Gem::Installer.at path
|
1384
|
-
installer.install
|
1385
|
-
end
|
1386
|
-
|
1387
|
-
assert_match %r{I am a shiny gem!}, @ui.output
|
1388
|
-
end
|
1389
|
-
|
1390
|
-
def test_install_with_skipped_message
|
1391
|
-
@spec = setup_base_spec
|
1392
|
-
@spec.post_install_message = "I am a shiny gem!"
|
1393
|
-
|
1394
|
-
use_ui @ui do
|
1395
|
-
path = Gem::Package.build @spec
|
1396
|
-
|
1397
|
-
installer = Gem::Installer.at path, :post_install_message => false
|
1398
|
-
installer.install
|
1399
|
-
end
|
1400
|
-
|
1401
|
-
refute_match %r{I am a shiny gem!}, @ui.output
|
1402
|
-
end
|
1403
|
-
|
1404
|
-
def test_install_extension_dir
|
1405
|
-
gemhome2 = "#{@gemhome}2"
|
1406
|
-
|
1407
|
-
@spec = setup_base_spec
|
1408
|
-
@spec.extensions << "extconf.rb"
|
1409
|
-
write_file File.join(@tempdir, "extconf.rb") do |io|
|
1410
|
-
io.write <<-RUBY
|
1411
|
-
require "mkmf"
|
1412
|
-
create_makefile("#{@spec.name}")
|
1413
|
-
RUBY
|
1414
|
-
end
|
1415
|
-
|
1416
|
-
@spec.files += %w[extconf.rb]
|
1417
|
-
|
1418
|
-
use_ui @ui do
|
1419
|
-
path = Gem::Package.build @spec
|
1420
|
-
|
1421
|
-
installer = Gem::Installer.at path, :install_dir => gemhome2
|
1422
|
-
installer.install
|
1423
|
-
end
|
1424
|
-
|
1425
|
-
expected_makefile = File.join gemhome2, "gems", @spec.full_name, "Makefile"
|
1426
|
-
|
1427
|
-
assert_path_exist expected_makefile
|
1428
|
-
end
|
1429
|
-
|
1430
|
-
def test_install_extension_dir_is_removed_on_reinstall
|
1431
|
-
@spec = setup_base_spec
|
1432
|
-
|
1433
|
-
@spec.extensions << "extconf.rb"
|
1434
|
-
write_file File.join(@tempdir, "extconf.rb") do |io|
|
1435
|
-
io.write <<-RUBY
|
1436
|
-
require "mkmf"
|
1437
|
-
create_makefile("#{@spec.name}")
|
1438
|
-
RUBY
|
1439
|
-
end
|
1440
|
-
|
1441
|
-
@spec.files += %w[extconf.rb]
|
1442
|
-
|
1443
|
-
path = Gem::Package.build @spec
|
1444
|
-
|
1445
|
-
# Install a gem with an extension
|
1446
|
-
use_ui @ui do
|
1447
|
-
installer = Gem::Installer.at path
|
1448
|
-
installer.install
|
1449
|
-
end
|
1450
|
-
|
1451
|
-
# pretend that a binary file was created as part of the build
|
1452
|
-
should_be_removed = File.join(@spec.extension_dir, "#{@spec.name}.so")
|
1453
|
-
write_file should_be_removed do |io|
|
1454
|
-
io.write "DELETE ME ON REINSTALL"
|
1455
|
-
end
|
1456
|
-
assert_path_exist should_be_removed
|
1457
|
-
|
1458
|
-
# reinstall the gem, this is also the same as pristine
|
1459
|
-
use_ui @ui do
|
1460
|
-
installer = Gem::Installer.at path, :force => true
|
1461
|
-
installer.install
|
1462
|
-
end
|
1463
|
-
|
1464
|
-
assert_path_not_exist should_be_removed
|
1465
|
-
end
|
1466
|
-
|
1467
|
-
def test_install_user_extension_dir
|
1468
|
-
@spec = setup_base_spec
|
1469
|
-
@spec.extensions << "extconf.rb"
|
1470
|
-
write_file File.join(@tempdir, "extconf.rb") do |io|
|
1471
|
-
io.write <<-RUBY
|
1472
|
-
require "mkmf"
|
1473
|
-
create_makefile("#{@spec.name}")
|
1474
|
-
RUBY
|
1475
|
-
end
|
1476
|
-
|
1477
|
-
@spec.files += %w[extconf.rb]
|
1478
|
-
|
1479
|
-
# Create the non-user ext dir
|
1480
|
-
expected_extension_dir = @spec.extension_dir.dup
|
1481
|
-
FileUtils.mkdir_p expected_extension_dir
|
1482
|
-
|
1483
|
-
use_ui @ui do
|
1484
|
-
path = Gem::Package.build @spec
|
1485
|
-
|
1486
|
-
installer = Gem::Installer.at path, :user_install => true
|
1487
|
-
installer.install
|
1488
|
-
end
|
1489
|
-
|
1490
|
-
expected_makefile = File.join Gem.user_dir, "gems", @spec.full_name, "Makefile"
|
1491
|
-
|
1492
|
-
assert_path_exist expected_makefile
|
1493
|
-
assert_path_exist expected_extension_dir
|
1494
|
-
assert_path_not_exist File.join expected_extension_dir, "gem_make.out"
|
1495
|
-
end
|
1496
|
-
|
1497
|
-
def test_find_lib_file_after_install
|
1498
|
-
pend "extensions don't quite work on jruby" if Gem.java_platform?
|
1499
|
-
|
1500
|
-
@spec = setup_base_spec
|
1501
|
-
@spec.extensions << "extconf.rb"
|
1502
|
-
write_file File.join(@tempdir, "extconf.rb") do |io|
|
1503
|
-
io.write <<-RUBY
|
1504
|
-
require "mkmf"
|
1505
|
-
|
1506
|
-
CONFIG['CC'] = '$(TOUCH) $@ ||'
|
1507
|
-
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
|
1508
|
-
$ruby = '#{Gem.ruby}'
|
1509
|
-
|
1510
|
-
create_makefile("#{@spec.name}")
|
1511
|
-
RUBY
|
1512
|
-
end
|
1513
|
-
|
1514
|
-
write_file File.join(@tempdir, "depend")
|
1515
|
-
|
1516
|
-
write_file File.join(@tempdir, "a.c") do |io|
|
1517
|
-
io.write <<-C
|
1518
|
-
#include <ruby.h>
|
1519
|
-
void Init_a() { }
|
1520
|
-
C
|
1521
|
-
end
|
1522
|
-
|
1523
|
-
Dir.mkdir File.join(@tempdir, "lib")
|
1524
|
-
write_file File.join(@tempdir, "lib", "b.rb") do |io|
|
1525
|
-
io.write "# b.rb"
|
1526
|
-
end
|
1527
|
-
|
1528
|
-
@spec.files += %w[extconf.rb lib/b.rb depend a.c]
|
1529
|
-
|
1530
|
-
use_ui @ui do
|
1531
|
-
path = Gem::Package.build @spec
|
1532
|
-
|
1533
|
-
installer = Gem::Installer.at path
|
1534
|
-
installer.install
|
1535
|
-
end
|
1536
|
-
|
1537
|
-
expected = File.join @spec.full_require_paths.find {|path|
|
1538
|
-
File.exist? File.join path, "b.rb"
|
1539
|
-
}, "b.rb"
|
1540
|
-
assert_equal expected, @spec.matches_for_glob("b.rb").first
|
1541
|
-
end
|
1542
|
-
|
1543
|
-
def test_install_extension_and_script
|
1544
|
-
pend "Makefile creation crashes on jruby" if Gem.java_platform?
|
1545
|
-
pend "terminates on mswin" if vc_windows? && ruby_repo?
|
1546
|
-
|
1547
|
-
@spec = setup_base_spec
|
1548
|
-
@spec.extensions << "extconf.rb"
|
1549
|
-
write_file File.join(@tempdir, "extconf.rb") do |io|
|
1550
|
-
io.write <<-RUBY
|
1551
|
-
require "mkmf"
|
1552
|
-
create_makefile("#{@spec.name}")
|
1553
|
-
RUBY
|
1554
|
-
end
|
1555
|
-
|
1556
|
-
rb = File.join("lib", "#{@spec.name}.rb")
|
1557
|
-
@spec.files += [rb]
|
1558
|
-
write_file File.join(@tempdir, rb) do |io|
|
1559
|
-
io.write <<-RUBY
|
1560
|
-
# #{@spec.name}.rb
|
1561
|
-
RUBY
|
1562
|
-
end
|
1563
|
-
|
1564
|
-
Dir.mkdir(File.join("lib", @spec.name))
|
1565
|
-
rb2 = File.join("lib", @spec.name, "#{@spec.name}.rb")
|
1566
|
-
@spec.files << rb2
|
1567
|
-
write_file File.join(@tempdir, rb2) do |io|
|
1568
|
-
io.write <<-RUBY
|
1569
|
-
# #{@spec.name}/#{@spec.name}.rb
|
1570
|
-
RUBY
|
1571
|
-
end
|
1572
|
-
|
1573
|
-
assert_path_not_exist File.join @spec.gem_dir, rb
|
1574
|
-
assert_path_not_exist File.join @spec.gem_dir, rb2
|
1575
|
-
use_ui @ui do
|
1576
|
-
path = Gem::Package.build @spec
|
1577
|
-
|
1578
|
-
installer = Gem::Installer.at path
|
1579
|
-
installer.install
|
1580
|
-
end
|
1581
|
-
assert_path_exist File.join @spec.gem_dir, rb
|
1582
|
-
assert_path_exist File.join @spec.gem_dir, rb2
|
1583
|
-
end
|
1584
|
-
|
1585
|
-
def test_install_extension_flat
|
1586
|
-
pend "extensions don't quite work on jruby" if Gem.java_platform?
|
1587
|
-
|
1588
|
-
begin
|
1589
|
-
@spec = setup_base_spec
|
1590
|
-
@spec.require_paths = ["."]
|
1591
|
-
|
1592
|
-
@spec.extensions << "extconf.rb"
|
1593
|
-
|
1594
|
-
write_file File.join(@tempdir, "extconf.rb") do |io|
|
1595
|
-
io.write <<-RUBY
|
1596
|
-
require "mkmf"
|
1597
|
-
|
1598
|
-
CONFIG['CC'] = '$(TOUCH) $@ ||'
|
1599
|
-
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
|
1600
|
-
$ruby = '#{Gem.ruby}'
|
1601
|
-
|
1602
|
-
create_makefile("#{@spec.name}")
|
1603
|
-
RUBY
|
1604
|
-
end
|
1605
|
-
|
1606
|
-
# empty depend file for no auto dependencies
|
1607
|
-
@spec.files += %W[depend #{@spec.name}.c].each do |file|
|
1608
|
-
write_file File.join(@tempdir, file)
|
1609
|
-
end
|
1610
|
-
|
1611
|
-
so = File.join(@spec.extension_dir, "#{@spec.name}.#{RbConfig::CONFIG["DLEXT"]}")
|
1612
|
-
assert_path_not_exist so
|
1613
|
-
use_ui @ui do
|
1614
|
-
path = Gem::Package.build @spec
|
1615
|
-
|
1616
|
-
installer = Gem::Installer.at path
|
1617
|
-
installer.install
|
1618
|
-
end
|
1619
|
-
assert_path_exist so
|
1620
|
-
rescue StandardError
|
1621
|
-
puts "-" * 78
|
1622
|
-
puts File.read File.join(@gemhome, "gems", "a-2", "Makefile")
|
1623
|
-
puts "-" * 78
|
1624
|
-
|
1625
|
-
path = File.join(@gemhome, "gems", "a-2", "gem_make.out")
|
1626
|
-
|
1627
|
-
if File.exist?(path)
|
1628
|
-
puts File.read(path)
|
1629
|
-
puts "-" * 78
|
1630
|
-
end
|
1631
|
-
|
1632
|
-
raise
|
1633
|
-
end
|
1634
|
-
end
|
1635
|
-
|
1636
|
-
def test_install_extension_clean_intermediate_files
|
1637
|
-
pend "extensions don't quite work on jruby" if Gem.java_platform?
|
1638
|
-
@spec = setup_base_spec
|
1639
|
-
@spec.require_paths = ["."]
|
1640
|
-
@spec.extensions << "extconf.rb"
|
1641
|
-
|
1642
|
-
File.write File.join(@tempdir, "extconf.rb"), <<-RUBY
|
1643
|
-
require "mkmf"
|
1644
|
-
CONFIG['CC'] = '$(TOUCH) $@ ||'
|
1645
|
-
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
|
1646
|
-
$ruby = '#{Gem.ruby}'
|
1647
|
-
create_makefile("#{@spec.name}")
|
1648
|
-
RUBY
|
1649
|
-
|
1650
|
-
# empty depend file for no auto dependencies
|
1651
|
-
@spec.files += %W[depend #{@spec.name}.c].each do |file|
|
1652
|
-
write_file File.join(@tempdir, file)
|
1653
|
-
end
|
1654
|
-
|
1655
|
-
shared_object = "#{@spec.name}.#{RbConfig::CONFIG["DLEXT"]}"
|
1656
|
-
extension_file = File.join @spec.extension_dir, shared_object
|
1657
|
-
intermediate_file = File.join @spec.gem_dir, shared_object
|
1658
|
-
|
1659
|
-
assert_path_not_exist extension_file, "no before installing"
|
1660
|
-
use_ui @ui do
|
1661
|
-
path = Gem::Package.build @spec
|
1662
|
-
|
1663
|
-
installer = Gem::Installer.at path
|
1664
|
-
installer.install
|
1665
|
-
end
|
1666
|
-
|
1667
|
-
assert_path_exist extension_file, "installed"
|
1668
|
-
assert_path_not_exist intermediate_file
|
1669
|
-
end
|
1670
|
-
|
1671
|
-
def test_installation_satisfies_dependency_eh
|
1672
|
-
installer = setup_base_installer
|
1673
|
-
|
1674
|
-
util_spec "a"
|
1675
|
-
|
1676
|
-
dep = Gem::Dependency.new "a", ">= 2"
|
1677
|
-
assert installer.installation_satisfies_dependency?(dep)
|
1678
|
-
|
1679
|
-
dep = Gem::Dependency.new "a", "> 2"
|
1680
|
-
refute installer.installation_satisfies_dependency?(dep)
|
1681
|
-
end
|
1682
|
-
|
1683
|
-
def test_installation_satisfies_dependency_eh_development
|
1684
|
-
installer = setup_base_installer
|
1685
|
-
installer.options[:development] = true
|
1686
|
-
installer.options[:dev_shallow] = true
|
1687
|
-
|
1688
|
-
util_spec "a"
|
1689
|
-
|
1690
|
-
dep = Gem::Dependency.new "a", :development
|
1691
|
-
assert installer.installation_satisfies_dependency?(dep)
|
1692
|
-
end
|
1693
|
-
|
1694
|
-
def test_pre_install_checks_dependencies
|
1695
|
-
installer = setup_base_installer
|
1696
|
-
@spec.add_dependency "b", "> 5"
|
1697
|
-
installer = util_setup_gem
|
1698
|
-
installer.force = false
|
1699
|
-
|
1700
|
-
use_ui @ui do
|
1701
|
-
assert_raise Gem::InstallError do
|
1702
|
-
installer.install
|
1703
|
-
end
|
1704
|
-
end
|
1705
|
-
end
|
1706
|
-
|
1707
|
-
def test_pre_install_checks_dependencies_ignore
|
1708
|
-
installer = util_setup_installer
|
1709
|
-
@spec.add_dependency "b", "> 5"
|
1710
|
-
installer.ignore_dependencies = true
|
1711
|
-
|
1712
|
-
build_rake_in do
|
1713
|
-
use_ui @ui do
|
1714
|
-
assert installer.pre_install_checks
|
1715
|
-
end
|
1716
|
-
end
|
1717
|
-
end
|
1718
|
-
|
1719
|
-
def test_pre_install_checks_dependencies_install_dir
|
1720
|
-
gemhome2 = "#{@gemhome}2"
|
1721
|
-
|
1722
|
-
@gem = setup_base_gem
|
1723
|
-
@spec.add_dependency "d"
|
1724
|
-
|
1725
|
-
quick_gem "d", 2
|
1726
|
-
|
1727
|
-
gem = File.join @gemhome, @spec.file_name
|
1728
|
-
|
1729
|
-
FileUtils.mv @gemhome, gemhome2
|
1730
|
-
FileUtils.mkdir @gemhome
|
1731
|
-
|
1732
|
-
FileUtils.mv File.join(gemhome2, "cache", @spec.file_name), gem
|
1733
|
-
|
1734
|
-
# Don't leak any already activated gems into the installer, require
|
1735
|
-
# that it work everything out on it's own.
|
1736
|
-
Gem::Specification.reset
|
1737
|
-
|
1738
|
-
installer = Gem::Installer.at gem, :install_dir => gemhome2
|
1739
|
-
|
1740
|
-
build_rake_in do
|
1741
|
-
use_ui @ui do
|
1742
|
-
assert installer.pre_install_checks
|
1743
|
-
end
|
1744
|
-
end
|
1745
|
-
end
|
1746
|
-
|
1747
|
-
def test_pre_install_checks_malicious_name
|
1748
|
-
spec = util_spec "../malicious", "1"
|
1749
|
-
def spec.full_name # so the spec is buildable
|
1750
|
-
"malicious-1"
|
1751
|
-
end
|
1752
|
-
def spec.validate(packaging, strict); end
|
1753
|
-
|
1754
|
-
util_build_gem spec
|
1755
|
-
|
1756
|
-
gem = File.join(@gemhome, "cache", spec.file_name)
|
1757
|
-
|
1758
|
-
use_ui @ui do
|
1759
|
-
installer = Gem::Installer.at gem
|
1760
|
-
e = assert_raise Gem::InstallError do
|
1761
|
-
installer.pre_install_checks
|
1762
|
-
end
|
1763
|
-
assert_equal "#<Gem::Specification name=../malicious version=1> has an invalid name", e.message
|
1764
|
-
end
|
1765
|
-
end
|
1766
|
-
|
1767
|
-
def test_pre_install_checks_malicious_name_before_eval
|
1768
|
-
spec = util_spec "malicious\n::Object.const_set(:FROM_EVAL, true)#", "1"
|
1769
|
-
def spec.full_name # so the spec is buildable
|
1770
|
-
"malicious-1"
|
1771
|
-
end
|
1772
|
-
def spec.validate(*args); end
|
1773
|
-
|
1774
|
-
util_build_gem spec
|
1775
|
-
|
1776
|
-
gem = File.join(@gemhome, "cache", spec.file_name)
|
1777
|
-
|
1778
|
-
use_ui @ui do
|
1779
|
-
installer = Gem::Installer.at gem
|
1780
|
-
e = assert_raise Gem::InstallError do
|
1781
|
-
installer.pre_install_checks
|
1782
|
-
end
|
1783
|
-
assert_equal "#<Gem::Specification name=malicious\n::Object.const_set(:FROM_EVAL, true)# version=1> has an invalid name", e.message
|
1784
|
-
end
|
1785
|
-
refute defined?(::Object::FROM_EVAL)
|
1786
|
-
end
|
1787
|
-
|
1788
|
-
def test_pre_install_checks_malicious_require_paths_before_eval
|
1789
|
-
spec = util_spec "malicious", "1"
|
1790
|
-
def spec.full_name # so the spec is buildable
|
1791
|
-
"malicious-1"
|
1792
|
-
end
|
1793
|
-
def spec.validate(*args); end
|
1794
|
-
spec.require_paths = ["malicious\n``"]
|
1795
|
-
|
1796
|
-
util_build_gem spec
|
1797
|
-
|
1798
|
-
gem = File.join(@gemhome, "cache", spec.file_name)
|
1799
|
-
|
1800
|
-
use_ui @ui do
|
1801
|
-
installer = Gem::Installer.at gem
|
1802
|
-
e = assert_raise Gem::InstallError do
|
1803
|
-
installer.pre_install_checks
|
1804
|
-
end
|
1805
|
-
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid require_paths", e.message
|
1806
|
-
end
|
1807
|
-
end
|
1808
|
-
|
1809
|
-
def test_pre_install_checks_malicious_extensions_before_eval
|
1810
|
-
pend "mswin environment disallow to create file contained the carriage return code." if Gem.win_platform?
|
1811
|
-
|
1812
|
-
spec = util_spec "malicious", "1"
|
1813
|
-
def spec.full_name # so the spec is buildable
|
1814
|
-
"malicious-1"
|
1815
|
-
end
|
1816
|
-
def spec.validate(*args); end
|
1817
|
-
spec.extensions = ["malicious\n``"]
|
1818
|
-
|
1819
|
-
util_build_gem spec
|
1820
|
-
|
1821
|
-
gem = File.join(@gemhome, "cache", spec.file_name)
|
1822
|
-
|
1823
|
-
use_ui @ui do
|
1824
|
-
installer = Gem::Installer.at gem
|
1825
|
-
e = assert_raise Gem::InstallError do
|
1826
|
-
installer.pre_install_checks
|
1827
|
-
end
|
1828
|
-
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid extensions", e.message
|
1829
|
-
end
|
1830
|
-
end
|
1831
|
-
|
1832
|
-
def test_pre_install_checks_malicious_specification_version_before_eval
|
1833
|
-
spec = util_spec "malicious", "1"
|
1834
|
-
def spec.full_name # so the spec is buildable
|
1835
|
-
"malicious-1"
|
1836
|
-
end
|
1837
|
-
def spec.validate(*args); end
|
1838
|
-
spec.specification_version = "malicious\n``"
|
1839
|
-
|
1840
|
-
util_build_gem spec
|
1841
|
-
|
1842
|
-
gem = File.join(@gemhome, "cache", spec.file_name)
|
1843
|
-
|
1844
|
-
use_ui @ui do
|
1845
|
-
installer = Gem::Installer.at gem
|
1846
|
-
e = assert_raise Gem::InstallError do
|
1847
|
-
installer.pre_install_checks
|
1848
|
-
end
|
1849
|
-
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid specification_version", e.message
|
1850
|
-
end
|
1851
|
-
end
|
1852
|
-
|
1853
|
-
def test_pre_install_checks_malicious_dependencies_before_eval
|
1854
|
-
spec = util_spec "malicious", "1"
|
1855
|
-
def spec.full_name # so the spec is buildable
|
1856
|
-
"malicious-1"
|
1857
|
-
end
|
1858
|
-
def spec.validate(*args); end
|
1859
|
-
spec.add_dependency "b\nfoo", "> 5"
|
1860
|
-
|
1861
|
-
util_build_gem spec
|
1862
|
-
|
1863
|
-
gem = File.join(@gemhome, "cache", spec.file_name)
|
1864
|
-
|
1865
|
-
use_ui @ui do
|
1866
|
-
installer = Gem::Installer.at gem
|
1867
|
-
installer.ignore_dependencies = true
|
1868
|
-
e = assert_raise Gem::InstallError do
|
1869
|
-
installer.pre_install_checks
|
1870
|
-
end
|
1871
|
-
assert_equal "#<Gem::Specification name=malicious version=1> has an invalid dependencies", e.message
|
1872
|
-
end
|
1873
|
-
end
|
1874
|
-
|
1875
|
-
def test_pre_install_checks_malicious_platform_before_eval
|
1876
|
-
gem_with_ill_formated_platform = File.expand_path("packages/ill-formatted-platform-1.0.0.10.gem", __dir__)
|
1877
|
-
|
1878
|
-
installer = Gem::Installer.at(
|
1879
|
-
gem_with_ill_formated_platform,
|
1880
|
-
:install_dir => @gemhome,
|
1881
|
-
:user_install => false,
|
1882
|
-
:force => true
|
1883
|
-
)
|
1884
|
-
|
1885
|
-
use_ui @ui do
|
1886
|
-
e = assert_raise Gem::InstallError do
|
1887
|
-
installer.pre_install_checks
|
1888
|
-
end
|
1889
|
-
|
1890
|
-
assert_equal "x86-mswin32\n system('id > /tmp/nyangawa')# is an invalid platform", e.message
|
1891
|
-
assert_empty @ui.output
|
1892
|
-
end
|
1893
|
-
end
|
1894
|
-
|
1895
|
-
def test_shebang
|
1896
|
-
load_relative "no" do
|
1897
|
-
installer = setup_base_installer
|
1898
|
-
|
1899
|
-
util_make_exec @spec, "#!/usr/bin/ruby"
|
1900
|
-
|
1901
|
-
shebang = installer.shebang "executable"
|
1902
|
-
|
1903
|
-
assert_equal "#!#{Gem.ruby}", shebang
|
1904
|
-
end
|
1905
|
-
end
|
1906
|
-
|
1907
|
-
def test_process_options
|
1908
|
-
installer = setup_base_installer
|
1909
|
-
|
1910
|
-
assert_nil installer.build_root
|
1911
|
-
assert_equal File.join(@gemhome, "bin"), installer.bin_dir
|
1912
|
-
assert_equal @gemhome, installer.gem_home
|
1913
|
-
end
|
1914
|
-
|
1915
|
-
def test_process_options_build_root
|
1916
|
-
build_root = File.join @tempdir, "build_root"
|
1917
|
-
bin_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ""), "bin")
|
1918
|
-
gem_home = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ""))
|
1919
|
-
plugins_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ""), "plugins")
|
1920
|
-
|
1921
|
-
@gem = setup_base_gem
|
1922
|
-
installer = use_ui(@ui) { Gem::Installer.at @gem, :build_root => build_root }
|
1923
|
-
|
1924
|
-
assert_equal build_root, installer.build_root
|
1925
|
-
assert_equal bin_dir, installer.bin_dir
|
1926
|
-
assert_equal gem_home, installer.gem_home
|
1927
|
-
|
1928
|
-
errors = @ui.error.split("\n")
|
1929
|
-
|
1930
|
-
assert_equal "WARNING: You build with buildroot.", errors.shift
|
1931
|
-
assert_equal " Build root: #{build_root}", errors.shift
|
1932
|
-
assert_equal " Bin dir: #{bin_dir}", errors.shift
|
1933
|
-
assert_equal " Gem home: #{gem_home}", errors.shift
|
1934
|
-
assert_equal " Plugins dir: #{plugins_dir}", errors.shift
|
1935
|
-
end
|
1936
|
-
|
1937
|
-
def test_shebang_arguments
|
1938
|
-
load_relative "no" do
|
1939
|
-
installer = setup_base_installer
|
1940
|
-
|
1941
|
-
util_make_exec @spec, "#!/usr/bin/ruby -ws"
|
1942
|
-
|
1943
|
-
shebang = installer.shebang "executable"
|
1944
|
-
|
1945
|
-
assert_equal "#!#{Gem.ruby} -ws", shebang
|
1946
|
-
end
|
1947
|
-
end
|
1948
|
-
|
1949
|
-
def test_shebang_arguments_with_load_relative
|
1950
|
-
load_relative "yes" do
|
1951
|
-
installer = setup_base_installer
|
1952
|
-
|
1953
|
-
util_make_exec @spec, "#!/usr/bin/ruby -ws"
|
1954
|
-
|
1955
|
-
shebang = installer.shebang "executable"
|
1956
|
-
|
1957
|
-
shebang_lines = shebang.split "\n"
|
1958
|
-
|
1959
|
-
assert_equal "#!/bin/sh", shebang_lines.shift
|
1960
|
-
assert_includes shebang_lines, "#!#{Gem.ruby} -ws"
|
1961
|
-
end
|
1962
|
-
end
|
1963
|
-
|
1964
|
-
def test_shebang_empty
|
1965
|
-
load_relative "no" do
|
1966
|
-
installer = setup_base_installer
|
1967
|
-
|
1968
|
-
util_make_exec @spec, ""
|
1969
|
-
|
1970
|
-
shebang = installer.shebang "executable"
|
1971
|
-
assert_equal "#!#{Gem.ruby}", shebang
|
1972
|
-
end
|
1973
|
-
end
|
1974
|
-
|
1975
|
-
def test_shebang_env
|
1976
|
-
load_relative "no" do
|
1977
|
-
installer = setup_base_installer
|
1978
|
-
|
1979
|
-
util_make_exec @spec, "#!/usr/bin/env ruby"
|
1980
|
-
|
1981
|
-
shebang = installer.shebang "executable"
|
1982
|
-
|
1983
|
-
assert_equal "#!#{Gem.ruby}", shebang
|
1984
|
-
end
|
1985
|
-
end
|
1986
|
-
|
1987
|
-
def test_shebang_env_arguments
|
1988
|
-
load_relative "no" do
|
1989
|
-
installer = setup_base_installer
|
1990
|
-
|
1991
|
-
util_make_exec @spec, "#!/usr/bin/env ruby -ws"
|
1992
|
-
|
1993
|
-
shebang = installer.shebang "executable"
|
1994
|
-
|
1995
|
-
assert_equal "#!#{Gem.ruby} -ws", shebang
|
1996
|
-
end
|
1997
|
-
end
|
1998
|
-
|
1999
|
-
def test_shebang_env_arguments_with_load_relative
|
2000
|
-
load_relative "yes" do
|
2001
|
-
installer = setup_base_installer
|
2002
|
-
|
2003
|
-
util_make_exec @spec, "#!/usr/bin/env ruby -ws"
|
2004
|
-
|
2005
|
-
shebang = installer.shebang "executable"
|
2006
|
-
|
2007
|
-
shebang_lines = shebang.split "\n"
|
2008
|
-
|
2009
|
-
assert_equal "#!/bin/sh", shebang_lines.shift
|
2010
|
-
assert_includes shebang_lines, "#!#{Gem.ruby} -ws"
|
2011
|
-
end
|
2012
|
-
end
|
2013
|
-
|
2014
|
-
def test_shebang_env_shebang
|
2015
|
-
installer = setup_base_installer
|
2016
|
-
|
2017
|
-
util_make_exec @spec, ""
|
2018
|
-
installer.env_shebang = true
|
2019
|
-
|
2020
|
-
shebang = installer.shebang "executable"
|
2021
|
-
|
2022
|
-
bin_env = get_bin_env
|
2023
|
-
|
2024
|
-
assert_equal("#!#{bin_env} #{RbConfig::CONFIG["ruby_install_name"]}",
|
2025
|
-
shebang)
|
2026
|
-
end
|
2027
|
-
|
2028
|
-
def test_shebang_nested
|
2029
|
-
load_relative "no" do
|
2030
|
-
installer = setup_base_installer
|
2031
|
-
|
2032
|
-
util_make_exec @spec, "#!/opt/local/ruby/bin/ruby"
|
2033
|
-
|
2034
|
-
shebang = installer.shebang "executable"
|
2035
|
-
|
2036
|
-
assert_equal "#!#{Gem.ruby}", shebang
|
2037
|
-
end
|
2038
|
-
end
|
2039
|
-
|
2040
|
-
def test_shebang_nested_arguments
|
2041
|
-
load_relative "no" do
|
2042
|
-
installer = setup_base_installer
|
2043
|
-
|
2044
|
-
util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws"
|
2045
|
-
|
2046
|
-
shebang = installer.shebang "executable"
|
2047
|
-
|
2048
|
-
assert_equal "#!#{Gem.ruby} -ws", shebang
|
2049
|
-
end
|
2050
|
-
end
|
2051
|
-
|
2052
|
-
def test_shebang_nested_arguments_with_load_relative
|
2053
|
-
load_relative "yes" do
|
2054
|
-
installer = setup_base_installer
|
2055
|
-
|
2056
|
-
util_make_exec @spec, "#!/opt/local/ruby/bin/ruby -ws"
|
2057
|
-
|
2058
|
-
shebang = installer.shebang "executable"
|
2059
|
-
|
2060
|
-
shebang_lines = shebang.split "\n"
|
2061
|
-
|
2062
|
-
assert_equal "#!/bin/sh", shebang_lines.shift
|
2063
|
-
assert_includes shebang_lines, "#!#{Gem.ruby} -ws"
|
2064
|
-
end
|
2065
|
-
end
|
2066
|
-
|
2067
|
-
def test_shebang_version
|
2068
|
-
load_relative "no" do
|
2069
|
-
installer = setup_base_installer
|
2070
|
-
|
2071
|
-
util_make_exec @spec, "#!/usr/bin/ruby18"
|
2072
|
-
|
2073
|
-
shebang = installer.shebang "executable"
|
2074
|
-
|
2075
|
-
assert_equal "#!#{Gem.ruby}", shebang
|
2076
|
-
end
|
2077
|
-
end
|
2078
|
-
|
2079
|
-
def test_shebang_version_arguments
|
2080
|
-
load_relative "no" do
|
2081
|
-
installer = setup_base_installer
|
2082
|
-
|
2083
|
-
util_make_exec @spec, "#!/usr/bin/ruby18 -ws"
|
2084
|
-
|
2085
|
-
shebang = installer.shebang "executable"
|
2086
|
-
|
2087
|
-
assert_equal "#!#{Gem.ruby} -ws", shebang
|
2088
|
-
end
|
2089
|
-
end
|
2090
|
-
|
2091
|
-
def test_shebang_version_arguments_with_load_relative
|
2092
|
-
load_relative "yes" do
|
2093
|
-
installer = setup_base_installer
|
2094
|
-
|
2095
|
-
util_make_exec @spec, "#!/usr/bin/ruby18 -ws"
|
2096
|
-
|
2097
|
-
shebang = installer.shebang "executable"
|
2098
|
-
|
2099
|
-
shebang_lines = shebang.split "\n"
|
2100
|
-
|
2101
|
-
assert_equal "#!/bin/sh", shebang_lines.shift
|
2102
|
-
assert_includes shebang_lines, "#!#{Gem.ruby} -ws"
|
2103
|
-
end
|
2104
|
-
end
|
2105
|
-
|
2106
|
-
def test_shebang_version_env
|
2107
|
-
load_relative "no" do
|
2108
|
-
installer = setup_base_installer
|
2109
|
-
|
2110
|
-
util_make_exec @spec, "#!/usr/bin/env ruby18"
|
2111
|
-
|
2112
|
-
shebang = installer.shebang "executable"
|
2113
|
-
|
2114
|
-
assert_equal "#!#{Gem.ruby}", shebang
|
2115
|
-
end
|
2116
|
-
end
|
2117
|
-
|
2118
|
-
def test_shebang_version_env_arguments
|
2119
|
-
load_relative "no" do
|
2120
|
-
installer = setup_base_installer
|
2121
|
-
|
2122
|
-
util_make_exec @spec, "#!/usr/bin/env ruby18 -ws"
|
2123
|
-
|
2124
|
-
shebang = installer.shebang "executable"
|
2125
|
-
|
2126
|
-
assert_equal "#!#{Gem.ruby} -ws", shebang
|
2127
|
-
end
|
2128
|
-
end
|
2129
|
-
|
2130
|
-
def test_shebang_version_env_arguments_with_load_relative
|
2131
|
-
load_relative "yes" do
|
2132
|
-
installer = setup_base_installer
|
2133
|
-
|
2134
|
-
util_make_exec @spec, "#!/usr/bin/env ruby18 -ws"
|
2135
|
-
|
2136
|
-
shebang = installer.shebang "executable"
|
2137
|
-
|
2138
|
-
shebang_lines = shebang.split "\n"
|
2139
|
-
|
2140
|
-
assert_equal "#!/bin/sh", shebang_lines.shift
|
2141
|
-
assert_includes shebang_lines, "#!#{Gem.ruby} -ws"
|
2142
|
-
end
|
2143
|
-
end
|
2144
|
-
|
2145
|
-
def test_shebang_custom
|
2146
|
-
installer = setup_base_installer
|
2147
|
-
|
2148
|
-
conf = Gem::ConfigFile.new []
|
2149
|
-
conf[:custom_shebang] = "test"
|
2150
|
-
|
2151
|
-
Gem.configuration = conf
|
2152
|
-
|
2153
|
-
util_make_exec @spec, "#!/usr/bin/ruby"
|
2154
|
-
|
2155
|
-
shebang = installer.shebang "executable"
|
2156
|
-
|
2157
|
-
assert_equal "#!test", shebang
|
2158
|
-
end
|
2159
|
-
|
2160
|
-
def get_bin_env
|
2161
|
-
if win_platform?
|
2162
|
-
""
|
2163
|
-
else
|
2164
|
-
%w[/usr/bin/env /bin/env].find {|f| File.executable?(f) }
|
2165
|
-
end
|
2166
|
-
end
|
2167
|
-
|
2168
|
-
def test_shebang_custom_with_expands
|
2169
|
-
installer = setup_base_installer
|
2170
|
-
|
2171
|
-
bin_env = get_bin_env
|
2172
|
-
conf = Gem::ConfigFile.new []
|
2173
|
-
conf[:custom_shebang] = "1 $env 2 $ruby 3 $exec 4 $name"
|
2174
|
-
|
2175
|
-
Gem.configuration = conf
|
2176
|
-
|
2177
|
-
util_make_exec @spec, "#!/usr/bin/ruby"
|
2178
|
-
|
2179
|
-
shebang = installer.shebang "executable"
|
2180
|
-
|
2181
|
-
assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} 3 executable 4 a", shebang
|
2182
|
-
end
|
2183
|
-
|
2184
|
-
def test_shebang_custom_with_expands_and_arguments
|
2185
|
-
installer = setup_base_installer
|
2186
|
-
|
2187
|
-
bin_env = get_bin_env
|
2188
|
-
conf = Gem::ConfigFile.new []
|
2189
|
-
conf[:custom_shebang] = "1 $env 2 $ruby 3 $exec"
|
2190
|
-
|
2191
|
-
Gem.configuration = conf
|
2192
|
-
|
2193
|
-
util_make_exec @spec, "#!/usr/bin/ruby -ws"
|
2194
|
-
|
2195
|
-
shebang = installer.shebang "executable"
|
2196
|
-
|
2197
|
-
assert_equal "#!1 #{bin_env} 2 #{Gem.ruby} -ws 3 executable", shebang
|
2198
|
-
end
|
2199
|
-
|
2200
|
-
def test_unpack
|
2201
|
-
installer = util_setup_installer
|
2202
|
-
|
2203
|
-
dest = File.join @gemhome, "gems", @spec.full_name
|
2204
|
-
|
2205
|
-
Gem::Deprecate.skip_during do
|
2206
|
-
installer.unpack dest
|
2207
|
-
end
|
2208
|
-
|
2209
|
-
assert_path_exist File.join dest, "lib", "code.rb"
|
2210
|
-
assert_path_exist File.join dest, "bin", "executable"
|
2211
|
-
end
|
2212
|
-
|
2213
|
-
def test_write_build_info_file
|
2214
|
-
installer = setup_base_installer
|
2215
|
-
|
2216
|
-
assert_path_not_exist @spec.build_info_file
|
2217
|
-
|
2218
|
-
installer.build_args = %w[
|
2219
|
-
--with-libyaml-dir /usr/local/Cellar/libyaml/0.1.4
|
2220
|
-
]
|
2221
|
-
|
2222
|
-
installer.write_build_info_file
|
2223
|
-
|
2224
|
-
assert_path_exist @spec.build_info_file
|
2225
|
-
|
2226
|
-
expected = "--with-libyaml-dir\n/usr/local/Cellar/libyaml/0.1.4\n"
|
2227
|
-
|
2228
|
-
assert_equal expected, File.read(@spec.build_info_file)
|
2229
|
-
end
|
2230
|
-
|
2231
|
-
def test_write_build_info_file_empty
|
2232
|
-
installer = setup_base_installer
|
2233
|
-
|
2234
|
-
assert_path_not_exist @spec.build_info_file
|
2235
|
-
|
2236
|
-
installer.write_build_info_file
|
2237
|
-
|
2238
|
-
assert_path_not_exist @spec.build_info_file
|
2239
|
-
end
|
2240
|
-
|
2241
|
-
def test_write_build_info_file_install_dir
|
2242
|
-
@gem = setup_base_gem
|
2243
|
-
installer = Gem::Installer.at @gem, :install_dir => "#{@gemhome}2"
|
2244
|
-
|
2245
|
-
installer.build_args = %w[
|
2246
|
-
--with-libyaml-dir /usr/local/Cellar/libyaml/0.1.4
|
2247
|
-
]
|
2248
|
-
|
2249
|
-
installer.write_build_info_file
|
2250
|
-
|
2251
|
-
assert_path_not_exist @spec.build_info_file
|
2252
|
-
assert_path_exist \
|
2253
|
-
File.join("#{@gemhome}2", "build_info", "#{@spec.full_name}.info")
|
2254
|
-
end
|
2255
|
-
|
2256
|
-
def test_write_cache_file
|
2257
|
-
@gem = setup_base_gem
|
2258
|
-
cache_file = File.join @gemhome, "cache", @spec.file_name
|
2259
|
-
gem = File.join @gemhome, @spec.file_name
|
2260
|
-
|
2261
|
-
FileUtils.mv cache_file, gem
|
2262
|
-
assert_path_not_exist cache_file
|
2263
|
-
|
2264
|
-
installer = Gem::Installer.at gem
|
2265
|
-
installer.gem_home = @gemhome
|
2266
|
-
|
2267
|
-
installer.write_cache_file
|
2268
|
-
|
2269
|
-
assert_path_exist cache_file
|
2270
|
-
end
|
2271
|
-
|
2272
|
-
def test_write_spec
|
2273
|
-
@spec = setup_base_spec
|
2274
|
-
FileUtils.rm @spec.spec_file
|
2275
|
-
assert_path_not_exist @spec.spec_file
|
2276
|
-
|
2277
|
-
installer = Gem::Installer.for_spec @spec
|
2278
|
-
installer.gem_home = @gemhome
|
2279
|
-
|
2280
|
-
installer.write_spec
|
2281
|
-
|
2282
|
-
assert_path_exist @spec.spec_file
|
2283
|
-
|
2284
|
-
loaded = Gem::Specification.load @spec.spec_file
|
2285
|
-
|
2286
|
-
assert_equal @spec, loaded
|
2287
|
-
|
2288
|
-
assert_equal Gem.rubygems_version, @spec.installed_by_version
|
2289
|
-
end
|
2290
|
-
|
2291
|
-
def test_write_spec_writes_cached_spec
|
2292
|
-
@spec = setup_base_spec
|
2293
|
-
FileUtils.rm @spec.spec_file
|
2294
|
-
assert_path_not_exist @spec.spec_file
|
2295
|
-
|
2296
|
-
@spec.files = %w[a.rb b.rb c.rb]
|
2297
|
-
|
2298
|
-
installer = Gem::Installer.for_spec @spec
|
2299
|
-
installer.gem_home = @gemhome
|
2300
|
-
|
2301
|
-
installer.write_spec
|
2302
|
-
|
2303
|
-
# cached specs have no file manifest:
|
2304
|
-
@spec.files = []
|
2305
|
-
|
2306
|
-
assert_equal @spec, eval(File.read(@spec.spec_file))
|
2307
|
-
end
|
2308
|
-
|
2309
|
-
def test_leaves_no_empty_cached_spec_when_no_more_disk_space
|
2310
|
-
@spec = setup_base_spec
|
2311
|
-
FileUtils.rm @spec.spec_file
|
2312
|
-
assert_path_not_exist @spec.spec_file
|
2313
|
-
|
2314
|
-
@spec.files = %w[a.rb b.rb c.rb]
|
2315
|
-
|
2316
|
-
installer = Gem::Installer.for_spec @spec
|
2317
|
-
installer.gem_home = @gemhome
|
2318
|
-
|
2319
|
-
File.class_eval do
|
2320
|
-
alias_method :original_write, :write
|
2321
|
-
|
2322
|
-
def write(data)
|
2323
|
-
raise Errno::ENOSPC
|
2324
|
-
end
|
2325
|
-
end
|
2326
|
-
|
2327
|
-
assert_raise Errno::ENOSPC do
|
2328
|
-
installer.write_spec
|
2329
|
-
end
|
2330
|
-
|
2331
|
-
assert_path_not_exist @spec.spec_file
|
2332
|
-
ensure
|
2333
|
-
File.class_eval do
|
2334
|
-
remove_method :write
|
2335
|
-
alias_method :write, :original_write # rubocop:disable Lint/DuplicateMethods
|
2336
|
-
remove_method :original_write
|
2337
|
-
end
|
2338
|
-
end
|
2339
|
-
|
2340
|
-
def test_dir
|
2341
|
-
installer = setup_base_installer
|
2342
|
-
|
2343
|
-
assert_match %r{/gemhome/gems/a-2$}, installer.dir
|
2344
|
-
end
|
2345
|
-
|
2346
|
-
def test_default_gem_loaded_from
|
2347
|
-
spec = util_spec "a"
|
2348
|
-
installer = Gem::Installer.for_spec spec, :install_as_default => true
|
2349
|
-
installer.install
|
2350
|
-
assert_predicate spec, :default_gem?
|
2351
|
-
end
|
2352
|
-
|
2353
|
-
def test_default_gem_without_wrappers
|
2354
|
-
installer = setup_base_installer
|
2355
|
-
|
2356
|
-
FileUtils.rm_rf File.join(Gem.default_dir, "specifications")
|
2357
|
-
|
2358
|
-
installer.wrappers = false
|
2359
|
-
installer.options[:install_as_default] = true
|
2360
|
-
installer.gem_dir = @spec.gem_dir
|
2361
|
-
|
2362
|
-
use_ui @ui do
|
2363
|
-
installer.install
|
2364
|
-
end
|
2365
|
-
|
2366
|
-
assert_directory_exists File.join(@spec.gem_dir, "bin")
|
2367
|
-
installed_exec = File.join @spec.gem_dir, "bin", "executable"
|
2368
|
-
assert_path_exist installed_exec
|
2369
|
-
|
2370
|
-
assert_directory_exists File.join(Gem.default_dir, "specifications")
|
2371
|
-
assert_directory_exists File.join(Gem.default_dir, "specifications", "default")
|
2372
|
-
|
2373
|
-
default_spec = eval File.read File.join(Gem.default_dir, "specifications", "default", "a-2.gemspec")
|
2374
|
-
assert_equal Gem::Version.new("2"), default_spec.version
|
2375
|
-
assert_equal ["bin/executable"], default_spec.files
|
2376
|
-
|
2377
|
-
assert_directory_exists util_inst_bindir
|
2378
|
-
|
2379
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
2380
|
-
assert_path_exist installed_exec
|
2381
|
-
|
2382
|
-
wrapper = File.read installed_exec
|
2383
|
-
|
2384
|
-
if symlink_supported?
|
2385
|
-
refute_match %r{generated by RubyGems}, wrapper
|
2386
|
-
else # when symlink not supported, it warns and fallbacks back to installing wrapper
|
2387
|
-
assert_match %r{Unable to use symlinks, installing wrapper}, @ui.error
|
2388
|
-
assert_match %r{generated by RubyGems}, wrapper
|
2389
|
-
end
|
2390
|
-
end
|
2391
|
-
|
2392
|
-
def test_default_gem_with_wrappers
|
2393
|
-
installer = setup_base_installer
|
2394
|
-
|
2395
|
-
installer.wrappers = true
|
2396
|
-
installer.options[:install_as_default] = true
|
2397
|
-
installer.gem_dir = @spec.gem_dir
|
2398
|
-
|
2399
|
-
use_ui @ui do
|
2400
|
-
installer.install
|
2401
|
-
end
|
2402
|
-
|
2403
|
-
assert_directory_exists util_inst_bindir
|
2404
|
-
|
2405
|
-
installed_exec = File.join util_inst_bindir, "executable"
|
2406
|
-
assert_path_exist installed_exec
|
2407
|
-
|
2408
|
-
wrapper = File.read installed_exec
|
2409
|
-
assert_match %r{generated by RubyGems}, wrapper
|
2410
|
-
end
|
2411
|
-
|
2412
|
-
def test_default_gem_with_exe_as_bindir
|
2413
|
-
@spec = quick_gem "c" do |spec|
|
2414
|
-
util_make_exec spec, "#!/usr/bin/ruby", "exe"
|
2415
|
-
end
|
2416
|
-
|
2417
|
-
util_build_gem @spec
|
2418
|
-
|
2419
|
-
@spec.cache_file
|
2420
|
-
|
2421
|
-
installer = util_installer @spec, @gemhome
|
2422
|
-
|
2423
|
-
installer.options[:install_as_default] = true
|
2424
|
-
installer.gem_dir = @spec.gem_dir
|
2425
|
-
|
2426
|
-
use_ui @ui do
|
2427
|
-
installer.install
|
2428
|
-
end
|
2429
|
-
|
2430
|
-
assert_directory_exists File.join(@spec.gem_dir, "exe")
|
2431
|
-
installed_exec = File.join @spec.gem_dir, "exe", "executable"
|
2432
|
-
assert_path_exist installed_exec
|
2433
|
-
|
2434
|
-
assert_directory_exists File.join(Gem.default_dir, "specifications")
|
2435
|
-
assert_directory_exists File.join(Gem.default_dir, "specifications", "default")
|
2436
|
-
|
2437
|
-
default_spec = eval File.read File.join(Gem.default_dir, "specifications", "default", "c-2.gemspec")
|
2438
|
-
assert_equal Gem::Version.new("2"), default_spec.version
|
2439
|
-
assert_equal ["exe/executable"], default_spec.files
|
2440
|
-
end
|
2441
|
-
|
2442
|
-
def test_default_gem_to_specific_install_dir
|
2443
|
-
@gem = setup_base_gem
|
2444
|
-
installer = util_installer @spec, "#{@gemhome}2"
|
2445
|
-
installer.options[:install_as_default] = true
|
2446
|
-
|
2447
|
-
use_ui @ui do
|
2448
|
-
installer.install
|
2449
|
-
end
|
2450
|
-
|
2451
|
-
assert_directory_exists File.join("#{@gemhome}2", "specifications")
|
2452
|
-
assert_directory_exists File.join("#{@gemhome}2", "specifications", "default")
|
2453
|
-
|
2454
|
-
default_spec = eval File.read File.join("#{@gemhome}2", "specifications", "default", "a-2.gemspec")
|
2455
|
-
assert_equal Gem::Version.new("2"), default_spec.version
|
2456
|
-
assert_equal ["bin/executable"], default_spec.files
|
2457
|
-
end
|
2458
|
-
|
2459
|
-
def test_package_attribute
|
2460
|
-
gem = quick_gem "c" do |spec|
|
2461
|
-
util_make_exec spec, "#!/usr/bin/ruby", "exe"
|
2462
|
-
end
|
2463
|
-
|
2464
|
-
installer = util_installer(gem, @gemhome)
|
2465
|
-
assert_respond_to(installer, :package)
|
2466
|
-
assert_kind_of(Gem::Package, installer.package)
|
2467
|
-
end
|
2468
|
-
|
2469
|
-
def test_gem_attribute
|
2470
|
-
gem = quick_gem "c" do |spec|
|
2471
|
-
util_make_exec spec, "#!/usr/bin/ruby", "exe"
|
2472
|
-
end
|
2473
|
-
|
2474
|
-
installer = util_installer(gem, @gemhome)
|
2475
|
-
assert_respond_to(installer, :gem)
|
2476
|
-
assert_kind_of(String, installer.gem)
|
2477
|
-
end
|
2478
|
-
|
2479
|
-
private
|
2480
|
-
|
2481
|
-
def util_execless
|
2482
|
-
@spec = util_spec "z"
|
2483
|
-
util_build_gem @spec
|
2484
|
-
|
2485
|
-
util_installer @spec, @gemhome
|
2486
|
-
end
|
2487
|
-
|
2488
|
-
def util_conflict_executable(wrappers)
|
2489
|
-
conflict = quick_gem "conflict" do |spec|
|
2490
|
-
util_make_exec spec
|
2491
|
-
end
|
2492
|
-
|
2493
|
-
util_build_gem conflict
|
2494
|
-
|
2495
|
-
installer = util_installer conflict, @gemhome
|
2496
|
-
installer.wrappers = wrappers
|
2497
|
-
installer.generate_bin
|
2498
|
-
end
|
2499
|
-
|
2500
|
-
def mask
|
2501
|
-
0o100755
|
2502
|
-
end
|
2503
|
-
|
2504
|
-
def load_relative(value)
|
2505
|
-
orig_LIBRUBY_RELATIVE = RbConfig::CONFIG["LIBRUBY_RELATIVE"]
|
2506
|
-
RbConfig::CONFIG["LIBRUBY_RELATIVE"] = value
|
2507
|
-
|
2508
|
-
yield
|
2509
|
-
ensure
|
2510
|
-
RbConfig::CONFIG["LIBRUBY_RELATIVE"] = orig_LIBRUBY_RELATIVE
|
2511
|
-
end
|
2512
|
-
end
|