aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/.rubocop_todo.yml25
-rw-r--r--Library/Homebrew/brew.sh3
-rw-r--r--Library/Homebrew/build.rb2
-rw-r--r--Library/Homebrew/cask/.gitattributes1
-rw-r--r--Library/Homebrew/cask/Gemfile24
-rw-r--r--Library/Homebrew/cask/Gemfile.lock56
-rw-r--r--Library/Homebrew/cask/Rakefile26
-rwxr-xr-xLibrary/Homebrew/cask/cmd/brew-cask-tests.rb36
-rw-r--r--Library/Homebrew/cask/lib/hbc.rb3
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact.rb64
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/base.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/installer.rb14
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/pkg.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb8
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb3
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb10
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/zap.rb11
-rw-r--r--Library/Homebrew/cask/lib/hbc/audit.rb19
-rw-r--r--Library/Homebrew/cask/lib/hbc/cache.rb21
-rw-r--r--Library/Homebrew/cask/lib/hbc/cask_loader.rb14
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli.rb7
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/doctor.rb175
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb61
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_help.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb20
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/list.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/container.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/container/dmg.rb15
-rw-r--r--Library/Homebrew/cask/lib/hbc/container/xip.rb29
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl.rb17
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl/appcast.rb16
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb21
-rw-r--r--Library/Homebrew/cask/lib/hbc/pkg.rb8
-rw-r--r--Library/Homebrew/cask/lib/hbc/staged.rb2
-rw-r--r--Library/Homebrew/cask/spec/cask/accessibility_spec.rb82
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/alt_target_spec.rb (renamed from Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb)36
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/app_spec.rb (renamed from Library/Homebrew/cask/test/cask/artifact/app_test.rb)131
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb10
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb47
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb17
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb71
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/postflight_block_spec.rb (renamed from Library/Homebrew/cask/test/cask/artifact/postflight_block_test.rb)18
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/preflight_block_spec.rb (renamed from Library/Homebrew/cask/test/cask/artifact/preflight_block_test.rb)18
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb49
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb93
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb11
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb21
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb (renamed from Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb)78
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb (renamed from Library/Homebrew/cask/test/cask/artifact/zap_test.rb)78
-rw-r--r--Library/Homebrew/cask/spec/cask/audit_spec.rb5
-rw-r--r--Library/Homebrew/cask/spec/cask/cask_spec.rb69
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/audit_spec.rb61
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/cat_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/cat_test.rb)34
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/create_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/create_test.rb)28
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb2
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/edit_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/edit_test.rb)28
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/fetch_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/fetch_test.rb)27
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/home_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/home_test.rb)18
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/info_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/info_test.rb)46
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/install_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/install_test.rb)46
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/list_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/list_test.rb)38
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/options_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/options_test.rb)50
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb24
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/search_spec.rb61
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/uninstall_test.rb)72
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/version_spec.rb11
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/zap_spec.rb (renamed from Library/Homebrew/cask/test/cask/cli/zap_test.rb)30
-rw-r--r--Library/Homebrew/cask/spec/cask/cli_spec.rb16
-rw-r--r--Library/Homebrew/cask/spec/cask/container/dmg_spec.rb (renamed from Library/Homebrew/cask/test/cask/container/dmg_test.rb)8
-rw-r--r--Library/Homebrew/cask/spec/cask/container/naked_spec.rb (renamed from Library/Homebrew/cask/test/cask/container/naked_test.rb)11
-rw-r--r--Library/Homebrew/cask/spec/cask/depends_on_spec.rb92
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb (renamed from Library/Homebrew/cask/test/cask/dsl/caveats_test.rb)4
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb (renamed from Library/Homebrew/cask/test/cask/dsl/postflight_test.rb)4
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb (renamed from Library/Homebrew/cask/test/cask/dsl/preflight_test.rb)4
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb (renamed from Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb)4
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb (renamed from Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb)4
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl_spec.rb548
-rw-r--r--Library/Homebrew/cask/spec/cask/installer_spec.rb398
-rw-r--r--Library/Homebrew/cask/spec/cask/pkg_spec.rb114
-rw-r--r--Library/Homebrew/cask/spec/cask/scopes_spec.rb28
-rw-r--r--Library/Homebrew/cask/spec/cask/staged_spec.rb (renamed from Library/Homebrew/cask/test/cask/staged_test.rb)12
-rw-r--r--Library/Homebrew/cask/spec/cask/url_checker_spec.rb44
-rw-r--r--Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb8
-rw-r--r--Library/Homebrew/cask/spec/plist/parser_spec.rb75
-rw-r--r--Library/Homebrew/cask/spec/spec_helper.rb42
-rw-r--r--Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb3
-rw-r--r--Library/Homebrew/cask/spec/support/fake_system_command.rb (renamed from Library/Homebrew/cask/test/support/fake_system_command.rb)24
-rw-r--r--Library/Homebrew/cask/spec/support/file_helper.rb8
-rw-r--r--Library/Homebrew/cask/spec/support/install_helper.rb38
-rw-r--r--Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb13
-rw-r--r--Library/Homebrew/cask/spec/support/never_sudo_system_command.rb (renamed from Library/Homebrew/cask/test/support/never_sudo_system_command.rb)2
-rw-r--r--Library/Homebrew/cask/spec/support/sha256_helper.rb8
-rw-r--r--Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb23
-rw-r--r--Library/Homebrew/cask/spec/support/shared_examples/staged.rb143
-rwxr-xr-xLibrary/Homebrew/cask/spec/upload_coverage.rb6
-rw-r--r--Library/Homebrew/cask/test/README.md3
-rw-r--r--Library/Homebrew/cask/test/cask/accessibility_test.rb77
-rw-r--r--Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb47
-rw-r--r--Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb17
-rw-r--r--Library/Homebrew/cask/test/cask/artifact/pkg_test.rb74
-rw-r--r--Library/Homebrew/cask/test/cask/artifact/suite_test.rb46
-rw-r--r--Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb97
-rw-r--r--Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb14
-rw-r--r--Library/Homebrew/cask/test/cask/cli/audit_test.rb64
-rw-r--r--Library/Homebrew/cask/test/cask/cli/reinstall_test.rb24
-rw-r--r--Library/Homebrew/cask/test/cask/cli/search_test.rb59
-rw-r--r--Library/Homebrew/cask/test/cask/cli/version_test.rb9
-rw-r--r--Library/Homebrew/cask/test/cask/depends_on_test.rb113
-rw-r--r--Library/Homebrew/cask/test/cask/dsl_test.rb475
-rw-r--r--Library/Homebrew/cask/test/cask/installer_test.rb422
-rw-r--r--Library/Homebrew/cask/test/cask/pkg_test.rb94
-rw-r--r--Library/Homebrew/cask/test/cask/url_checker_test.rb51
-rw-r--r--Library/Homebrew/cask/test/cask_test.rb71
-rw-r--r--Library/Homebrew/cask/test/plist/parser_test.rb65
-rw-r--r--Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb9
-rw-r--r--Library/Homebrew/cask/test/support/cleanup.rb10
-rw-r--r--Library/Homebrew/cask/test/support/fake_dirs.rb31
-rw-r--r--Library/Homebrew/cask/test/support/shared_examples.rb25
-rw-r--r--Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb23
-rw-r--r--Library/Homebrew/cask/test/support/shared_examples/staged.rb109
-rw-r--r--Library/Homebrew/cask/test/syntax_test.rb17
-rw-r--r--Library/Homebrew/cask/test/test_helper.rb110
-rw-r--r--Library/Homebrew/caveats.rb27
-rw-r--r--Library/Homebrew/cmd/install.rb8
-rw-r--r--Library/Homebrew/cmd/reinstall.rb20
-rw-r--r--Library/Homebrew/cmd/style.rb2
-rw-r--r--Library/Homebrew/cmd/update-reset.sh2
-rw-r--r--Library/Homebrew/cmd/update.sh2
-rw-r--r--Library/Homebrew/cmd/upgrade.rb24
-rw-r--r--Library/Homebrew/cmd/uses.rb28
-rw-r--r--Library/Homebrew/compat/hbc/cask_loader.rb2
-rw-r--r--Library/Homebrew/dependency.rb2
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb36
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb3
-rw-r--r--Library/Homebrew/dev-cmd/create.rb6
-rw-r--r--Library/Homebrew/dev-cmd/man.rb4
-rw-r--r--Library/Homebrew/dev-cmd/pull.rb10
-rw-r--r--Library/Homebrew/dev-cmd/tests.rb48
-rw-r--r--Library/Homebrew/emoji.rb12
-rw-r--r--Library/Homebrew/exceptions.rb13
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb2
-rw-r--r--Library/Homebrew/extend/fileutils.rb2
-rw-r--r--Library/Homebrew/extend/os/mac/diagnostic.rb4
-rw-r--r--Library/Homebrew/formula.rb25
-rw-r--r--Library/Homebrew/formula_installer.rb25
-rw-r--r--Library/Homebrew/formula_support.rb47
-rw-r--r--Library/Homebrew/formulary.rb6
-rw-r--r--Library/Homebrew/global.rb2
-rw-r--r--Library/Homebrew/keg.rb57
-rw-r--r--Library/Homebrew/manpages/brew-cask.1.md12
-rw-r--r--Library/Homebrew/official_taps.rb5
-rw-r--r--Library/Homebrew/os/mac.rb5
-rw-r--r--Library/Homebrew/os/mac/keg.rb4
-rw-r--r--Library/Homebrew/os/mac/xcode.rb2
-rw-r--r--Library/Homebrew/requirement.rb36
-rw-r--r--Library/Homebrew/requirements/language_module_requirement.rb18
-rw-r--r--Library/Homebrew/tab.rb6
-rw-r--r--Library/Homebrew/test/ARGV_spec.rb149
-rw-r--r--Library/Homebrew/test/ARGV_test.rb80
-rw-r--r--Library/Homebrew/test/ENV_test.rb1
-rw-r--r--Library/Homebrew/test/Gemfile22
-rw-r--r--Library/Homebrew/test/Gemfile.lock68
-rw-r--r--Library/Homebrew/test/audit_test.rb24
-rw-r--r--Library/Homebrew/test/bash_spec.rb52
-rw-r--r--Library/Homebrew/test/bash_test.rb35
-rw-r--r--Library/Homebrew/test/blacklist_spec.rb111
-rw-r--r--Library/Homebrew/test/blacklist_test.rb68
-rw-r--r--Library/Homebrew/test/bottle_collector_test.rb1
-rw-r--r--Library/Homebrew/test/bottle_hooks_test.rb2
-rw-r--r--Library/Homebrew/test/bottle_test.rb2
-rw-r--r--Library/Homebrew/test/build_environment_test.rb1
-rw-r--r--Library/Homebrew/test/build_options_test.rb1
-rw-r--r--Library/Homebrew/test/caveats_test.rb1
-rw-r--r--Library/Homebrew/test/checksum_verification_test.rb4
-rw-r--r--Library/Homebrew/test/cleaner_test.rb5
-rw-r--r--Library/Homebrew/test/cleanup_test.rb34
-rw-r--r--Library/Homebrew/test/commands_test.rb6
-rw-r--r--Library/Homebrew/test/compiler_selector_test.rb1
-rw-r--r--Library/Homebrew/test/dependencies_test.rb2
-rw-r--r--Library/Homebrew/test/dependency_collector_test.rb2
-rw-r--r--Library/Homebrew/test/dependency_expansion_test.rb1
-rw-r--r--Library/Homebrew/test/dependency_test.rb6
-rw-r--r--Library/Homebrew/test/descriptions_test.rb3
-rw-r--r--Library/Homebrew/test/diagnostic_test.rb8
-rw-r--r--Library/Homebrew/test/download_strategies_test.rb67
-rw-r--r--Library/Homebrew/test/emoji_test.rb11
-rw-r--r--Library/Homebrew/test/exceptions_test.rb5
-rw-r--r--Library/Homebrew/test/formula_installer_test.rb15
-rw-r--r--Library/Homebrew/test/formula_lock_test.rb3
-rw-r--r--Library/Homebrew/test/formula_pin_test.rb5
-rw-r--r--Library/Homebrew/test/formula_test.rb133
-rw-r--r--Library/Homebrew/test/formulary_test.rb25
-rw-r--r--Library/Homebrew/test/gpg2_requirement_test.rb7
-rw-r--r--Library/Homebrew/test/gpg_test.rb10
-rw-r--r--Library/Homebrew/test/install_test.rb17
-rw-r--r--Library/Homebrew/test/keg_test.rb17
-rw-r--r--Library/Homebrew/test/language_python_test.rb5
-rw-r--r--Library/Homebrew/test/migrator_test.rb23
-rw-r--r--Library/Homebrew/test/options_test.rb5
-rw-r--r--Library/Homebrew/test/os/mac/bottle_collector_test.rb1
-rw-r--r--Library/Homebrew/test/os/mac/dependency_collector_test.rb2
-rw-r--r--Library/Homebrew/test/os/mac/diagnostic_test.rb8
-rw-r--r--Library/Homebrew/test/os/mac/keg_test.rb8
-rw-r--r--Library/Homebrew/test/os/mac/mach_test.rb3
-rw-r--r--Library/Homebrew/test/os/mac/version_test.rb1
-rw-r--r--Library/Homebrew/test/patch_test.rb1
-rw-r--r--Library/Homebrew/test/patching_test.rb5
-rw-r--r--Library/Homebrew/test/pathname_test.rb6
-rw-r--r--Library/Homebrew/test/reinstall_test.rb9
-rw-r--r--Library/Homebrew/test/resource_test.rb1
-rw-r--r--Library/Homebrew/test/sandbox_test.rb15
-rw-r--r--Library/Homebrew/test/shell_test.rb9
-rw-r--r--Library/Homebrew/test/software_spec_test.rb3
-rw-r--r--Library/Homebrew/test/spec_helper.rb77
-rw-r--r--Library/Homebrew/test/stdlib_test.rb1
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb (renamed from Library/Homebrew/cask/spec/support/Casks/appcast-checkpoint-sha256-for-empty-string.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb (renamed from Library/Homebrew/cask/spec/support/Casks/appcast-invalid-checkpoint.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb (renamed from Library/Homebrew/cask/spec/support/Casks/appcast-missing-checkpoint.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb (renamed from Library/Homebrew/cask/spec/support/Casks/appcast-valid-checkpoint.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb (renamed from Library/Homebrew/cask/test/support/Casks/appdir-interpolation.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb (renamed from Library/Homebrew/cask/test/support/Casks/auto-updates.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb (renamed from Library/Homebrew/cask/test/support/Casks/bad-checksum.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb (renamed from Library/Homebrew/cask/test/support/Casks/basic-cask.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/booby-trap.rb (renamed from Library/Homebrew/cask/spec/support/Casks/booby-trap.rb)0
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-7z.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-air.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-bzip2.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-cab.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-dmg.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-gzip.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-lzma.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-pkg.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-rar.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-sit.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-tar-gz.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-xar.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb (renamed from Library/Homebrew/cask/test/support/Casks/container-xz.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb (renamed from Library/Homebrew/cask/spec/support/Casks/generic-artifact-absolute-target.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb3
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb (renamed from Library/Homebrew/cask/spec/support/Casks/generic-artifact-relative-target.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb (renamed from Library/Homebrew/cask/spec/support/Casks/invalid-sha256.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-multiple.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-url.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-conflicts-with-key.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-arch-value.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-key.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-bad-release.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-x11-value.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-conflicting-keys.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-id.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-url.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-missing-key.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-multiple-stanzas.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-parameter.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-signature-url.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-type.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-format.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb9
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-version.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-stage-only-conflict.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-homepage.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-url.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb (renamed from Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-version.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb (renamed from Library/Homebrew/cask/test/support/Casks/local-caffeine.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb (renamed from Library/Homebrew/cask/test/support/Casks/local-transmission.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb (renamed from Library/Homebrew/cask/test/support/Casks/missing-checksum.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb (renamed from Library/Homebrew/cask/spec/support/Casks/missing-homepage.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb (renamed from Library/Homebrew/cask/spec/support/Casks/missing-name.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb (renamed from Library/Homebrew/cask/spec/support/Casks/missing-sha256.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb (renamed from Library/Homebrew/cask/spec/support/Casks/missing-url.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb (renamed from Library/Homebrew/cask/spec/support/Casks/missing-version.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb (renamed from Library/Homebrew/cask/test/support/Casks/naked-executable.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb (renamed from Library/Homebrew/cask/test/support/Casks/nested-app.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb (renamed from Library/Homebrew/cask/test/support/Casks/no-checksum.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb (renamed from Library/Homebrew/cask/test/support/Casks/no-dsl-version.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb (renamed from Library/Homebrew/cask/spec/support/Casks/osdn-correct-url-format.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb (renamed from Library/Homebrew/cask/spec/support/Casks/osdn-incorrect-url-format.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb (renamed from Library/Homebrew/cask/spec/support/Casks/sha256-for-empty-string.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb (renamed from Library/Homebrew/cask/spec/support/Casks/sourceforge-correct-url-format.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb (renamed from Library/Homebrew/cask/spec/support/Casks/sourceforge-incorrect-url-format.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb (renamed from Library/Homebrew/cask/spec/support/Casks/sourceforge-version-latest-correct-url-format.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb (renamed from Library/Homebrew/cask/test/support/Casks/stage-only.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb (renamed from Library/Homebrew/cask/test/support/Casks/test-opera-mail.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb (renamed from Library/Homebrew/cask/test/support/Casks/test-opera.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb (renamed from Library/Homebrew/cask/spec/support/Casks/version-latest-string.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb (renamed from Library/Homebrew/cask/spec/support/Casks/version-latest-with-checksum.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-accessibility-access.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-alt-target.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-appcast.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb (renamed from Library/Homebrew/cask/spec/support/Casks/with-binary.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-caveats.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-choices.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-conditional-caveats.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-conflicts-with.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic-helper.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-multiple.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-cask.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-formula-multiple.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-formula.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-array.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-comparison.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-failure.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-string.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-symbol.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-x11-false.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-depends-on-x11.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-dsl-version.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb (renamed from Library/Homebrew/cask/spec/support/Casks/with-embedded-binary.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-generic-artifact-no-target.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-generic-artifact.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-gpg-key-url.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-gpg.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-installable.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-installer-manual.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-installer-script.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-macosx-dir.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-pkgutil-zap.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-suite.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-two-apps-correct.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-two-apps-incorrect.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-two-apps-subdir.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-delete.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-early-script.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-kext.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-launchctl.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-login-item.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-pkgutil.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-quit.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-rmdir.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-script.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-signal.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-uninstall-trash.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-delete.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-early-script.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-kext.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-launchctl.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-login-item.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-pkgutil.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-quit.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-rmdir.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-script.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-signal.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap-trash.rb)2
-rw-r--r--Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb (renamed from Library/Homebrew/cask/test/support/Casks/with-zap.rb)2
-rw-r--r--Library/Homebrew/test/support/helper/env.rb15
-rw-r--r--Library/Homebrew/test/support/helper/fs_leak_logger.rb4
-rw-r--r--Library/Homebrew/test/support/helper/integration_command_test_case.rb109
-rw-r--r--Library/Homebrew/test/support/helper/lifecycle_enforcer.rb22
-rw-r--r--Library/Homebrew/test/support/helper/test_case.rb58
-rw-r--r--Library/Homebrew/test/support/lib/config.rb3
-rw-r--r--Library/Homebrew/test/tab_test.rb55
-rw-r--r--Library/Homebrew/test/tap_test.rb30
-rw-r--r--Library/Homebrew/test/testing_env.rb23
-rw-r--r--Library/Homebrew/test/uninstall_test.rb9
-rw-r--r--Library/Homebrew/test/update_report_test.rb1
-rw-r--r--Library/Homebrew/test/utils_test.rb27
-rw-r--r--Library/Homebrew/test/versions_test.rb2
-rw-r--r--Library/Homebrew/utils.rb4
-rw-r--r--README.md14
-rw-r--r--completions/zsh/_brew2
-rw-r--r--docs/Formula-Cookbook.md3
-rw-r--r--docs/Versions.md2
-rw-r--r--docs/brew.1.html4
-rw-r--r--manpages/brew-cask.113
-rw-r--r--manpages/brew.14
370 files changed, 4209 insertions, 4141 deletions
diff --git a/Library/Homebrew/.rubocop_todo.yml b/Library/Homebrew/.rubocop_todo.yml
index c1b2ba6e7..37518a5f0 100644
--- a/Library/Homebrew/.rubocop_todo.yml
+++ b/Library/Homebrew/.rubocop_todo.yml
@@ -1,12 +1,12 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 100`
-# on 2016-12-31 22:41:53 +0000 using RuboCop version 0.45.0.
+# on 2017-01-27 21:44:55 +0000 using RuboCop version 0.47.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
-# Offense count: 16
+# Offense count: 17
Lint/HandleExceptions:
Exclude:
- 'cmd/install.rb'
@@ -60,19 +60,26 @@ Lint/ShadowedException:
- 'utils/fork.rb'
# Offense count: 13
+# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 5
# Offense count: 19
# Configuration parameters: CountComments.
Metrics/ModuleLength:
- Max: 363
+ Max: 400
# Offense count: 1
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 6
+# Offense count: 2
+Security/MarshalLoad:
+ Exclude:
+ - 'dependency.rb'
+ - 'utils/fork.rb'
+
# Offense count: 1
Style/AccessorMethodName:
Exclude:
@@ -86,6 +93,18 @@ Style/ClassVars:
- 'test/support/helper/fs_leak_logger.rb'
# Offense count: 13
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, SupportedStyles.
+# SupportedStyles: compact, expanded
+Style/EmptyMethod:
+ Exclude:
+ - 'debrew/irb.rb'
+ - 'download_strategy.rb'
+ - 'extend/ENV/super.rb'
+ - 'formula.rb'
+ - 'patch.rb'
+
+# Offense count: 13
# Configuration parameters: AllowedVariables.
Style/GlobalVars:
Exclude:
diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh
index 92953001d..81a52f474 100644
--- a/Library/Homebrew/brew.sh
+++ b/Library/Homebrew/brew.sh
@@ -82,6 +82,9 @@ unset GEM_PATH
# bash processes inside builds
unset BASH_ENV
+# Users may have this set, breaking grep's output.
+unset GREP_OPTIONS
+
HOMEBREW_SYSTEM="$(uname -s)"
case "$HOMEBREW_SYSTEM" in
Darwin) HOMEBREW_MACOS="1" ;;
diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb
index c4e903642..c0f15158d 100644
--- a/Library/Homebrew/build.rb
+++ b/Library/Homebrew/build.rb
@@ -48,7 +48,7 @@ class Build
Requirement.prune
elsif req.build? && dependent != formula
Requirement.prune
- elsif req.satisfied? && req.default_formula? && (dep = req.to_dependency).installed?
+ elsif req.satisfied? && (dep = req.to_dependency) && dep.installed?
deps << dep
Requirement.prune
end
diff --git a/Library/Homebrew/cask/.gitattributes b/Library/Homebrew/cask/.gitattributes
deleted file mode 100644
index 176a458f9..000000000
--- a/Library/Homebrew/cask/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-* text=auto
diff --git a/Library/Homebrew/cask/Gemfile b/Library/Homebrew/cask/Gemfile
index 5c99338b8..5572387cc 100644
--- a/Library/Homebrew/cask/Gemfile
+++ b/Library/Homebrew/cask/Gemfile
@@ -1,29 +1,13 @@
source "https://rubygems.org"
-gem "rake"
-
-group :debug do
- gem "pry"
- gem "pry-byebug", platforms: :mri
-end
-
group :test do
- # This is SimpleCov v0.12.0 with two fixes merged on top, that finally resolve
- # all issues with parallel tests, uncovered files, and tracked files. Switch
- # back to stable as soon as v0.12.1 or v0.13.0 is released. For details, see:
- # - https://github.com/colszowka/simplecov/pull/513
- # - https://github.com/colszowka/simplecov/pull/520
- gem "simplecov", "0.12.0",
- git: "https://github.com/colszowka/simplecov.git",
- branch: "master",
- ref: "83d8031ddde0927f87ef9327200a98583ca18d77",
- require: false
+ gem "simplecov", require: false
gem "codecov", require: false
- gem "minitest", "~> 5.9"
+ gem "minitest"
gem "minitest-reporters"
- gem "mocha", "~> 1.1", require: false
+ gem "mocha", require: false
gem "parallel_tests"
- gem "rspec", "~> 3.5"
+ gem "rspec"
gem "rspec-its", require: false
gem "rspec-wait", require: false
end
diff --git a/Library/Homebrew/cask/Gemfile.lock b/Library/Homebrew/cask/Gemfile.lock
index 4bdf2d0f6..700f093d1 100644
--- a/Library/Homebrew/cask/Gemfile.lock
+++ b/Library/Homebrew/cask/Gemfile.lock
@@ -1,49 +1,27 @@
-GIT
- remote: https://github.com/colszowka/simplecov.git
- revision: 83d8031ddde0927f87ef9327200a98583ca18d77
- ref: 83d8031ddde0927f87ef9327200a98583ca18d77
- branch: master
- specs:
- simplecov (0.12.0)
- docile (~> 1.1.0)
- json (>= 1.8, < 3)
- simplecov-html (~> 0.10.0)
-
GEM
remote: https://rubygems.org/
specs:
ansi (1.5.0)
- builder (3.2.2)
- byebug (9.0.6)
- codecov (0.1.6)
+ builder (3.2.3)
+ codecov (0.1.9)
json
simplecov
url
- coderay (1.1.1)
- diff-lcs (1.2.5)
+ diff-lcs (1.3)
docile (1.1.5)
- json (2.0.2)
+ json (2.0.3)
metaclass (0.0.4)
- method_source (0.8.2)
- minitest (5.9.1)
- minitest-reporters (1.1.12)
+ minitest (5.10.1)
+ minitest-reporters (1.1.14)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
mocha (1.2.1)
metaclass (~> 0.0.1)
- parallel (1.9.0)
- parallel_tests (2.10.0)
+ parallel (1.10.0)
+ parallel_tests (2.13.0)
parallel
- pry (0.10.4)
- coderay (~> 1.1.0)
- method_source (~> 0.8.1)
- slop (~> 3.4)
- pry-byebug (3.4.0)
- byebug (~> 9.0)
- pry (~> 0.10)
- rake (11.3.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
@@ -63,8 +41,11 @@ GEM
rspec-wait (0.0.9)
rspec (>= 3, < 4)
ruby-progressbar (1.8.1)
+ simplecov (0.13.0)
+ docile (~> 1.1.0)
+ json (>= 1.8, < 3)
+ simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
- slop (3.6.0)
url (0.3.2)
PLATFORMS
@@ -72,17 +53,14 @@ PLATFORMS
DEPENDENCIES
codecov
- minitest (~> 5.9)
+ minitest
minitest-reporters
- mocha (~> 1.1)
+ mocha
parallel_tests
- pry
- pry-byebug
- rake
- rspec (~> 3.5)
+ rspec
rspec-its
rspec-wait
- simplecov (= 0.12.0)!
+ simplecov
BUNDLED WITH
- 1.13.6
+ 1.13.7
diff --git a/Library/Homebrew/cask/Rakefile b/Library/Homebrew/cask/Rakefile
deleted file mode 100644
index 39398aa19..000000000
--- a/Library/Homebrew/cask/Rakefile
+++ /dev/null
@@ -1,26 +0,0 @@
-require "rake/testtask"
-require "rspec/core/rake_task"
-
-$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
-$LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
-
-namespace :test do
- namespace :coverage do
- desc "Upload coverage to Codecov"
- task :upload do
- require "simplecov"
- require "codecov"
- formatter = SimpleCov::Formatter::Codecov.new
- formatter.format(SimpleCov::ResultMerger.merged_result)
- end
- end
-end
-
-desc "Open a REPL for debugging and experimentation"
-task :console do
- require "pry"
- require "pry-byebug"
- require "hbc"
- ARGV.clear
- Hbc.pry
-end
diff --git a/Library/Homebrew/cask/cmd/brew-cask-tests.rb b/Library/Homebrew/cask/cmd/brew-cask-tests.rb
index 43683a263..b27bc2fe7 100755
--- a/Library/Homebrew/cask/cmd/brew-cask-tests.rb
+++ b/Library/Homebrew/cask/cmd/brew-cask-tests.rb
@@ -10,8 +10,8 @@ def run_tests(executable, files, args = [])
system "bundle", "exec", executable, *opts, "--", *args, "--", *files
end
-repo_root = Pathname.new(__FILE__).realpath.parent.parent
-repo_root.cd do
+cask_root = Pathname.new(__FILE__).realpath.parent.parent
+cask_root.cd do
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
ENV["HOMEBREW_NO_EMOJI"] = "1"
ENV.delete("HOMEBREW_CASK_OPTS")
@@ -21,37 +21,25 @@ repo_root.cd do
system "bundle", "install"
end
- rspec = ARGV.flag?("--rspec") || !ARGV.flag?("--minitest")
- minitest = ARGV.flag?("--minitest") || !ARGV.flag?("--rspec")
-
- p [:coverage, ARGV.flag?("--coverage"), ENV["CI"], ENV["TRAVIS"]]
if ARGV.flag?("--coverage")
ENV["HOMEBREW_TESTS_COVERAGE"] = "1"
upload_coverage = ENV["CODECOV_TOKEN"] || ENV["TRAVIS"]
end
- failed = false
-
- if rspec
- run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[
- --color
- --require spec_helper
- --format progress
- --format ParallelTests::RSpec::RuntimeLogger
- --out tmp/parallel_runtime_rspec.log
- ]
- failed ||= !$CHILD_STATUS.success?
- end
+ run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[
+ --color
+ --require spec_helper
+ --format progress
+ --format ParallelTests::RSpec::RuntimeLogger
+ --out tmp/parallel_runtime_rspec.log
+ ]
- if minitest
- run_tests "parallel_test", Dir["test/**/*_test.rb"]
- failed ||= !$CHILD_STATUS.success?
+ unless $CHILD_STATUS.success?
+ Homebrew.failed = true
end
- Homebrew.failed = failed
-
if upload_coverage
puts "Submitting Codecov coverage..."
- system "bundle", "exec", "rake", "test:coverage:upload"
+ system "bundle", "exec", "spec/upload_coverage.rb"
end
end
diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb
index 69b6e8f21..80f1f1da0 100644
--- a/Library/Homebrew/cask/lib/hbc.rb
+++ b/Library/Homebrew/cask/lib/hbc.rb
@@ -6,6 +6,7 @@ require "hbc/audit"
require "hbc/auditor"
require "hbc/cache"
require "hbc/cask"
+require "hbc/cask_loader"
require "hbc/without_source"
require "hbc/caskroom"
require "hbc/checkable"
@@ -46,7 +47,7 @@ module Hbc
def self.init
Cache.ensure_cache_exists
- Cache.migrate_legacy_cache
+ Cache.delete_legacy_cache
Caskroom.migrate_caskroom_from_repo_to_prefix
Caskroom.ensure_caskroom_exists
diff --git a/Library/Homebrew/cask/lib/hbc/artifact.rb b/Library/Homebrew/cask/lib/hbc/artifact.rb
index 8b4babdf6..b155a125a 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact.rb
@@ -27,41 +27,39 @@ module Hbc
module Artifact
# NOTE: order is important here, since we want to extract nested containers
# before we handle any other artifacts
- def self.artifacts
- [
- PreflightBlock,
- NestedContainer,
- Installer,
- App,
- Suite,
- Artifact, # generic 'artifact' stanza
- Colorpicker,
- Pkg,
- Prefpane,
- Qlplugin,
- Dictionary,
- Font,
- Service,
- StageOnly,
- Binary,
- InputMethod,
- InternetPlugin,
- AudioUnitPlugin,
- VstPlugin,
- Vst3Plugin,
- ScreenSaver,
- Uninstall,
- PostflightBlock,
- Zap,
- ]
- end
+ TYPES = [
+ PreflightBlock,
+ NestedContainer,
+ Installer,
+ App,
+ Suite,
+ Artifact, # generic 'artifact' stanza
+ Colorpicker,
+ Pkg,
+ Prefpane,
+ Qlplugin,
+ Dictionary,
+ Font,
+ Service,
+ StageOnly,
+ Binary,
+ InputMethod,
+ InternetPlugin,
+ AudioUnitPlugin,
+ VstPlugin,
+ Vst3Plugin,
+ ScreenSaver,
+ Uninstall,
+ PostflightBlock,
+ Zap,
+ ].freeze
- def self.for_cask(cask)
+ def self.for_cask(cask, command: SystemCommand, force: false)
odebug "Determining which artifacts are present in Cask #{cask}"
- artifacts.select do |artifact|
- odebug "Checking for artifact class #{artifact}"
- artifact.me?(cask)
- end
+
+ TYPES
+ .select { |klass| klass.me?(cask) }
+ .map { |klass| klass.new(cask, command: command, force: force) }
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/base.rb b/Library/Homebrew/cask/lib/hbc/artifact/base.rb
index b53c13f08..d925ff340 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/base.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/base.rb
@@ -27,10 +27,6 @@ module Hbc
attr_reader :force
- def zap_phase
- odebug "Nothing to do. The #{self.class.artifact_name} artifact has no zap phase."
- end
-
# TODO: this sort of logic would make more sense in dsl.rb, or a
# constructor called from dsl.rb, so long as that isn't slow.
def self.read_script_arguments(arguments, stanza, default_arguments = {}, override_arguments = {}, key = nil)
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb
index b64b00fe3..55e8d38c0 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb
@@ -3,16 +3,6 @@ require "hbc/artifact/base"
module Hbc
module Artifact
class Installer < Base
- # TODO: for backward compatibility, removeme
- def install
- install_phase
- end
-
- # TODO: for backward compatibility, removeme
- def uninstall
- uninstall_phase
- end
-
def install_phase
@cask.artifacts[self.class.artifact_dsl_key].each do |artifact|
if artifact.manual
@@ -36,10 +26,6 @@ module Hbc
end
end
end
-
- def uninstall_phase
- odebug "Nothing to do. The #{self.class.artifact_dsl_key} artifact has no uninstall phase."
- end
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb
index 107640797..45f23fe37 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb
@@ -7,10 +7,6 @@ module Hbc
@cask.artifacts[:nested_container].each { |container| extract(container) }
end
- def uninstall_phase
- # no need to take action; is removed after extraction
- end
-
def extract(container_relative_path)
source = @cask.staged_path.join(container_relative_path)
container = Container.for_path(source, @command)
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
index 0569d2a86..6d6362d46 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
@@ -36,10 +36,6 @@ module Hbc
@cask.artifacts[:pkg].each { |pkg_description| run_installer(pkg_description) }
end
- def uninstall_phase
- # Do nothing. Must be handled explicitly by a separate :uninstall stanza.
- end
-
def run_installer(pkg_description)
load_pkg_description pkg_description
ohai "Running installer for #{@cask}; your password may be necessary."
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb b/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb
index 594c5bef9..1122c1d02 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb
@@ -6,14 +6,6 @@ module Hbc
def self.artifact_dsl_key
:stage_only
end
-
- def install_phase
- # do nothing
- end
-
- def uninstall_phase
- # do nothing
- end
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb
index 8b5603064..5a3dc098d 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb
@@ -3,6 +3,9 @@ require "hbc/artifact/uninstall_base"
module Hbc
module Artifact
class Uninstall < UninstallBase
+ def uninstall_phase
+ dispatch_uninstall_directives
+ end
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb
index ccb06a9ab..ce2b1f51a 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb
@@ -54,15 +54,7 @@ module Hbc
path_strings - undeletable
end
- def install_phase
- odebug "Nothing to do. The uninstall artifact has no install phase."
- end
-
- def uninstall_phase
- dispatch_uninstall_directives
- end
-
- def dispatch_uninstall_directives(expand_tilde = true)
+ def dispatch_uninstall_directives(expand_tilde: true)
directives_set = @cask.artifacts[stanza]
ohai "Running #{stanza} process for #{@cask}; your password may be necessary"
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb
index 503ea35c4..7793e5772 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb
@@ -3,17 +3,8 @@ require "hbc/artifact/uninstall_base"
module Hbc
module Artifact
class Zap < UninstallBase
- def install_phase
- odebug "Nothing to do. The zap artifact has no install phase."
- end
-
- def uninstall_phase
- odebug "Nothing to do. The zap artifact has no uninstall phase."
- end
-
def zap_phase
- expand_tilde = true
- dispatch_uninstall_directives(expand_tilde)
+ dispatch_uninstall_directives(expand_tilde: true)
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb
index 955ecdbb0..12cefb939 100644
--- a/Library/Homebrew/cask/lib/hbc/audit.rb
+++ b/Library/Homebrew/cask/lib/hbc/audit.rb
@@ -133,20 +133,19 @@ module Hbc
def check_appcast_checkpoint_accuracy
odebug "Verifying appcast checkpoint is accurate"
- result = @command.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, cask.appcast], print_stderr: false)
- if result.success?
- processed_appcast_text = result.stdout.gsub(%r{<pubDate>[^<]*</pubDate>}, "")
- # This step is necessary to replicate running `sed` from the command line
- processed_appcast_text << "\n" unless processed_appcast_text.end_with?("\n")
+ result = cask.appcast.calculate_checkpoint
+
+ actual_checkpoint = result[:checkpoint]
+
+ if actual_checkpoint.nil?
+ add_warning "error retrieving appcast: #{result[:command_result].stderr}"
+ else
expected = cask.appcast.checkpoint
- actual = Digest::SHA2.hexdigest(processed_appcast_text)
- add_warning <<-EOS.undent unless expected == actual
+ add_warning <<-EOS.undent unless expected == actual_checkpoint
appcast checkpoint mismatch
Expected: #{expected}
- Actual: #{actual}
+ Actual: #{actual_checkpoint}
EOS
- else
- add_warning "error retrieving appcast: #{result.stderr}"
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cache.rb b/Library/Homebrew/cask/lib/hbc/cache.rb
index e343da3fa..7b586528e 100644
--- a/Library/Homebrew/cask/lib/hbc/cache.rb
+++ b/Library/Homebrew/cask/lib/hbc/cache.rb
@@ -9,27 +9,10 @@ module Hbc
Hbc.cache.mkpath
end
- def migrate_legacy_cache
+ def delete_legacy_cache
return unless Hbc.legacy_cache.exist?
- ohai "Migrating cached files to #{Hbc.cache}..."
- Hbc.legacy_cache.children.select(&:symlink?).each do |symlink|
- file = symlink.readlink
-
- new_name = file.basename
- .sub(/\-((?:(\d|#{DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$/x,
- '--\1')
-
- renamed_file = Hbc.cache.join(new_name)
-
- if file.exist?
- puts "#{file} -> #{renamed_file}"
- FileUtils.mv(file, renamed_file)
- end
-
- FileUtils.rm(symlink)
- end
-
+ ohai "Deleting legacy cache at #{Hbc.legacy_cache}..."
FileUtils.remove_entry_secure(Hbc.legacy_cache)
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cask_loader.rb b/Library/Homebrew/cask/lib/hbc/cask_loader.rb
index 3875b30df..3fe02d7e1 100644
--- a/Library/Homebrew/cask/lib/hbc/cask_loader.rb
+++ b/Library/Homebrew/cask/lib/hbc/cask_loader.rb
@@ -32,22 +32,12 @@ module Hbc
end
def cask(header_token, &block)
- @klass = Cask
- build_cask(header_token, &block)
- end
-
- def test_cask(header_token, &block)
- @klass = TestCask
- build_cask(header_token, &block)
- end
-
- def build_cask(header_token, &block)
raise CaskTokenDoesNotMatchError.new(@token, header_token) unless @token == header_token
if @path.nil?
- @klass.new(@token, &block)
+ Cask.new(@token, &block)
else
- @klass.new(@token, sourcefile_path: @path, &block)
+ Cask.new(@token, sourcefile_path: @path, &block)
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb
index 42c3982ba..73ab121d2 100644
--- a/Library/Homebrew/cask/lib/hbc/cli.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli.rb
@@ -23,6 +23,7 @@ require "hbc/cli/zap"
require "hbc/cli/internal_use_base"
require "hbc/cli/internal_audit_modified_casks"
+require "hbc/cli/internal_appcast_checkpoint"
require "hbc/cli/internal_checkurl"
require "hbc/cli/internal_dump"
require "hbc/cli/internal_help"
@@ -141,13 +142,17 @@ module Hbc
end
def self.process(arguments)
+ unless ENV["MACOS_VERSION"].nil?
+ MacOS.full_version = ENV["MACOS_VERSION"]
+ end
+
command_string, *rest = *arguments
rest = process_options(rest)
command = Hbc.help ? "help" : lookup_command(command_string)
Hbc.default_tap.install unless Hbc.default_tap.installed?
Hbc.init if should_init?(command)
run_command(command, *rest)
- rescue CaskError, CaskSha256MismatchError => e
+ rescue CaskError, CaskSha256MismatchError, ArgumentError => e
msg = e.message
msg << e.backtrace.join("\n") if Hbc.debug
onoe msg
diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
index 84d8e1ebc..6b2f4caab 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
@@ -2,116 +2,39 @@ module Hbc
class CLI
class Doctor < Base
def self.run
- ohai "macOS Release:", render_with_none_as_error(MacOS.full_version)
- ohai "Hardware Architecture:", render_with_none_as_error("#{Hardware::CPU.type}-#{Hardware::CPU.bits}")
- ohai "Ruby Version:", render_with_none_as_error("#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}")
- ohai "Ruby Path:", render_with_none_as_error(RbConfig.ruby)
- # TODO: consider removing most Homebrew constants from doctor output
- ohai "Homebrew Version:", render_with_none_as_error(homebrew_version)
- ohai "Homebrew Executable Path:", render_with_none_as_error(HOMEBREW_BREW_FILE)
- ohai "Homebrew Cellar Path:", render_with_none_as_error(homebrew_cellar)
- ohai "Homebrew Repository Path:", render_with_none_as_error(HOMEBREW_REPOSITORY)
- ohai "Homebrew Origin:", render_with_none_as_error(homebrew_origin)
- ohai "Homebrew-Cask Version:", render_with_none_as_error(Hbc.full_version)
- ohai "Homebrew-Cask Install Location:", render_install_location
- ohai "Homebrew-Cask Staging Location:", render_staging_location(Hbc.caskroom)
- ohai "Homebrew-Cask Cached Downloads:", render_cached_downloads
- ohai "Homebrew-Cask Default Tap Path:", render_tap_paths(Hbc.default_tap.path)
- ohai "Homebrew-Cask Alternate Cask Taps:", render_tap_paths(alt_taps)
- ohai "Homebrew-Cask Default Tap Cask Count:", render_with_none_as_error(default_cask_count)
- ohai "Contents of $LOAD_PATH:", render_load_path($LOAD_PATH)
- ohai "Contents of $RUBYLIB Environment Variable:", render_env_var("RUBYLIB")
- ohai "Contents of $RUBYOPT Environment Variable:", render_env_var("RUBYOPT")
- ohai "Contents of $RUBYPATH Environment Variable:", render_env_var("RUBYPATH")
- ohai "Contents of $RBENV_VERSION Environment Variable:", render_env_var("RBENV_VERSION")
- ohai "Contents of $CHRUBY_VERSION Environment Variable:", render_env_var("CHRUBY_VERSION")
- ohai "Contents of $GEM_HOME Environment Variable:", render_env_var("GEM_HOME")
- ohai "Contents of $GEM_PATH Environment Variable:", render_env_var("GEM_PATH")
- ohai "Contents of $BUNDLE_PATH Environment Variable:", render_env_var("BUNDLE_PATH")
- ohai "Contents of $PATH Environment Variable:", render_env_var("PATH")
- ohai "Contents of $SHELL Environment Variable:", render_env_var("SHELL")
- ohai "Contents of Locale Environment Variables:", render_with_none(locale_variables)
- end
-
- def self.alt_taps
- Tap.select { |t| t.cask_dir && t != Hbc.default_tap }
- .map(&:path)
- end
-
- def self.default_cask_count
- Hbc.default_tap.cask_files.count
- rescue StandardError
- "0 #{error_string "Error reading #{Hbc.default_tap.path}"}"
- end
-
- def self.homebrew_origin
- homebrew_origin = notfound_string
- begin
- Dir.chdir(HOMEBREW_REPOSITORY) do
- homebrew_origin = SystemCommand.run("/usr/bin/git",
- args: %w[config --get remote.origin.url],
- print_stderr: false).stdout.strip
- end
- if homebrew_origin !~ /\S/
- homebrew_origin = "#{none_string} #{error_string}"
- elsif homebrew_origin !~ %r{(mxcl|Homebrew)/(home)?brew(\.git)?\Z}
- homebrew_origin.concat " #{error_string "warning: nonstandard origin"}"
- end
- rescue StandardError
- homebrew_origin = error_string "Not Found - Error running git"
- end
- homebrew_origin
- end
-
- def self.homebrew_cellar
- homebrew_constants("cellar")
- end
-
- def self.homebrew_version
- homebrew_constants("version")
- end
-
- def self.homebrew_taps
- Tap::TAP_DIRECTORY
- end
-
- def self.homebrew_constants(name)
- @homebrew_constants ||= {}
- return @homebrew_constants[name] if @homebrew_constants.key?(name)
- @homebrew_constants[name] = notfound_string
- begin
- @homebrew_constants[name] = SystemCommand.run!(HOMEBREW_BREW_FILE,
- args: ["--#{name}"],
- print_stderr: false)
- .stdout
- .strip
- if @homebrew_constants[name] !~ /\S/
- @homebrew_constants[name] = "#{none_string} #{error_string}"
- end
- path = Pathname.new(@homebrew_constants[name])
- @homebrew_constants[name] = path if path.exist?
- rescue StandardError
- @homebrew_constants[name] = error_string "Not Found - Error running brew"
- end
- @homebrew_constants[name]
+ ohai "Homebrew-Cask Version", Hbc.full_version
+ ohai "Homebrew-Cask Install Location", render_install_location
+ ohai "Homebrew-Cask Staging Location", render_staging_location(Hbc.caskroom)
+ ohai "Homebrew-Cask Cached Downloads", render_cached_downloads
+ ohai "Homebrew-Cask Taps:"
+ puts render_taps(Hbc.default_tap, *alt_taps)
+ ohai "Contents of $LOAD_PATH", render_load_path($LOAD_PATH)
+ ohai "Environment Variables"
+
+ environment_variables = [
+ "RUBYLIB",
+ "RUBYOPT",
+ "RUBYPATH",
+ "RBENV_VERSION",
+ "CHRUBY_VERSION",
+ "GEM_HOME",
+ "GEM_PATH",
+ "BUNDLE_PATH",
+ "PATH",
+ "SHELL",
+ ]
+
+ (locale_variables + environment_variables).sort.each(&method(:render_env_var))
end
def self.locale_variables
- ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).collect { |v| %Q(#{v}="#{ENV[v]}") }.sort.join("\n")
+ ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).sort
end
def self.none_string
"<NONE>"
end
- def self.legacy_tap_pattern
- /phinze/
- end
-
- def self.notfound_string
- Formatter.error("Not Found - Unknown Error")
- end
-
def self.error_string(string = "Error")
Formatter.error("(#{string})")
end
@@ -121,37 +44,42 @@ module Hbc
none_string
end
- def self.render_with_none_as_error(string)
- return string if !string.nil? && string.respond_to?(:to_s) && !string.to_s.empty?
- "#{none_string} #{error_string}"
+ def self.alt_taps
+ Tap.select { |t| t.cask_dir && t != Hbc.default_tap }
end
- def self.render_tap_paths(paths)
- paths = [paths] unless paths.respond_to?(:each)
- paths.collect do |dir|
- if dir.nil? || dir.to_s.empty?
+ def self.cask_count_for_tap(tap)
+ count = tap.cask_files.count
+ "#{count} #{count == 1 ? "cask" : "casks"}"
+ rescue StandardError
+ "0 #{error_string "error reading #{tap.path}"}"
+ end
+
+ def self.render_taps(*taps)
+ taps.collect do |tap|
+ if tap.path.nil? || tap.path.to_s.empty?
none_string
- elsif dir.to_s.match(legacy_tap_pattern)
- dir.to_s.concat(" #{error_string "Warning: legacy tap path"}")
else
- dir.to_s
+ "#{tap.path} (#{cask_count_for_tap(tap)})"
end
end
end
def self.render_env_var(var)
- if ENV.key?(var)
- %Q(#{var}="#{ENV[var]}")
- else
- none_string
- end
+ return unless ENV.key?(var)
+ var = %Q(#{var}="#{ENV[var]}")
+ puts user_tilde(var)
+ end
+
+ def self.user_tilde(path)
+ path.gsub(ENV["HOME"], "~")
end
# This could be done by calling into Homebrew, but the situation
# where "doctor" is needed is precisely the situation where such
# things are less dependable.
def self.render_install_location
- locations = Dir.glob(Pathname.new(homebrew_cellar).join("brew-cask", "*")).reverse
+ locations = Dir.glob(HOMEBREW_CELLAR.join("brew-cask", "*")).reverse
if locations.empty?
none_string
else
@@ -162,7 +90,7 @@ module Hbc
end
def self.render_staging_location(path)
- path = Pathname.new(path)
+ path = Pathname.new(user_tilde(path.to_s))
if !path.exist?
"#{path} #{error_string "error: path does not exist"}}"
elsif !path.writable?
@@ -173,19 +101,18 @@ module Hbc
end
def self.render_load_path(paths)
+ paths.map(&method(:user_tilde))
return "#{none_string} #{error_string}" if [*paths].empty?
paths
end
def self.render_cached_downloads
cleanup = CLI::Cleanup.default
- files = cleanup.cache_files
- count = files.count
+ count = cleanup.cache_files.count
size = cleanup.disk_cleanup_size
- size_msg = "#{number_readable(count)} files, #{disk_usage_readable(size)}"
- warn_msg = error_string('warning: run "brew cask cleanup"')
- size_msg << " #{warn_msg}" if count > 0
- [Hbc.cache, size_msg]
+ msg = user_tilde(Hbc.cache.to_s)
+ msg << " (#{number_readable(count)} files, #{disk_usage_readable(size)})" unless count.zero?
+ msg
end
def self.help
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb
new file mode 100644
index 000000000..790e917b2
--- /dev/null
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb
@@ -0,0 +1,61 @@
+module Hbc
+ class CLI
+ class InternalAppcastCheckpoint < InternalUseBase
+ def self.run(*args)
+ calculate = args.include? "--calculate"
+ cask_tokens = cask_tokens_from(args)
+ raise CaskUnspecifiedError if cask_tokens.empty?
+
+ if cask_tokens.all? { |t| t =~ %r{^https?://} && t !~ /\.rb$/ }
+ appcask_checkpoint_for_url(cask_tokens)
+ else
+ appcask_checkpoint(cask_tokens, calculate)
+ end
+ end
+
+ def self.appcask_checkpoint_for_url(urls)
+ urls.each do |url|
+ appcast = DSL::Appcast.new(url)
+ puts appcast.calculate_checkpoint[:checkpoint]
+ end
+ end
+
+ def self.appcask_checkpoint(cask_tokens, calculate)
+ count = 0
+
+ cask_tokens.each do |cask_token|
+ cask = Hbc.load(cask_token)
+
+ if cask.appcast.nil?
+ opoo "Cask '#{cask}' is missing an `appcast` stanza."
+ else
+ if calculate
+ result = cask.appcast.calculate_checkpoint
+
+ checkpoint = result[:checkpoint]
+ else
+ checkpoint = cask.appcast.checkpoint
+ end
+
+ if checkpoint.nil?
+ onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}"
+ else
+ puts cask_tokens.count > 1 ? "#{checkpoint} #{cask}": checkpoint
+ count += 1
+ end
+ end
+ end
+
+ count == cask_tokens.count
+ end
+
+ def self.help
+ "prints or calculates a given Cask's or URL's appcast checkpoint"
+ end
+
+ def self.needs_init?
+ true
+ end
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb
index af1494e5f..ac1b20493 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb
@@ -27,7 +27,7 @@ module Hbc
end
def self.help
- "Dump the given Cask in YAML format"
+ "dump the given Cask in YAML format"
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb
index 6c646cfd7..0908ee05e 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb
@@ -16,7 +16,7 @@ module Hbc
end
def self.help
- "Print help strings for unstable internal-use commands"
+ "print help strings for unstable internal-use commands"
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
index e5c04ee51..c54db8795 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
@@ -44,18 +44,20 @@ module Hbc
:stage_only,
:nested_container,
:uninstall,
- :postflight,
- :uninstall_postflight,
:preflight,
+ :postflight,
+ :uninstall_preflight,
:uninstall_postflight,
]
- def self.run(*arguments)
- table = arguments.include? "--table"
- quiet = arguments.include? "--quiet"
- format = :to_yaml if arguments.include? "--yaml"
- format = :inspect if arguments.include? "--inspect"
- cask_tokens = arguments.reject { |arg| arg.chars.first == "-" }
+ def self.run(*args)
+ raise ArgumentError, "No stanza given." if args.empty?
+
+ table = args.include? "--table"
+ quiet = args.include? "--quiet"
+ format = :to_yaml if args.include? "--yaml"
+ format = :inspect if args.include? "--inspect"
+ cask_tokens = cask_tokens_from(args)
stanza = cask_tokens.shift.to_sym
cask_tokens = Hbc.all_tokens if cask_tokens.empty?
@@ -125,7 +127,7 @@ module Hbc
end
def self.help
- "Extract and render a specific stanza for the given Casks"
+ "extract and render a specific stanza for the given Casks"
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb
index 4094b3d38..e100fbd83 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/list.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb
@@ -55,7 +55,7 @@ module Hbc
def self.list_artifacts(cask)
Artifact.for_cask(cask).each do |artifact|
- summary = artifact.new(cask).summary
+ summary = artifact.summary
ohai summary[:english_description], summary[:contents] unless summary.empty?
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/container.rb b/Library/Homebrew/cask/lib/hbc/container.rb
index e31fbc8fb..fc7246f3d 100644
--- a/Library/Homebrew/cask/lib/hbc/container.rb
+++ b/Library/Homebrew/cask/lib/hbc/container.rb
@@ -16,7 +16,6 @@ require "hbc/container/tar"
require "hbc/container/ttf"
require "hbc/container/rar"
require "hbc/container/xar"
-require "hbc/container/xip"
require "hbc/container/xz"
require "hbc/container/zip"
@@ -34,7 +33,6 @@ module Hbc
Sit,
Rar,
Zip,
- Xip, # needs to be before xar as this is a cpio inside a gzip inside a xar
Xar, # need to be before tar as tar can also list xar
Tar, # or compressed tar (bzip2/gzip/lzma/xz)
Bzip2, # pure bzip2
diff --git a/Library/Homebrew/cask/lib/hbc/container/dmg.rb b/Library/Homebrew/cask/lib/hbc/container/dmg.rb
index 987455ad7..815f8f010 100644
--- a/Library/Homebrew/cask/lib/hbc/container/dmg.rb
+++ b/Library/Homebrew/cask/lib/hbc/container/dmg.rb
@@ -43,11 +43,16 @@ module Hbc
next unless mountpath.exist?
begin
- tries ||= 2
- @command.run("/usr/sbin/diskutil",
- args: ["eject", mountpath],
- print_stderr: false)
-
+ tries ||= 3
+ if tries > 1
+ @command.run("/usr/sbin/diskutil",
+ args: ["eject", mountpath],
+ print_stderr: false)
+ else
+ @command.run("/usr/sbin/diskutil",
+ args: ["unmount", "force", mountpath],
+ print_stderr: false)
+ end
raise CaskError, "Failed to eject #{mountpath}" if mountpath.exist?
rescue CaskError => e
raise e if (tries -= 1).zero?
diff --git a/Library/Homebrew/cask/lib/hbc/container/xip.rb b/Library/Homebrew/cask/lib/hbc/container/xip.rb
deleted file mode 100644
index 982402e4e..000000000
--- a/Library/Homebrew/cask/lib/hbc/container/xip.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require "tmpdir"
-
-module Hbc
- class Container
- class Xip < Base
- def self.me?(criteria)
- criteria.magic_number(/^xar!/n) &&
- IO.popen(["/usr/bin/xar", "-t", "-f", criteria.path.to_s], err: "/dev/null") { |io| io.read =~ /\AContent\nMetadata\n\Z/ }
- end
-
- def extract
- Dir.mktmpdir do |unpack_dir|
- begin
- ohai "Verifying signature for #{@path.basename}"
- @command.run!("/usr/sbin/pkgutil", args: ["--check-signature", @path])
- rescue
- raise "Signature check failed."
- end
-
- @command.run!("/usr/bin/xar", args: ["-x", "-f", @path, "Content", "-C", unpack_dir])
-
- Dir.chdir(@cask.staged_path) do
- @command.run!("/usr/bin/cpio", args: ["--quiet", "-i", "-I", Pathname(unpack_dir).join("Content")])
- end
- end
- end
- end
- end
-end
diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb
index c62873665..4707ae76a 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl.rb
@@ -270,14 +270,17 @@ module Hbc
ORDINARY_ARTIFACT_TYPES.each do |type|
define_method(type) do |*args|
- if type == :stage_only && args != [true]
- raise CaskInvalidError.new(token, "'stage_only' takes a single argument: true")
- end
- artifacts[type] << args
- if artifacts.key?(:stage_only) && artifacts.keys.count > 1 &&
- !(artifacts.keys & ACTIVATABLE_ARTIFACT_TYPES).empty?
- raise CaskInvalidError.new(token, "'stage_only' must be the only activatable artifact")
+ if type == :stage_only
+ if args != [true]
+ raise CaskInvalidError.new(token, "'stage_only' takes a single argument: true")
+ end
+
+ unless (artifacts.keys & ACTIVATABLE_ARTIFACT_TYPES).empty?
+ raise CaskInvalidError.new(token, "'stage_only' must be the only activatable artifact")
+ end
end
+
+ artifacts[type].add(args)
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb
index 2f1245d3d..e27870622 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb
@@ -1,3 +1,5 @@
+require "hbc/system_command"
+
module Hbc
class DSL
class Appcast
@@ -9,6 +11,20 @@ module Hbc
@checkpoint = @parameters[:checkpoint]
end
+ def calculate_checkpoint
+ result = SystemCommand.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, @uri], print_stderr: false)
+
+ checkpoint = if result.success?
+ processed_appcast_text = result.stdout.gsub(%r{<pubDate>[^<]*</pubDate>}m, "")
+ Digest::SHA2.hexdigest(processed_appcast_text)
+ end
+
+ {
+ checkpoint: checkpoint,
+ command_result: result,
+ }
+ end
+
def to_yaml
[@uri, @parameters].to_yaml
end
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 3875e1c8f..cafc9d8b9 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -133,22 +133,23 @@ module Hbc
def install_artifacts
already_installed_artifacts = []
- options = { command: @command, force: force }
odebug "Installing artifacts"
- artifacts = Artifact.for_cask(@cask)
+ artifacts = Artifact.for_cask(@cask, command: @command, force: force)
odebug "#{artifacts.length} artifact/s defined", artifacts
artifacts.each do |artifact|
- odebug "Installing artifact of class #{artifact}"
+ next unless artifact.respond_to?(:install_phase)
+ odebug "Installing artifact of class #{artifact.class}"
+ artifact.install_phase
already_installed_artifacts.unshift(artifact)
- artifact.new(@cask, options).install_phase
end
rescue StandardError => e
begin
already_installed_artifacts.each do |artifact|
- odebug "Reverting installation of artifact of class #{artifact}"
- artifact.new(@cask, options).uninstall_phase
+ next unless artifact.respond_to?(:uninstall_phase)
+ odebug "Reverting installation of artifact of class #{artifact.class}"
+ artifact.uninstall_phase
end
ensure
purge_versioned_files
@@ -316,12 +317,12 @@ module Hbc
def uninstall_artifacts
odebug "Un-installing artifacts"
- artifacts = Artifact.for_cask(@cask)
+ artifacts = Artifact.for_cask(@cask, command: @command, force: force)
odebug "#{artifacts.length} artifact/s defined", artifacts
artifacts.each do |artifact|
- odebug "Un-installing artifact of class #{artifact}"
- options = { command: @command, force: force }
- artifact.new(@cask, options).uninstall_phase
+ next unless artifact.respond_to?(:uninstall_phase)
+ odebug "Un-installing artifact of class #{artifact.class}"
+ artifact.uninstall_phase
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/pkg.rb b/Library/Homebrew/cask/lib/hbc/pkg.rb
index 2fb634f24..39252b48a 100644
--- a/Library/Homebrew/cask/lib/hbc/pkg.rb
+++ b/Library/Homebrew/cask/lib/hbc/pkg.rb
@@ -26,6 +26,7 @@ module Hbc
_deepest_path_first(pkgutil_bom_dirs).each do |dir|
next unless dir.exist? && !MacOS.undeletable?(dir)
_with_full_permissions(dir) do
+ _delete_broken_file_dir(dir) && next
_clean_broken_symlinks(dir)
_clean_ds_store(dir)
_rmdir(dir)
@@ -97,6 +98,13 @@ module Hbc
end
end
+ # Some pkgs incorrectly report files (generally nibs)
+ # as directories; we remove these as files instead.
+ def _delete_broken_file_dir(path)
+ return unless path.file? && !path.symlink?
+ @command.run!("/bin/rm", args: ["-f", "--", path], sudo: true)
+ end
+
# Some pkgs leave broken symlinks hanging around; we clean them out before
# attempting to rmdir to prevent extra cruft from lying around after
# uninstall
diff --git a/Library/Homebrew/cask/lib/hbc/staged.rb b/Library/Homebrew/cask/lib/hbc/staged.rb
index dcc05ef5d..c1aa01b29 100644
--- a/Library/Homebrew/cask/lib/hbc/staged.rb
+++ b/Library/Homebrew/cask/lib/hbc/staged.rb
@@ -27,7 +27,7 @@ module Hbc
full_paths = remove_nonexistent(paths)
return if full_paths.empty?
@command.run!("/bin/chmod", args: ["-R", "--", permissions_str] + full_paths,
- sudo: true)
+ sudo: false)
end
def set_ownership(paths, user: current_user, group: "staff")
diff --git a/Library/Homebrew/cask/spec/cask/accessibility_spec.rb b/Library/Homebrew/cask/spec/cask/accessibility_spec.rb
new file mode 100644
index 000000000..8787a2c6d
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/accessibility_spec.rb
@@ -0,0 +1,82 @@
+require "spec_helper"
+
+# TODO: this test should be named after the corresponding class, once
+# that class is abstracted from installer.rb.
+describe "Accessibility Access" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-accessibility-access.rb") }
+ let(:fake_system_command) { class_double(Hbc::SystemCommand) }
+ let(:installer) { Hbc::Installer.new(cask, command: fake_system_command) }
+
+ before(:each) do
+ allow(MacOS).to receive(:version).and_return(MacOS::Version.new(macos_version))
+ allow(installer).to receive(:bundle_identifier).and_return("com.example.BasicCask")
+ end
+
+ context "on MacOS 10.8 and below" do
+ let(:macos_version) { "10.8" }
+
+ it "can enable accessibility access in macOS releases prior to Mavericks" do
+ expect(fake_system_command).to receive(:run!).with(
+ "/usr/bin/touch",
+ args: [Hbc.pre_mavericks_accessibility_dotfile],
+ sudo: true
+ )
+
+ shutup do
+ installer.enable_accessibility_access
+ end
+ end
+
+ it "warns about disabling accessibility access on old macOS releases" do
+ expect {
+ installer.disable_accessibility_access
+ }.to output(/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./).to_stderr
+ end
+ end
+
+ context "on MacOS 10.9" do
+ let(:macos_version) { "10.9" }
+
+ it "can enable accessibility access" do
+ expect(fake_system_command).to receive(:run!).with(
+ "/usr/bin/sqlite3",
+ args: [Hbc.tcc_db, "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);"],
+ sudo: true
+ )
+
+ shutup do
+ installer.enable_accessibility_access
+ end
+ end
+
+ it "can disable accessibility access" do
+ expect(fake_system_command).to receive(:run!).with(
+ "/usr/bin/sqlite3",
+ args: [Hbc.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"],
+ sudo: true
+ )
+
+ shutup do
+ installer.disable_accessibility_access
+ end
+ end
+ end
+
+ context "on MacOS 10.12 and above" do
+ let(:macos_version) { "10.12" }
+
+ it "warns about enabling accessibility access on new macOS releases" do
+ expect {
+ expect {
+ installer.enable_accessibility_access
+ }.to output.to_stdout
+ }.to output(/Warning: Accessibility access cannot be enabled automatically on this version of macOS\./).to_stderr
+ end
+
+ it "warns about disabling accessibility access on new macOS releases" do
+ expect {
+ installer.disable_accessibility_access
+ }.to output(/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./).to_stderr
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb b/Library/Homebrew/cask/spec/cask/artifact/alt_target_spec.rb
index d1fe26eaa..9a57a9878 100644
--- a/Library/Homebrew/cask/test/cask/artifact/alt_target_test.rb
+++ b/Library/Homebrew/cask/spec/cask/artifact/alt_target_spec.rb
@@ -1,8 +1,8 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::Artifact::App do
describe "activate to alternate target" do
- let(:cask) { Hbc.load("with-alt-target") }
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-alt-target.rb") }
let(:install_phase) {
-> { Hbc::Artifact::App.new(cask).install_phase }
@@ -12,19 +12,19 @@ describe Hbc::Artifact::App do
let(:target_path) { Hbc.appdir.join("AnotherName.app") }
before do
- TestHelper.install_without_artifacts(cask)
+ InstallHelper.install_without_artifacts(cask)
end
it "installs the given apps using the proper target directory" do
- source_path.must_be :directory?
- target_path.wont_be :exist?
+ expect(source_path).to be_a_directory
+ expect(target_path).not_to exist
shutup do
install_phase.call
end
- target_path.must_be :directory?
- source_path.wont_be :exist?
+ expect(target_path).to be_a_directory
+ expect(source_path).not_to exist
end
describe "when app is in a subdirectory" do
@@ -46,8 +46,8 @@ describe Hbc::Artifact::App do
install_phase.call
end
- target_path.must_be :directory?
- appsubdir.join("Caffeine.app").wont_be :exist?
+ expect(target_path).to be_a_directory
+ expect(appsubdir.join("Caffeine.app")).not_to exist
end
end
@@ -59,23 +59,21 @@ describe Hbc::Artifact::App do
install_phase.call
end
- target_path.must_be :directory?
- source_path.wont_be :exist?
+ expect(target_path).to be_a_directory
+ expect(source_path).not_to exist
- Hbc.appdir.join("Caffeine Deluxe.app").wont_be :exist?
- cask.staged_path.join("Caffeine Deluxe.app").must_be :directory?
+ expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist
+ expect(cask.staged_path.join("Caffeine Deluxe.app")).to be_a_directory
end
it "avoids clobbering an existing app by moving over it" do
target_path.mkpath
- err = install_phase.must_raise(Hbc::CaskError)
+ expect(install_phase).to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.")
- err.message.must_equal("It seems there is already an App at '#{target_path}'.")
-
- source_path.must_be :directory?
- target_path.must_be :directory?
- File.identical?(source_path, target_path).must_equal false
+ expect(source_path).to be_a_directory
+ expect(target_path).to be_a_directory
+ expect(File.identical?(source_path, target_path)).to be false
end
end
end
diff --git a/Library/Homebrew/cask/test/cask/artifact/app_test.rb b/Library/Homebrew/cask/spec/cask/artifact/app_spec.rb
index 3eeeb729f..b3877f000 100644
--- a/Library/Homebrew/cask/test/cask/artifact/app_test.rb
+++ b/Library/Homebrew/cask/spec/cask/artifact/app_spec.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::Artifact::App do
- let(:cask) { Hbc.load("local-caffeine") }
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") }
let(:command) { Hbc::SystemCommand }
let(:force) { false }
let(:app) { Hbc::Artifact::App.new(cask, command: command, force: force) }
@@ -12,8 +12,8 @@ describe Hbc::Artifact::App do
let(:install_phase) { -> { app.install_phase } }
let(:uninstall_phase) { -> { app.uninstall_phase } }
- before do
- TestHelper.install_without_artifacts(cask)
+ before(:each) do
+ InstallHelper.install_without_artifacts(cask)
end
describe "install_phase" do
@@ -22,8 +22,8 @@ describe Hbc::Artifact::App do
install_phase.call
end
- target_path.must_be :directory?
- source_path.wont_be :exist?
+ expect(target_path).to be_a_directory
+ expect(source_path).not_to exist
end
describe "when app is in a subdirectory" do
@@ -45,8 +45,8 @@ describe Hbc::Artifact::App do
install_phase.call
end
- target_path.must_be :directory?
- appsubdir.join("Caffeine.app").wont_be :exist?
+ expect(target_path).to be_a_directory
+ expect(appsubdir.join("Caffeine.app")).not_to exist
end
end
@@ -58,36 +58,34 @@ describe Hbc::Artifact::App do
install_phase.call
end
- target_path.must_be :directory?
- source_path.wont_be :exist?
+ expect(target_path).to be_a_directory
+ expect(source_path).not_to exist
- Hbc.appdir.join("Caffeine Deluxe.app").wont_be :exist?
- cask.staged_path.join("Caffeine Deluxe.app").must_be :exist?
+ expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist
+ expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
end
describe "when the target already exists" do
- before do
+ before(:each) do
target_path.mkpath
end
it "avoids clobbering an existing app" do
- err = install_phase.must_raise(Hbc::CaskError)
+ expect(install_phase).to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.")
- err.message.must_equal("It seems there is already an App at '#{target_path}'.")
-
- source_path.must_be :directory?
- target_path.must_be :directory?
- File.identical?(source_path, target_path).must_equal false
+ expect(source_path).to be_a_directory
+ expect(target_path).to be_a_directory
+ expect(File.identical?(source_path, target_path)).to be false
contents_path = target_path.join("Contents/Info.plist")
- contents_path.wont_be :exist?
+ expect(contents_path).not_to exist
end
describe "given the force option" do
let(:force) { true }
- before do
- Hbc::Utils.stubs(current_user: "fake_user")
+ before(:each) do
+ allow(Hbc::Utils).to receive(:current_user).and_return("fake_user")
end
describe "target is both writable and user-owned" do
@@ -101,40 +99,31 @@ describe Hbc::Artifact::App do
Warning: It seems there is already an App at '#{target_path}'; overwriting.
EOS
- install_phase.must_output(stdout, stderr)
+ expect {
+ expect(install_phase).to output(stdout).to_stdout
+ }.to output(stderr).to_stderr
- source_path.wont_be :exist?
- target_path.must_be :directory?
+ expect(source_path).not_to exist
+ expect(target_path).to be_a_directory
contents_path = target_path.join("Contents/Info.plist")
- contents_path.must_be :exist?
+ expect(contents_path).to exist
end
end
describe "target is user-owned but contains read-only files" do
- let(:command) { Hbc::FakeSystemCommand }
-
- let(:chmod_cmd) {
- ["/bin/chmod", "-R", "--", "u+rwx", target_path]
- }
-
- let(:chmod_n_cmd) {
- ["/bin/chmod", "-R", "-N", target_path]
- }
-
- let(:chflags_cmd) {
- ["/usr/bin/chflags", "-R", "--", "000", target_path]
- }
-
- before do
+ before(:each) do
system "/usr/bin/touch", "--", "#{target_path}/foo"
system "/bin/chmod", "--", "0555", target_path
end
it "overwrites the existing app" do
- command.expect_and_pass_through(chflags_cmd)
- command.expect_and_pass_through(chmod_cmd)
- command.expect_and_pass_through(chmod_n_cmd)
+ expect(command).to receive(:run).with("/bin/chmod", args: ["-R", "--", "u+rwx", target_path], must_succeed: false)
+ .and_call_original
+ expect(command).to receive(:run).with("/bin/chmod", args: ["-R", "-N", target_path], must_succeed: false)
+ .and_call_original
+ expect(command).to receive(:run).with("/usr/bin/chflags", args: ["-R", "--", "000", target_path], must_succeed: false)
+ .and_call_original
stdout = <<-EOS.undent
==> Removing App: '#{target_path}'
@@ -145,16 +134,18 @@ describe Hbc::Artifact::App do
Warning: It seems there is already an App at '#{target_path}'; overwriting.
EOS
- install_phase.must_output(stdout, stderr)
+ expect {
+ expect(install_phase).to output(stdout).to_stdout
+ }.to output(stderr).to_stderr
- source_path.wont_be :exist?
- target_path.must_be :directory?
+ expect(source_path).not_to exist
+ expect(target_path).to be_a_directory
contents_path = target_path.join("Contents/Info.plist")
- contents_path.must_be :exist?
+ expect(contents_path).to exist
end
- after do
+ after(:each) do
system "/bin/chmod", "--", "0755", target_path
end
end
@@ -164,18 +155,15 @@ describe Hbc::Artifact::App do
describe "when the target is a broken symlink" do
let(:deleted_path) { cask.staged_path.join("Deleted.app") }
- before do
+ before(:each) do
deleted_path.mkdir
File.symlink(deleted_path, target_path)
deleted_path.rmdir
end
it "leaves the target alone" do
- err = install_phase.must_raise(Hbc::CaskError)
-
- err.message.must_equal("It seems there is already an App at '#{target_path}'.")
-
- File.symlink?(target_path).must_equal true
+ expect(install_phase).to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path}'.")
+ expect(target_path).to be_a_symlink
end
describe "given the force option" do
@@ -191,13 +179,15 @@ describe Hbc::Artifact::App do
Warning: It seems there is already an App at '#{target_path}'; overwriting.
EOS
- install_phase.must_output(stdout, stderr)
+ expect {
+ expect(install_phase).to output(stdout).to_stdout
+ }.to output(stderr).to_stderr
- source_path.wont_be :exist?
- target_path.must_be :directory?
+ expect(source_path).not_to exist
+ expect(target_path).to be_a_directory
contents_path = target_path.join("Contents/Info.plist")
- contents_path.must_be :exist?
+ expect(contents_path).to exist
end
end
end
@@ -207,26 +197,23 @@ describe Hbc::Artifact::App do
message = "It seems the App source is not there: '#{source_path}'"
- error = install_phase.must_raise(Hbc::CaskError)
- error.message.must_equal message
+ expect(install_phase).to raise_error(Hbc::CaskError, message)
end
end
describe "uninstall_phase" do
- before do
+ it "deletes managed apps" do
shutup do
install_phase.call
end
- end
- it "deletes managed apps" do
- target_path.must_be :exist?
+ expect(target_path).to exist
shutup do
uninstall_phase.call
end
- target_path.wont_be :exist?
+ expect(target_path).not_to exist
end
end
@@ -235,25 +222,23 @@ describe Hbc::Artifact::App do
let(:contents) { app.summary[:contents] }
it "returns the correct english_description" do
- description.must_equal "Apps"
+ expect(description).to eq("Apps")
end
describe "app is correctly installed" do
- before do
+ it "returns the path to the app" do
shutup do
install_phase.call
end
- end
- it "returns the path to the app" do
- contents.must_equal ["#{target_path} (#{target_path.abv})"]
+ expect(contents).to eq(["#{target_path} (#{target_path.abv})"])
end
end
describe "app is missing" do
it "returns a warning and the supposed path to the app" do
- contents.size.must_equal 1
- contents[0].must_match(/.*Missing App.*: #{target_path}/)
+ expect(contents.size).to eq(1)
+ expect(contents[0]).to match(/.*Missing App.*: #{target_path}/)
end
end
end
diff --git a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb
index fbb117f67..c27dcc8f0 100644
--- a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb
@@ -1,6 +1,6 @@
describe Hbc::Artifact::Binary do
let(:cask) {
- Hbc.load("with-binary").tap do |cask|
+ Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb").tap do |cask|
shutup do
InstallHelper.install_without_artifacts(cask)
end
@@ -20,7 +20,8 @@ describe Hbc::Artifact::Binary do
shutup do
Hbc::Artifact::Binary.new(cask).install_phase
end
- expect(FileHelper.valid_alias?(expected_path)).to be true
+ expect(expected_path).to be_a_symlink
+ expect(expected_path.readlink).to exist
end
it "avoids clobbering an existing binary by linking over it" do
@@ -69,7 +70,7 @@ describe Hbc::Artifact::Binary do
context "binary is inside an app package" do
let(:cask) {
- Hbc.load("with-embedded-binary").tap do |cask|
+ Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-embedded-binary.rb").tap do |cask|
shutup do
InstallHelper.install_without_artifacts(cask)
end
@@ -82,7 +83,8 @@ describe Hbc::Artifact::Binary do
Hbc::Artifact::Binary.new(cask).install_phase
end
- expect(FileHelper.valid_alias?(expected_path)).to be true
+ expect(expected_path).to be_a_symlink
+ expect(expected_path.readlink).to exist
end
end
end
diff --git a/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb
new file mode 100644
index 000000000..7d9128c0e
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/artifact/generic_artifact_spec.rb
@@ -0,0 +1,47 @@
+require "spec_helper"
+
+describe Hbc::Artifact::Artifact do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") }
+
+ let(:install_phase) {
+ -> { Hbc::Artifact::Artifact.new(cask).install_phase }
+ }
+
+ let(:source_path) { cask.staged_path.join("Caffeine.app") }
+ let(:target_path) { Hbc.appdir.join("Caffeine.app") }
+
+ before do
+ InstallHelper.install_without_artifacts(cask)
+ end
+
+ describe "with no target" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact-no-target.rb") }
+
+ it "fails to install with no target" do
+ expect(install_phase).to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+
+ it "moves the artifact to the proper directory" do
+ shutup do
+ install_phase.call
+ end
+
+ expect(target_path).to be_a_directory
+ expect(source_path).not_to exist
+ end
+
+ it "avoids clobbering an existing artifact" do
+ target_path.mkpath
+
+ expect {
+ shutup do
+ install_phase.call
+ end
+ }.to raise_error(Hbc::CaskError)
+
+ expect(source_path).to be_a_directory
+ expect(target_path).to be_a_directory
+ expect(File.identical?(source_path, target_path)).to be false
+ end
+end
diff --git a/Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb
new file mode 100644
index 000000000..31a1cb5eb
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/artifact/nested_container_spec.rb
@@ -0,0 +1,17 @@
+require "spec_helper"
+
+describe Hbc::Artifact::NestedContainer do
+ describe "install" do
+ it "extracts the specified paths as containers" do
+ cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb").tap do |c|
+ InstallHelper.install_without_artifacts(c)
+ end
+
+ shutup do
+ Hbc::Artifact::NestedContainer.new(cask).install_phase
+ end
+
+ expect(cask.staged_path.join("MyNestedApp.app")).to be_a_directory
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb
new file mode 100644
index 000000000..d4d69ea66
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb
@@ -0,0 +1,71 @@
+require "spec_helper"
+
+describe Hbc::Artifact::Pkg do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") }
+ let(:fake_system_command) { class_double(Hbc::SystemCommand) }
+
+ before(:each) do
+ shutup do
+ InstallHelper.install_without_artifacts(cask)
+ end
+ end
+
+ describe "install_phase" do
+ it "runs the system installer on the specified pkgs" do
+ pkg = Hbc::Artifact::Pkg.new(cask, command: fake_system_command)
+
+ expect(fake_system_command).to receive(:run!).with(
+ "/usr/sbin/installer",
+ args: ["-pkg", cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/"],
+ sudo: true,
+ print_stdout: true
+ )
+
+ shutup do
+ pkg.install_phase
+ end
+ end
+ end
+
+ describe "choices" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb") }
+
+ it "passes the choice changes xml to the system installer" do
+ pkg = Hbc::Artifact::Pkg.new(cask, command: fake_system_command)
+
+ file = double(path: Pathname.new("/tmp/choices.xml"))
+
+ expect(file).to receive(:write).with(<<-EOS.undent)
+ <?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+ <plist version="1.0">
+ <array>
+ \t<dict>
+ \t\t<key>attributeSetting</key>
+ \t\t<integer>1</integer>
+ \t\t<key>choiceAttribute</key>
+ \t\t<string>selected</string>
+ \t\t<key>choiceIdentifier</key>
+ \t\t<string>choice1</string>
+ \t</dict>
+ </array>
+ </plist>
+ EOS
+
+ expect(file).to receive(:close)
+ expect(file).to receive(:unlink)
+ expect(Tempfile).to receive(:open).and_yield(file)
+
+ expect(fake_system_command).to receive(:run!).with(
+ "/usr/sbin/installer",
+ args: ["-pkg", cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/", "-applyChoiceChangesXML", cask.staged_path.join("/tmp/choices.xml")],
+ sudo: true,
+ print_stdout: true
+ )
+
+ shutup do
+ pkg.install_phase
+ end
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/test/cask/artifact/postflight_block_test.rb b/Library/Homebrew/cask/spec/cask/artifact/postflight_block_spec.rb
index 47dcdd905..6f58afb2a 100644
--- a/Library/Homebrew/cask/test/cask/artifact/postflight_block_test.rb
+++ b/Library/Homebrew/cask/spec/cask/artifact/postflight_block_spec.rb
@@ -1,9 +1,9 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::Artifact::PostflightBlock do
describe "install_phase" do
it "calls the specified block after installing, passing a Cask mini-dsl" do
- called = false
+ called = false
yielded_arg = nil
cask = Hbc::Cask.new("with-postflight") do
@@ -13,16 +13,16 @@ describe Hbc::Artifact::PostflightBlock do
end
end
- Hbc::Artifact::PostflightBlock.new(cask).install_phase
+ described_class.new(cask).install_phase
- called.must_equal true
- yielded_arg.must_be_kind_of Hbc::DSL::Postflight
+ expect(called).to be true
+ expect(yielded_arg).to be_kind_of(Hbc::DSL::Postflight)
end
end
describe "uninstall_phase" do
it "calls the specified block after uninstalling, passing a Cask mini-dsl" do
- called = false
+ called = false
yielded_arg = nil
cask = Hbc::Cask.new("with-uninstall-postflight") do
@@ -32,10 +32,10 @@ describe Hbc::Artifact::PostflightBlock do
end
end
- Hbc::Artifact::PostflightBlock.new(cask).uninstall_phase
+ described_class.new(cask).uninstall_phase
- called.must_equal true
- yielded_arg.must_be_kind_of Hbc::DSL::UninstallPostflight
+ expect(called).to be true
+ expect(yielded_arg).to be_kind_of(Hbc::DSL::UninstallPostflight)
end
end
end
diff --git a/Library/Homebrew/cask/test/cask/artifact/preflight_block_test.rb b/Library/Homebrew/cask/spec/cask/artifact/preflight_block_spec.rb
index 440b1db3a..ac5313bca 100644
--- a/Library/Homebrew/cask/test/cask/artifact/preflight_block_test.rb
+++ b/Library/Homebrew/cask/spec/cask/artifact/preflight_block_spec.rb
@@ -1,9 +1,9 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::Artifact::PreflightBlock do
describe "install_phase" do
it "calls the specified block before installing, passing a Cask mini-dsl" do
- called = false
+ called = false
yielded_arg = nil
cask = Hbc::Cask.new("with-preflight") do
@@ -13,16 +13,16 @@ describe Hbc::Artifact::PreflightBlock do
end
end
- Hbc::Artifact::PreflightBlock.new(cask).install_phase
+ described_class.new(cask).install_phase
- called.must_equal true
- yielded_arg.must_be_kind_of Hbc::DSL::Preflight
+ expect(called).to be true
+ expect(yielded_arg).to be_kind_of Hbc::DSL::Preflight
end
end
describe "uninstall_phase" do
it "calls the specified block before uninstalling, passing a Cask mini-dsl" do
- called = false
+ called = false
yielded_arg = nil
cask = Hbc::Cask.new("with-uninstall-preflight") do
@@ -32,10 +32,10 @@ describe Hbc::Artifact::PreflightBlock do
end
end
- Hbc::Artifact::PreflightBlock.new(cask).uninstall_phase
+ described_class.new(cask).uninstall_phase
- called.must_equal true
- yielded_arg.must_be_kind_of Hbc::DSL::UninstallPreflight
+ expect(called).to be true
+ expect(yielded_arg).to be_kind_of Hbc::DSL::UninstallPreflight
end
end
end
diff --git a/Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb
new file mode 100644
index 000000000..79ca0546c
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/artifact/suite_spec.rb
@@ -0,0 +1,49 @@
+require "spec_helper"
+
+describe Hbc::Artifact::Suite do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-suite.rb") }
+
+ let(:install_phase) { -> { Hbc::Artifact::Suite.new(cask).install_phase } }
+
+ let(:target_path) { Hbc.appdir.join("Caffeine") }
+ let(:source_path) { cask.staged_path.join("Caffeine") }
+
+ before(:each) do
+ InstallHelper.install_without_artifacts(cask)
+ end
+
+ it "moves the suite to the proper directory" do
+ skip("flaky test") # FIXME
+
+ shutup do
+ install_phase.call
+ end
+
+ expect(target_path).to be_a_directory
+ expect(target_path).to be_a_symlink
+ expect(target_path.readlink).to exist
+ expect(source_path).not_to exist
+ end
+
+ it "creates a suite containing the expected app" do
+ shutup do
+ install_phase.call
+ end
+
+ expect(target_path.join("Caffeine.app")).to exist
+ end
+
+ it "avoids clobbering an existing suite by moving over it" do
+ target_path.mkpath
+
+ expect {
+ shutup do
+ install_phase.call
+ end
+ }.to raise_error(Hbc::CaskError)
+
+ expect(source_path).to be_a_directory
+ expect(target_path).to be_a_directory
+ expect(File.identical?(source_path, target_path)).to be false
+ end
+end
diff --git a/Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb
new file mode 100644
index 000000000..7fa44dbce
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/artifact/two_apps_correct_spec.rb
@@ -0,0 +1,93 @@
+require "spec_helper"
+
+describe Hbc::Artifact::App do
+ describe "multiple apps" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-correct.rb") }
+
+ let(:install_phase) {
+ -> { Hbc::Artifact::App.new(cask).install_phase }
+ }
+
+ let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") }
+ let(:target_path_mini) { Hbc.appdir.join("Caffeine Mini.app") }
+
+ let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") }
+ let(:target_path_pro) { Hbc.appdir.join("Caffeine Pro.app") }
+
+ before(:each) do
+ InstallHelper.install_without_artifacts(cask)
+ end
+
+ it "installs both apps using the proper target directory" do
+ shutup do
+ install_phase.call
+ end
+
+ expect(target_path_mini).to be_a_directory
+ expect(source_path_mini).not_to exist
+
+ expect(target_path_pro).to be_a_directory
+ expect(source_path_pro).not_to exist
+ end
+
+ describe "when apps are in a subdirectory" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-subdir.rb") }
+
+ it "installs both apps using the proper target directory" do
+ shutup do
+ install_phase.call
+ end
+
+ expect(target_path_mini).to be_a_directory
+ expect(source_path_mini).not_to exist
+
+ expect(target_path_pro).to be_a_directory
+ expect(source_path_pro).not_to exist
+ end
+ end
+
+ it "only uses apps when they are specified" do
+ FileUtils.cp_r source_path_mini, source_path_mini.sub("Caffeine Mini.app", "Caffeine Deluxe.app")
+
+ shutup do
+ install_phase.call
+ end
+
+ expect(target_path_mini).to be_a_directory
+ expect(source_path_mini).not_to exist
+
+ expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist
+ expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
+ end
+
+ describe "avoids clobbering an existing app" do
+ it "when the first app of two already exists" do
+ target_path_mini.mkpath
+
+ expect {
+ expect(install_phase).to output(<<-EOS.undent).to_stdout
+ ==> Moving App 'Caffeine Pro.app' to '#{target_path_pro}'
+ EOS
+ }.to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path_mini}'.")
+
+ expect(source_path_mini).to be_a_directory
+ expect(target_path_mini).to be_a_directory
+ expect(File.identical?(source_path_mini, target_path_mini)).to be false
+ end
+
+ it "when the second app of two already exists" do
+ target_path_pro.mkpath
+
+ expect {
+ expect(install_phase).to output(<<-EOS.undent).to_stdout
+ ==> Moving App 'Caffeine Mini.app' to '#{target_path_mini}'
+ EOS
+ }.to raise_error(Hbc::CaskError, "It seems there is already an App at '#{target_path_pro}'.")
+
+ expect(source_path_pro).to be_a_directory
+ expect(target_path_pro).to be_a_directory
+ expect(File.identical?(source_path_pro, target_path_pro)).to be false
+ end
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb
new file mode 100644
index 000000000..0aa38d910
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/artifact/two_apps_incorrect_spec.rb
@@ -0,0 +1,11 @@
+require "spec_helper"
+
+describe Hbc::Artifact::App do
+ # FIXME: Doesn't actually raise because the `app` stanza is not evaluated on load.
+ # it "must raise" do
+ # lambda {
+ # Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-incorrect.rb")
+ # }.must_raise
+ # # TODO: later give the user a nice exception for this case and check for it here
+ # end
+end
diff --git a/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb
new file mode 100644
index 000000000..3150b50be
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb
@@ -0,0 +1,21 @@
+require "spec_helper"
+
+describe Hbc::Artifact::Zap do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") }
+
+ let(:zap_artifact) {
+ Hbc::Artifact::Zap.new(cask)
+ }
+
+ before do
+ shutup do
+ InstallHelper.install_without_artifacts(cask)
+ end
+ end
+
+ describe "#uninstall_phase" do
+ subject { zap_artifact }
+
+ it { is_expected.not_to respond_to(:uninstall_phase) }
+ end
+end
diff --git a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb
index b09d39833..008e2ad2a 100644
--- a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb
+++ b/Library/Homebrew/cask/spec/cask/artifact/uninstall_spec.rb
@@ -1,43 +1,27 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::Artifact::Uninstall do
- let(:cask) { Hbc.load("with-installable") }
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") }
let(:uninstall_artifact) {
Hbc::Artifact::Uninstall.new(cask, command: Hbc::FakeSystemCommand)
}
- before do
+ before(:each) do
shutup do
- TestHelper.install_without_artifacts(cask)
- end
- end
-
- describe "install_phase" do
- it "does nothing, because the install_phase method is a no-op" do
- shutup do
- uninstall_artifact.install_phase
- end
- end
- end
-
- describe "zap_phase" do
- it "does nothing, because the zap_phase method is a no-op" do
- shutup do
- uninstall_artifact.zap_phase
- end
+ InstallHelper.install_without_artifacts(cask)
end
end
describe "uninstall_phase" do
- subject do
+ subject {
shutup do
uninstall_artifact.uninstall_phase
end
- end
+ }
- describe "when using launchctl" do
- let(:cask) { Hbc.load("with-uninstall-launchctl") }
+ context "when using launchctl" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-launchctl.rb") }
let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] }
let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] }
let(:unknown_response) { "launchctl list returned unknown response\n" }
@@ -56,7 +40,7 @@ describe Hbc::Artifact::Uninstall do
EOS
}
- describe "when launchctl job is owned by user" do
+ context "when launchctl job is owned by user" do
it "can uninstall" do
Hbc::FakeSystemCommand.stubs_command(
launchctl_list_cmd,
@@ -74,7 +58,7 @@ describe Hbc::Artifact::Uninstall do
end
end
- describe "when launchctl job is owned by system" do
+ context "when launchctl job is owned by system" do
it "can uninstall" do
Hbc::FakeSystemCommand.stubs_command(
launchctl_list_cmd,
@@ -93,8 +77,8 @@ describe Hbc::Artifact::Uninstall do
end
end
- describe "when using pkgutil" do
- let(:cask) { Hbc.load("with-uninstall-pkgutil") }
+ context "when using pkgutil" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-pkgutil.rb") }
let(:main_pkg_id) { "my.fancy.package.main" }
let(:agent_pkg_id) { "my.fancy.package.agent" }
let(:main_files) {
@@ -179,8 +163,8 @@ describe Hbc::Artifact::Uninstall do
end
end
- describe "when using kext" do
- let(:cask) { Hbc.load("with-uninstall-kext") }
+ context "when using kext" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-kext.rb") }
let(:kext_id) { "my.fancy.package.kernelextension" }
it "can uninstall" do
@@ -204,8 +188,8 @@ describe Hbc::Artifact::Uninstall do
end
end
- describe "when using quit" do
- let(:cask) { Hbc.load("with-uninstall-quit") }
+ context "when using quit" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-quit.rb") }
let(:bundle_id) { "my.fancy.package.app" }
let(:quit_application_script) {
%Q(tell application id "#{bundle_id}" to quit)
@@ -224,8 +208,8 @@ describe Hbc::Artifact::Uninstall do
end
end
- describe "when using signal" do
- let(:cask) { Hbc.load("with-uninstall-signal") }
+ context "when using signal" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-signal.rb") }
let(:bundle_id) { "my.fancy.package.app" }
let(:signals) { %w[TERM KILL] }
let(:unix_pids) { [12_345, 67_890] }
@@ -236,15 +220,15 @@ describe Hbc::Artifact::Uninstall do
)
signals.each do |signal|
- Process.expects(:kill).with(signal, *unix_pids)
+ expect(Process).to receive(:kill).with(signal, *unix_pids)
end
subject
end
end
- describe "when using delete" do
- let(:cask) { Hbc.load("with-uninstall-delete") }
+ context "when using delete" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-delete.rb") }
it "can uninstall" do
Hbc::FakeSystemCommand.expects_command(
@@ -257,8 +241,8 @@ describe Hbc::Artifact::Uninstall do
end
end
- describe "when using trash" do
- let(:cask) { Hbc.load("with-uninstall-trash") }
+ context "when using trash" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-trash.rb") }
it "can uninstall" do
Hbc::FakeSystemCommand.expects_command(
@@ -271,8 +255,8 @@ describe Hbc::Artifact::Uninstall do
end
end
- describe "when using rmdir" do
- let(:cask) { Hbc.load("with-uninstall-rmdir") }
+ context "when using rmdir" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-rmdir.rb") }
let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") }
it "can uninstall" do
@@ -288,8 +272,8 @@ describe Hbc::Artifact::Uninstall do
end
end
- describe "when using script" do
- let(:cask) { Hbc.load("with-uninstall-script") }
+ context "when using script" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script.rb") }
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
it "can uninstall" do
@@ -303,8 +287,8 @@ describe Hbc::Artifact::Uninstall do
end
end
- describe "when using early_script" do
- let(:cask) { Hbc.load("with-uninstall-early-script") }
+ context "when using early_script" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-early-script.rb") }
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
it "can uninstall" do
@@ -318,8 +302,8 @@ describe Hbc::Artifact::Uninstall do
end
end
- describe "when using login_item" do
- let(:cask) { Hbc.load("with-uninstall-login-item") }
+ context "when using login_item" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-login-item.rb") }
it "can uninstall" do
Hbc::FakeSystemCommand.expects_command(
diff --git a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb
index b65b0bf5c..bd14cd6de 100644
--- a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb
+++ b/Library/Homebrew/cask/spec/cask/artifact/zap_spec.rb
@@ -1,44 +1,28 @@
-require "test_helper"
+require "spec_helper"
# TODO: test that zap removes an alternate version of the same Cask
describe Hbc::Artifact::Zap do
- let(:cask) { Hbc.load("with-installable") }
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") }
let(:zap_artifact) {
Hbc::Artifact::Zap.new(cask, command: Hbc::FakeSystemCommand)
}
- before do
+ before(:each) do
shutup do
- TestHelper.install_without_artifacts(cask)
+ InstallHelper.install_without_artifacts(cask)
end
end
- describe "install_phase" do
- it "does nothing, because the install_phase method is a no-op" do
- shutup do
- zap_artifact.install_phase
- end
- end
- end
-
- describe "uninstall_phase" do
- it "does nothing, because the uninstall_phase method is a no-op" do
- shutup do
- zap_artifact.uninstall_phase
- end
- end
- end
-
- describe "zap_phase" do
- subject do
+ describe "#zap_phase" do
+ subject {
shutup do
zap_artifact.zap_phase
end
- end
+ }
- describe "when using launchctl" do
- let(:cask) { Hbc.load("with-zap-launchctl") }
+ context "when using launchctl" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-launchctl.rb") }
let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] }
let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] }
let(:unknown_response) { "launchctl list returned unknown response\n" }
@@ -57,7 +41,7 @@ describe Hbc::Artifact::Zap do
EOS
}
- describe "when launchctl job is owned by user" do
+ context "when launchctl job is owned by user" do
it "can zap" do
Hbc::FakeSystemCommand.stubs_command(
launchctl_list_cmd,
@@ -94,8 +78,8 @@ describe Hbc::Artifact::Zap do
end
end
- describe "when using pkgutil" do
- let(:cask) { Hbc.load("with-zap-pkgutil") }
+ context "when using pkgutil" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-pkgutil.rb") }
let(:main_pkg_id) { "my.fancy.package.main" }
let(:agent_pkg_id) { "my.fancy.package.agent" }
let(:main_files) {
@@ -180,8 +164,8 @@ describe Hbc::Artifact::Zap do
end
end
- describe "when using kext" do
- let(:cask) { Hbc.load("with-zap-kext") }
+ context "when using kext" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-kext.rb") }
let(:kext_id) { "my.fancy.package.kernelextension" }
it "can zap" do
@@ -205,8 +189,8 @@ describe Hbc::Artifact::Zap do
end
end
- describe "when using quit" do
- let(:cask) { Hbc.load("with-zap-quit") }
+ context "when using quit" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-quit.rb") }
let(:bundle_id) { "my.fancy.package.app" }
let(:quit_application_script) {
%Q(tell application id "#{bundle_id}" to quit)
@@ -225,8 +209,8 @@ describe Hbc::Artifact::Zap do
end
end
- describe "when using signal" do
- let(:cask) { Hbc.load("with-zap-signal") }
+ context "when using signal" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-signal.rb") }
let(:bundle_id) { "my.fancy.package.app" }
let(:signals) { %w[TERM KILL] }
let(:unix_pids) { [12_345, 67_890] }
@@ -237,15 +221,15 @@ describe Hbc::Artifact::Zap do
)
signals.each do |signal|
- Process.expects(:kill).with(signal, *unix_pids)
+ expect(Process).to receive(:kill).with(signal, *unix_pids)
end
subject
end
end
- describe "when using delete" do
- let(:cask) { Hbc.load("with-zap-delete") }
+ context "when using delete" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-delete.rb") }
it "can zap" do
Hbc::FakeSystemCommand.expects_command(
@@ -258,8 +242,8 @@ describe Hbc::Artifact::Zap do
end
end
- describe "when using trash" do
- let(:cask) { Hbc.load("with-zap-trash") }
+ context "when using trash" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-trash.rb") }
it "can zap" do
Hbc::FakeSystemCommand.expects_command(
@@ -272,8 +256,8 @@ describe Hbc::Artifact::Zap do
end
end
- describe "when using rmdir" do
- let(:cask) { Hbc.load("with-zap-rmdir") }
+ context "when using rmdir" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-rmdir.rb") }
let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") }
it "can zap" do
@@ -289,8 +273,8 @@ describe Hbc::Artifact::Zap do
end
end
- describe "when using script" do
- let(:cask) { Hbc.load("with-zap-script") }
+ context "when using script" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-script.rb") }
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
it "can zap" do
@@ -304,8 +288,8 @@ describe Hbc::Artifact::Zap do
end
end
- describe "when using early_script" do
- let(:cask) { Hbc.load("with-zap-early-script") }
+ context "when using early_script" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-early-script.rb") }
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
it "can zap" do
@@ -319,8 +303,8 @@ describe Hbc::Artifact::Zap do
end
end
- describe "when using login_item" do
- let(:cask) { Hbc.load("with-zap-login-item") }
+ context "when using login_item" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-login-item.rb") }
it "can zap" do
Hbc::FakeSystemCommand.expects_command(
diff --git a/Library/Homebrew/cask/spec/cask/audit_spec.rb b/Library/Homebrew/cask/spec/cask/audit_spec.rb
index c12063a1d..9eb9f0136 100644
--- a/Library/Homebrew/cask/spec/cask/audit_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/audit_spec.rb
@@ -1,6 +1,5 @@
describe Hbc::Audit do
include AuditMatchers
- include Sha256Helper
let(:cask) { instance_double(Hbc::Cask) }
let(:download) { false }
@@ -162,7 +161,7 @@ describe Hbc::Audit do
before do
allow(audit).to receive(:check_appcast_http_code)
- allow(fake_system_command).to receive(:run).and_return(fake_curl_result)
+ allow(Hbc::SystemCommand).to receive(:run).and_return(fake_curl_result)
allow(fake_curl_result).to receive(:success?).and_return(success)
end
@@ -178,7 +177,7 @@ describe Hbc::Audit do
end
context "when appcast checkpoint is out of date" do
- let(:actual_checkpoint) { random_sha256 }
+ let(:actual_checkpoint) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" }
it { is_expected.to warn_with(mismatch_msg) }
it { should_not warn_with(curl_error_msg) }
end
diff --git a/Library/Homebrew/cask/spec/cask/cask_spec.rb b/Library/Homebrew/cask/spec/cask/cask_spec.rb
index d470c6ec3..32f3d8258 100644
--- a/Library/Homebrew/cask/spec/cask/cask_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/cask_spec.rb
@@ -20,4 +20,73 @@ describe Hbc::Cask do
end
end
end
+
+ describe "load" do
+ let(:hbc_relative_tap_path) { "../../Taps/caskroom/homebrew-cask" }
+
+ it "returns an instance of the Cask for the given token" do
+ c = Hbc.load("adium")
+ expect(c).to be_kind_of(Hbc::Cask)
+ expect(c.token).to eq("adium")
+ end
+
+ it "returns an instance of the Cask from a specific file location" do
+ location = File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb")
+ c = Hbc.load(location)
+ expect(c).to be_kind_of(Hbc::Cask)
+ expect(c.token).to eq("dia")
+ end
+
+ it "returns an instance of the Cask from a url" do
+ url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb")
+ c = shutup do
+ Hbc.load(url)
+ end
+ expect(c).to be_kind_of(Hbc::Cask)
+ expect(c.token).to eq("dia")
+ end
+
+ it "raises an error when failing to download a Cask from a url" do
+ expect {
+ url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb")
+ shutup do
+ Hbc.load(url)
+ end
+ }.to raise_error(Hbc::CaskUnavailableError)
+ end
+
+ it "returns an instance of the Cask from a relative file location" do
+ c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb")
+ expect(c).to be_kind_of(Hbc::Cask)
+ expect(c.token).to eq("bbedit")
+ end
+
+ it "uses exact match when loading by token" do
+ expect(Hbc.load("test-opera").token).to eq("test-opera")
+ expect(Hbc.load("test-opera-mail").token).to eq("test-opera-mail")
+ end
+
+ it "raises an error when attempting to load a Cask that doesn't exist" do
+ expect {
+ Hbc.load("notacask")
+ }.to raise_error(Hbc::CaskUnavailableError)
+ end
+ end
+
+ describe "all_tokens" do
+ it "returns a token for every Cask" do
+ all_cask_tokens = Hbc.all_tokens
+ expect(all_cask_tokens.count).to be > 20
+ all_cask_tokens.each { |token| expect(token).to be_kind_of(String) }
+ end
+ end
+
+ describe "metadata" do
+ it "proposes a versioned metadata directory name for each instance" do
+ cask_token = "adium"
+ c = Hbc.load(cask_token)
+ metadata_path = Hbc.caskroom.join(cask_token, ".metadata", c.version)
+ expect(c.metadata_versioned_container_path.to_s).to eq(metadata_path.to_s)
+ end
+ end
end
diff --git a/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb b/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb
new file mode 100644
index 000000000..b520a88df
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/cli/audit_spec.rb
@@ -0,0 +1,61 @@
+require "spec_helper"
+
+describe Hbc::CLI::Audit do
+ let(:auditor) { double }
+ let(:cask) { double }
+
+ describe "selection of Casks to audit" do
+ it "audits all Casks if no tokens are given" do
+ allow(Hbc).to receive(:all).and_return([cask, cask])
+
+ expect(auditor).to receive(:audit).twice
+
+ run_audit([], auditor)
+ end
+
+ it "audits specified Casks if tokens are given" do
+ cask_token = "nice-app"
+ expect(Hbc).to receive(:load).with(cask_token).and_return(cask)
+
+ expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false)
+
+ run_audit([cask_token], auditor)
+ end
+ end
+
+ describe "rules for downloading a Cask" do
+ it "does not download the Cask per default" do
+ allow(Hbc).to receive(:load).and_return(cask)
+ expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false)
+
+ run_audit(["casktoken"], auditor)
+ end
+
+ it "download a Cask if --download flag is set" do
+ allow(Hbc).to receive(:load).and_return(cask)
+ expect(auditor).to receive(:audit).with(cask, audit_download: true, check_token_conflicts: false)
+
+ run_audit(["casktoken", "--download"], auditor)
+ end
+ end
+
+ describe "rules for checking token conflicts" do
+ it "does not check for token conflicts per default" do
+ allow(Hbc).to receive(:load).and_return(cask)
+ expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: false)
+
+ run_audit(["casktoken"], auditor)
+ end
+
+ it "checks for token conflicts if --token-conflicts flag is set" do
+ allow(Hbc).to receive(:load).and_return(cask)
+ expect(auditor).to receive(:audit).with(cask, audit_download: false, check_token_conflicts: true)
+
+ run_audit(["casktoken", "--token-conflicts"], auditor)
+ end
+ end
+
+ def run_audit(args, auditor)
+ Hbc::CLI::Audit.new(args, auditor).run
+ end
+end
diff --git a/Library/Homebrew/cask/test/cask/cli/cat_test.rb b/Library/Homebrew/cask/spec/cask/cli/cat_spec.rb
index df49efda0..7517c1b5c 100644
--- a/Library/Homebrew/cask/test/cask/cli/cat_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/cat_spec.rb
@@ -1,10 +1,10 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::CLI::Cat do
describe "given a basic Cask" do
- before do
- @expected_output = <<-EOS.undent
- test_cask 'basic-cask' do
+ let(:expected_output) {
+ <<-EOS.undent
+ cask 'basic-cask' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
@@ -14,46 +14,46 @@ describe Hbc::CLI::Cat do
app 'TestCask.app'
end
EOS
- end
+ }
it "displays the Cask file content about the specified Cask" do
- lambda {
+ expect {
Hbc::CLI::Cat.run("basic-cask")
- }.must_output(@expected_output)
+ }.to output(expected_output).to_stdout
end
it "throws away additional Cask arguments and uses the first" do
- lambda {
+ expect {
Hbc::CLI::Cat.run("basic-cask", "local-caffeine")
- }.must_output(@expected_output)
+ }.to output(expected_output).to_stdout
end
it "throws away stray options" do
- lambda {
+ expect {
Hbc::CLI::Cat.run("--notavalidoption", "basic-cask")
- }.must_output(@expected_output)
+ }.to output(expected_output).to_stdout
end
end
it "raises an exception when the Cask does not exist" do
- lambda {
+ expect {
Hbc::CLI::Cat.run("notacask")
- }.must_raise Hbc::CaskUnavailableError
+ }.to raise_error(Hbc::CaskUnavailableError)
end
describe "when no Cask is specified" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Cat.run
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
describe "when no Cask is specified, but an invalid option" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Cat.run("--notavalidoption")
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
end
diff --git a/Library/Homebrew/cask/test/cask/cli/create_test.rb b/Library/Homebrew/cask/spec/cask/cli/create_spec.rb
index f09c91e8e..e3d484d87 100644
--- a/Library/Homebrew/cask/test/cask/cli/create_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/create_spec.rb
@@ -1,4 +1,4 @@
-require "test_helper"
+require "spec_helper"
# monkeypatch for testing
module Hbc
@@ -20,11 +20,11 @@ module Hbc
end
describe Hbc::CLI::Create do
- before do
+ before(:each) do
Hbc::CLI::Create.reset!
end
- after do
+ after(:each) do
%w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask|
path = Hbc.path(cask)
path.delete if path.exist?
@@ -33,7 +33,7 @@ describe Hbc::CLI::Create do
it "opens the editor for the specified Cask" do
Hbc::CLI::Create.run("new-cask")
- Hbc::CLI::Create.editor_commands.must_equal [
+ expect(Hbc::CLI::Create.editor_commands).to eq [
[Hbc.path("new-cask")],
]
end
@@ -41,7 +41,7 @@ describe Hbc::CLI::Create do
it "drops a template down for the specified Cask" do
Hbc::CLI::Create.run("new-cask")
template = File.read(Hbc.path("new-cask"))
- template.must_equal <<-EOS.undent
+ expect(template).to eq <<-EOS.undent
cask 'new-cask' do
version ''
sha256 ''
@@ -57,44 +57,44 @@ describe Hbc::CLI::Create do
it "throws away additional Cask arguments and uses the first" do
Hbc::CLI::Create.run("additional-cask", "another-cask")
- Hbc::CLI::Create.editor_commands.must_equal [
+ expect(Hbc::CLI::Create.editor_commands).to eq [
[Hbc.path("additional-cask")],
]
end
it "throws away stray options" do
Hbc::CLI::Create.run("--notavalidoption", "yet-another-cask")
- Hbc::CLI::Create.editor_commands.must_equal [
+ expect(Hbc::CLI::Create.editor_commands).to eq [
[Hbc.path("yet-another-cask")],
]
end
it "raises an exception when the Cask already exists" do
- lambda {
+ expect {
Hbc::CLI::Create.run("basic-cask")
- }.must_raise Hbc::CaskAlreadyCreatedError
+ }.to raise_error(Hbc::CaskAlreadyCreatedError)
end
it "allows creating Casks that are substrings of existing Casks" do
Hbc::CLI::Create.run("local-caff")
- Hbc::CLI::Create.editor_commands.must_equal [
+ expect(Hbc::CLI::Create.editor_commands).to eq [
[Hbc.path("local-caff")],
]
end
describe "when no Cask is specified" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Create.run
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
describe "when no Cask is specified, but an invalid option" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Create.run("--notavalidoption")
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
end
diff --git a/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb b/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb
index 38f8b50ac..ff1cf5706 100644
--- a/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb
@@ -4,7 +4,7 @@ describe Hbc::CLI::Doctor do
it "displays some nice info about the environment" do
expect {
Hbc::CLI::Doctor.run
- }.to output(/\A==> macOS Release:/).to_stdout
+ }.to output(/\A==> Homebrew-Cask Version/).to_stdout
end
it "raises an exception when arguments are given" do
diff --git a/Library/Homebrew/cask/test/cask/cli/edit_test.rb b/Library/Homebrew/cask/spec/cask/cli/edit_spec.rb
index 6eb2289c0..5ddf27a48 100644
--- a/Library/Homebrew/cask/test/cask/cli/edit_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/edit_spec.rb
@@ -1,4 +1,4 @@
-require "test_helper"
+require "spec_helper"
# monkeypatch for testing
module Hbc
@@ -20,43 +20,43 @@ module Hbc
end
describe Hbc::CLI::Edit do
- before do
+ before(:each) do
Hbc::CLI::Edit.reset!
end
it "opens the editor for the specified Cask" do
- Hbc::CLI::Edit.run("alfred")
- Hbc::CLI::Edit.editor_commands.must_equal [
- [Hbc.path("alfred")],
+ Hbc::CLI::Edit.run("local-caffeine")
+ expect(Hbc::CLI::Edit.editor_commands).to eq [
+ [Hbc.path("local-caffeine")],
]
end
it "throws away additional arguments and uses the first" do
- Hbc::CLI::Edit.run("adium", "alfred")
- Hbc::CLI::Edit.editor_commands.must_equal [
- [Hbc.path("adium")],
+ Hbc::CLI::Edit.run("local-caffeine", "local-transmission")
+ expect(Hbc::CLI::Edit.editor_commands).to eq [
+ [Hbc.path("local-caffeine")],
]
end
it "raises an exception when the Cask doesnt exist" do
- lambda {
+ expect {
Hbc::CLI::Edit.run("notacask")
- }.must_raise Hbc::CaskUnavailableError
+ }.to raise_error(Hbc::CaskUnavailableError)
end
describe "when no Cask is specified" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Edit.run
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
describe "when no Cask is specified, but an invalid option" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Edit.run("--notavalidoption")
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
end
diff --git a/Library/Homebrew/cask/test/cask/cli/fetch_test.rb b/Library/Homebrew/cask/spec/cask/cli/fetch_spec.rb
index 70c25646d..bb8133453 100644
--- a/Library/Homebrew/cask/test/cask/cli/fetch_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/fetch_spec.rb
@@ -1,20 +1,20 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::CLI::Fetch do
let(:local_transmission) {
- Hbc.load("local-transmission")
+ Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
}
let(:local_caffeine) {
- Hbc.load("local-caffeine")
+ Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
}
it "allows download the installer of a Cask" do
shutup do
Hbc::CLI::Fetch.run("local-transmission", "local-caffeine")
end
- Hbc::CurlDownloadStrategy.new(local_transmission).cached_location.must_be :exist?
- Hbc::CurlDownloadStrategy.new(local_caffeine).cached_location.must_be :exist?
+ expect(Hbc::CurlDownloadStrategy.new(local_transmission).cached_location).to exist
+ expect(Hbc::CurlDownloadStrategy.new(local_caffeine).cached_location).to exist
end
it "prevents double fetch (without nuking existing installation)" do
@@ -30,7 +30,7 @@ describe Hbc::CLI::Fetch do
end
new_ctime = File.stat(download_stategy.cached_location).ctime
- old_ctime.to_i.must_equal new_ctime.to_i
+ expect(old_ctime.to_i).to eq(new_ctime.to_i)
end
it "allows double fetch with --force" do
@@ -48,31 +48,30 @@ describe Hbc::CLI::Fetch do
download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission)
new_ctime = File.stat(download_stategy.cached_location).ctime
- # new_ctime.to_i.must_be :>, old_ctime.to_i
- new_ctime.to_i.must_be :>, old_ctime.to_i
+ expect(new_ctime.to_i).to be > old_ctime.to_i
end
it "properly handles Casks that are not present" do
- lambda {
+ expect {
shutup do
Hbc::CLI::Fetch.run("notacask")
end
- }.must_raise Hbc::CaskUnavailableError
+ }.to raise_error(Hbc::CaskUnavailableError)
end
describe "when no Cask is specified" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Fetch.run
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
describe "when no Cask is specified, but an invalid option" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Fetch.run("--notavalidoption")
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
end
diff --git a/Library/Homebrew/cask/test/cask/cli/home_test.rb b/Library/Homebrew/cask/spec/cask/cli/home_spec.rb
index 67bcb024a..a2b49b433 100644
--- a/Library/Homebrew/cask/test/cask/cli/home_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/home_spec.rb
@@ -1,4 +1,4 @@
-require "test_helper"
+require "spec_helper"
# monkeypatch for testing
module Hbc
@@ -25,23 +25,23 @@ describe Hbc::CLI::Home do
end
it "opens the homepage for the specified Cask" do
- Hbc::CLI::Home.run("alfred")
- Hbc::CLI::Home.system_commands.must_equal [
- ["/usr/bin/open", "--", "https://www.alfredapp.com/"],
+ Hbc::CLI::Home.run("local-caffeine")
+ expect(Hbc::CLI::Home.system_commands).to eq [
+ ["/usr/bin/open", "--", "http://example.com/local-caffeine"],
]
end
it "works for multiple Casks" do
- Hbc::CLI::Home.run("alfred", "adium")
- Hbc::CLI::Home.system_commands.must_equal [
- ["/usr/bin/open", "--", "https://www.alfredapp.com/"],
- ["/usr/bin/open", "--", "https://www.adium.im/"],
+ Hbc::CLI::Home.run("local-caffeine", "local-transmission")
+ expect(Hbc::CLI::Home.system_commands).to eq [
+ ["/usr/bin/open", "--", "http://example.com/local-caffeine"],
+ ["/usr/bin/open", "--", "http://example.com/local-transmission"],
]
end
it "opens the project page when no Cask is specified" do
Hbc::CLI::Home.run
- Hbc::CLI::Home.system_commands.must_equal [
+ expect(Hbc::CLI::Home.system_commands).to eq [
["/usr/bin/open", "--", "http://caskroom.io/"],
]
end
diff --git a/Library/Homebrew/cask/test/cask/cli/info_test.rb b/Library/Homebrew/cask/spec/cask/cli/info_spec.rb
index 767a594e8..6977f81c3 100644
--- a/Library/Homebrew/cask/test/cask/cli/info_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/info_spec.rb
@@ -1,14 +1,14 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::CLI::Info do
it "displays some nice info about the specified Cask" do
- lambda {
+ expect {
Hbc::CLI::Info.run("local-caffeine")
- }.must_output <<-EOS.undent
+ }.to output(<<-EOS.undent).to_stdout
local-caffeine: 1.2.3
http://example.com/local-caffeine
Not installed
- From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-caffeine.rb
+ From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb
==> Name
None
==> Artifacts
@@ -17,12 +17,12 @@ describe Hbc::CLI::Info do
end
describe "given multiple Casks" do
- before do
- @expected_output = <<-EOS.undent
+ let(:expected_output) {
+ <<-EOS.undent
local-caffeine: 1.2.3
http://example.com/local-caffeine
Not installed
- From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-caffeine.rb
+ From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-caffeine.rb
==> Name
None
==> Artifacts
@@ -30,35 +30,35 @@ describe Hbc::CLI::Info do
local-transmission: 2.61
http://example.com/local-transmission
Not installed
- From: https://github.com/caskroom/homebrew-test/blob/master/Casks/local-transmission.rb
+ From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/local-transmission.rb
==> Name
None
==> Artifacts
Transmission.app (app)
EOS
- end
+ }
it "displays the info" do
- lambda {
+ expect {
Hbc::CLI::Info.run("local-caffeine", "local-transmission")
- }.must_output(@expected_output)
+ }.to output(expected_output).to_stdout
end
it "throws away stray options" do
- lambda {
+ expect {
Hbc::CLI::Info.run("--notavalidoption", "local-caffeine", "local-transmission")
- }.must_output(@expected_output)
+ }.to output(expected_output).to_stdout
end
end
it "should print caveats if the Cask provided one" do
- lambda {
+ expect {
Hbc::CLI::Info.run("with-caveats")
- }.must_output <<-EOS.undent
+ }.to output(<<-EOS.undent).to_stdout
with-caveats: 1.2.3
http://example.com/local-caffeine
Not installed
- From: https://github.com/caskroom/homebrew-test/blob/master/Casks/with-caveats.rb
+ From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-caveats.rb
==> Name
None
==> Artifacts
@@ -78,13 +78,13 @@ describe Hbc::CLI::Info do
end
it 'should not print "Caveats" section divider if the caveats block has no output' do
- lambda {
+ expect {
Hbc::CLI::Info.run("with-conditional-caveats")
- }.must_output <<-EOS.undent
+ }.to output(<<-EOS.undent).to_stdout
with-conditional-caveats: 1.2.3
http://example.com/local-caffeine
Not installed
- From: https://github.com/caskroom/homebrew-test/blob/master/Casks/with-conditional-caveats.rb
+ From: https://github.com/caskroom/homebrew-spec/blob/master/Casks/with-conditional-caveats.rb
==> Name
None
==> Artifacts
@@ -94,17 +94,17 @@ describe Hbc::CLI::Info do
describe "when no Cask is specified" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Info.run
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
describe "when no Cask is specified, but an invalid option" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Info.run("--notavalidoption")
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
end
diff --git a/Library/Homebrew/cask/test/cask/cli/install_test.rb b/Library/Homebrew/cask/spec/cask/cli/install_spec.rb
index eef3f2e5b..07aa78aa3 100644
--- a/Library/Homebrew/cask/test/cask/cli/install_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/install_spec.rb
@@ -1,4 +1,4 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::CLI::Install do
it "allows staging and activation of multiple Casks at once" do
@@ -6,10 +6,10 @@ describe Hbc::CLI::Install do
Hbc::CLI::Install.run("local-transmission", "local-caffeine")
end
- Hbc.load("local-transmission").must_be :installed?
- Hbc.appdir.join("Transmission.app").must_be :directory?
- Hbc.load("local-caffeine").must_be :installed?
- Hbc.appdir.join("Caffeine.app").must_be :directory?
+ expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed
+ expect(Hbc.appdir.join("Transmission.app")).to be_a_directory
+ expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")).to be_installed
+ expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory
end
it "skips double install (without nuking existing installation)" do
@@ -19,7 +19,7 @@ describe Hbc::CLI::Install do
shutup do
Hbc::CLI::Install.run("local-transmission")
end
- Hbc.load("local-transmission").must_be :installed?
+ expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed
end
it "prints a warning message on double install" do
@@ -27,9 +27,9 @@ describe Hbc::CLI::Install do
Hbc::CLI::Install.run("local-transmission")
end
- lambda {
+ expect {
Hbc::CLI::Install.run("local-transmission", "")
- }.must_output nil, /Warning: A Cask for local-transmission is already installed./
+ }.to output(/Warning: A Cask for local-transmission is already installed./).to_stderr
end
it "allows double install with --force" do
@@ -37,54 +37,56 @@ describe Hbc::CLI::Install do
Hbc::CLI::Install.run("local-transmission")
end
- lambda {
- Hbc::CLI::Install.run("local-transmission", "--force")
- }.must_output(/local-transmission was successfully installed!/)
+ expect {
+ expect {
+ Hbc::CLI::Install.run("local-transmission", "--force")
+ }.to output(/It seems there is already an App at.*overwriting\./).to_stderr
+ }.to output(/local-transmission was successfully installed!/).to_stdout
end
it "skips dependencies with --skip-cask-deps" do
shutup do
Hbc::CLI::Install.run("with-depends-on-cask-multiple", "--skip-cask-deps")
end
- Hbc.load("with-depends-on-cask-multiple").must_be :installed?
- Hbc.load("local-caffeine").wont_be :installed?
- Hbc.load("local-transmission").wont_be :installed?
+ expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb")).to be_installed
+ expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")).not_to be_installed
+ expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed
end
it "properly handles Casks that are not present" do
- lambda {
+ expect {
shutup do
Hbc::CLI::Install.run("notacask")
end
- }.must_raise Hbc::CaskError
+ }.to raise_error(Hbc::CaskError)
end
it "returns a suggestion for a misspelled Cask" do
- lambda {
+ expect {
begin
Hbc::CLI::Install.run("googlechrome")
rescue Hbc::CaskError
nil
end
- }.must_output(nil, /No available Cask for googlechrome\. Did you mean:\ngoogle-chrome/)
+ }.to output(/No available Cask for googlechrome\. Did you mean:\ngoogle-chrome/).to_stderr
end
it "returns multiple suggestions for a Cask fragment" do
- lambda {
+ expect {
begin
Hbc::CLI::Install.run("google")
rescue Hbc::CaskError
nil
end
- }.must_output(nil, /No available Cask for google\. Did you mean one of:\ngoogle/)
+ }.to output(/No available Cask for google\. Did you mean one of:\ngoogle/).to_stderr
end
describe "when no Cask is specified" do
with_options = lambda do |options|
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Install.run(*options)
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
diff --git a/Library/Homebrew/cask/test/cask/cli/list_test.rb b/Library/Homebrew/cask/spec/cask/cli/list_spec.rb
index 4220ea510..49c06c521 100644
--- a/Library/Homebrew/cask/test/cask/cli/list_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/list_spec.rb
@@ -1,16 +1,16 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::CLI::List do
it "lists the installed Casks in a pretty fashion" do
casks = %w[local-caffeine local-transmission].map { |c| Hbc.load(c) }
casks.each do |c|
- TestHelper.install_with_caskfile(c)
+ InstallHelper.install_with_caskfile(c)
end
- lambda {
+ expect {
Hbc::CLI::List.run
- }.must_output <<-EOS.undent
+ }.to output(<<-EOS.undent).to_stdout
local-caffeine
local-transmission
EOS
@@ -18,7 +18,7 @@ describe Hbc::CLI::List do
describe "lists versions" do
let(:casks) { ["local-caffeine", "local-transmission"] }
- let(:output) {
+ let(:expected_output) {
<<-EOS.undent
local-caffeine 1.2.3
local-transmission 2.61
@@ -26,19 +26,19 @@ describe Hbc::CLI::List do
}
before(:each) do
- casks.map(&Hbc.method(:load)).each(&TestHelper.method(:install_with_caskfile))
+ casks.map(&Hbc.method(:load)).each(&InstallHelper.method(:install_with_caskfile))
end
it "of all installed Casks" do
- lambda {
+ expect {
Hbc::CLI::List.run("--versions")
- }.must_output(output)
+ }.to output(expected_output).to_stdout
end
it "of given Casks" do
- lambda {
+ expect {
Hbc::CLI::List.run("--versions", "local-caffeine", "local-transmission")
- }.must_output(output)
+ }.to output(expected_output).to_stdout
end
end
@@ -50,34 +50,30 @@ describe Hbc::CLI::List do
staged_path.mkpath
end
- after do
- caskroom_path.rmtree
- end
-
it "lists installed Casks without backing ruby files (due to renames or otherwise)" do
- lambda {
+ expect {
Hbc::CLI::List.run
- }.must_output <<-EOS.undent
+ }.to output(<<-EOS.undent).to_stdout
ive-been-renamed (!)
EOS
end
end
describe "given a set of installed Casks" do
- let(:caffeine) { Hbc.load("local-caffeine") }
- let(:transmission) { Hbc.load("local-transmission") }
+ let(:caffeine) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") }
+ let(:transmission) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") }
let(:casks) { [caffeine, transmission] }
it "lists the installed files for those Casks" do
- casks.each(&TestHelper.method(:install_without_artifacts_with_caskfile))
+ casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile))
shutup do
Hbc::Artifact::App.new(transmission).install_phase
end
- lambda {
+ expect {
Hbc::CLI::List.run("local-transmission", "local-caffeine")
- }.must_output <<-EOS.undent
+ }.to output(<<-EOS.undent).to_stdout
==> Apps
#{Hbc.appdir.join("Transmission.app")} (#{Hbc.appdir.join("Transmission.app").abv})
==> Apps
diff --git a/Library/Homebrew/cask/test/cask/cli/options_test.rb b/Library/Homebrew/cask/spec/cask/cli/options_spec.rb
index d49e7827b..a4381213a 100644
--- a/Library/Homebrew/cask/test/cask/cli/options_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/options_spec.rb
@@ -1,10 +1,10 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::CLI do
it "supports setting the appdir" do
Hbc::CLI.process_options %w[help --appdir=/some/path/foo]
- Hbc.appdir.must_equal Pathname("/some/path/foo")
+ expect(Hbc.appdir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the appdir from ENV" do
@@ -12,13 +12,13 @@ describe Hbc::CLI do
Hbc::CLI.process_options %w[help]
- Hbc.appdir.must_equal Pathname("/some/path/bar")
+ expect(Hbc.appdir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the prefpanedir" do
Hbc::CLI.process_options %w[help --prefpanedir=/some/path/foo]
- Hbc.prefpanedir.must_equal Pathname("/some/path/foo")
+ expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the prefpanedir from ENV" do
@@ -26,13 +26,13 @@ describe Hbc::CLI do
Hbc::CLI.process_options %w[help]
- Hbc.prefpanedir.must_equal Pathname("/some/path/bar")
+ expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the qlplugindir" do
Hbc::CLI.process_options %w[help --qlplugindir=/some/path/foo]
- Hbc.qlplugindir.must_equal Pathname("/some/path/foo")
+ expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the qlplugindir from ENV" do
@@ -40,13 +40,13 @@ describe Hbc::CLI do
Hbc::CLI.process_options %w[help]
- Hbc.qlplugindir.must_equal Pathname("/some/path/bar")
+ expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the colorpickerdir" do
Hbc::CLI.process_options %w[help --colorpickerdir=/some/path/foo]
- Hbc.colorpickerdir.must_equal Pathname("/some/path/foo")
+ expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the colorpickerdir from ENV" do
@@ -54,13 +54,13 @@ describe Hbc::CLI do
Hbc::CLI.process_options %w[help]
- Hbc.colorpickerdir.must_equal Pathname("/some/path/bar")
+ expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the dictionarydir" do
Hbc::CLI.process_options %w[help --dictionarydir=/some/path/foo]
- Hbc.dictionarydir.must_equal Pathname("/some/path/foo")
+ expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the dictionarydir from ENV" do
@@ -68,13 +68,13 @@ describe Hbc::CLI do
Hbc::CLI.process_options %w[help]
- Hbc.dictionarydir.must_equal Pathname("/some/path/bar")
+ expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the fontdir" do
Hbc::CLI.process_options %w[help --fontdir=/some/path/foo]
- Hbc.fontdir.must_equal Pathname("/some/path/foo")
+ expect(Hbc.fontdir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the fontdir from ENV" do
@@ -82,13 +82,13 @@ describe Hbc::CLI do
Hbc::CLI.process_options %w[help]
- Hbc.fontdir.must_equal Pathname("/some/path/bar")
+ expect(Hbc.fontdir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the servicedir" do
Hbc::CLI.process_options %w[help --servicedir=/some/path/foo]
- Hbc.servicedir.must_equal Pathname("/some/path/foo")
+ expect(Hbc.servicedir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the servicedir from ENV" do
@@ -96,36 +96,36 @@ describe Hbc::CLI do
Hbc::CLI.process_options %w[help]
- Hbc.servicedir.must_equal Pathname("/some/path/bar")
+ expect(Hbc.servicedir).to eq(Pathname.new("/some/path/bar"))
end
it "allows additional options to be passed through" do
rest = Hbc::CLI.process_options %w[edit foo --create --appdir=/some/path/qux]
- Hbc.appdir.must_equal Pathname("/some/path/qux")
- rest.must_equal %w[edit foo --create]
+ expect(Hbc.appdir).to eq(Pathname.new("/some/path/qux"))
+ expect(rest).to eq(%w[edit foo --create])
end
describe "when a mandatory argument is missing" do
it "shows a user-friendly error message" do
- lambda {
+ expect {
Hbc::CLI.process_options %w[install -f]
- }.must_raise Hbc::CaskError
+ }.to raise_error(Hbc::CaskError)
end
end
describe "given an ambiguous option" do
it "shows a user-friendly error message" do
- lambda {
+ expect {
Hbc::CLI.process_options %w[edit -c]
- }.must_raise Hbc::CaskError
+ }.to raise_error(Hbc::CaskError)
end
end
describe "--debug" do
it "sets the Cask debug method to true" do
Hbc::CLI.process_options %w[help --debug]
- Hbc.debug.must_equal true
+ expect(Hbc.debug).to be true
Hbc.debug = false
end
end
@@ -133,12 +133,8 @@ describe Hbc::CLI do
describe "--help" do
it "sets the Cask help method to true" do
Hbc::CLI.process_options %w[foo --help]
- Hbc.help.must_equal true
+ expect(Hbc.help).to be true
Hbc.help = false
end
end
-
- after do
- ENV["HOMEBREW_CASK_OPTS"] = nil
- end
end
diff --git a/Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb b/Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb
new file mode 100644
index 000000000..df83c53e2
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/cli/reinstall_spec.rb
@@ -0,0 +1,24 @@
+require "spec_helper"
+
+describe Hbc::CLI::Reinstall do
+ it "allows reinstalling a Cask" do
+ shutup do
+ Hbc::CLI::Install.run("local-transmission")
+ end
+ expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed
+
+ shutup do
+ Hbc::CLI::Reinstall.run("local-transmission")
+ end
+ expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed
+ end
+
+ it "allows reinstalling a non installed Cask" do
+ expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed
+
+ shutup do
+ Hbc::CLI::Reinstall.run("local-transmission")
+ end
+ expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed
+ end
+end
diff --git a/Library/Homebrew/cask/spec/cask/cli/search_spec.rb b/Library/Homebrew/cask/spec/cask/cli/search_spec.rb
new file mode 100644
index 000000000..fe669dd3e
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/cli/search_spec.rb
@@ -0,0 +1,61 @@
+require "spec_helper"
+
+describe Hbc::CLI::Search do
+ it "lists the available Casks that match the search term" do
+ expect {
+ Hbc::CLI::Search.run("photoshop")
+ }.to output(<<-EOS.undent).to_stdout
+ ==> Partial matches
+ adobe-photoshop-cc
+ adobe-photoshop-lightroom
+ EOS
+ end
+
+ it "shows that there are no Casks matching a search term that did not result in anything" do
+ expect {
+ Hbc::CLI::Search.run("foo-bar-baz")
+ }.to output("No Cask found for \"foo-bar-baz\".\n").to_stdout
+ end
+
+ it "lists all available Casks with no search term" do
+ expect {
+ Hbc::CLI::Search.run
+ }.to output(/google-chrome/).to_stdout
+ end
+
+ it "ignores hyphens in search terms" do
+ expect {
+ Hbc::CLI::Search.run("goo-gle-chrome")
+ }.to output(/google-chrome/).to_stdout
+ end
+
+ it "ignores hyphens in Cask tokens" do
+ expect {
+ Hbc::CLI::Search.run("googlechrome")
+ }.to output(/google-chrome/).to_stdout
+ end
+
+ it "accepts multiple arguments" do
+ expect {
+ Hbc::CLI::Search.run("google chrome")
+ }.to output(/google-chrome/).to_stdout
+ end
+
+ it "accepts a regexp argument" do
+ expect {
+ Hbc::CLI::Search.run("/^google-c[a-z]rome$/")
+ }.to output("==> Regexp matches\ngoogle-chrome\n").to_stdout
+ end
+
+ it "Returns both exact and partial matches" do
+ expect {
+ Hbc::CLI::Search.run("mnemosyne")
+ }.to output(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/).to_stdout
+ end
+
+ it "does not search the Tap name" do
+ expect {
+ Hbc::CLI::Search.run("caskroom")
+ }.to output(/^No Cask found for "caskroom"\.\n/).to_stdout
+ end
+end
diff --git a/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb
index 0368ad87c..be0aa31b6 100644
--- a/Library/Homebrew/cask/test/cask/cli/uninstall_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/uninstall_spec.rb
@@ -1,44 +1,44 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::CLI::Uninstall do
it "shows an error when a bad Cask is provided" do
- lambda {
+ expect {
Hbc::CLI::Uninstall.run("notacask")
- }.must_raise Hbc::CaskUnavailableError
+ }.to raise_error(Hbc::CaskUnavailableError)
end
it "shows an error when a Cask is provided that's not installed" do
- lambda {
+ expect {
Hbc::CLI::Uninstall.run("anvil")
- }.must_raise Hbc::CaskNotInstalledError
+ }.to raise_error(Hbc::CaskNotInstalledError)
end
it "tries anyway on a non-present Cask when --force is given" do
- lambda do
+ expect {
Hbc::CLI::Uninstall.run("anvil", "--force")
- end # wont_raise
+ }.not_to raise_error
end
it "can uninstall and unlink multiple Casks at once" do
- caffeine = Hbc.load("local-caffeine")
- transmission = Hbc.load("local-transmission")
+ caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
+ transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
shutup do
Hbc::Installer.new(caffeine).install
Hbc::Installer.new(transmission).install
end
- caffeine.must_be :installed?
- transmission.must_be :installed?
+ expect(caffeine).to be_installed
+ expect(transmission).to be_installed
shutup do
Hbc::CLI::Uninstall.run("local-caffeine", "local-transmission")
end
- caffeine.wont_be :installed?
- Hbc.appdir.join("Transmission.app").wont_be :exist?
- transmission.wont_be :installed?
- Hbc.appdir.join("Caffeine.app").wont_be :exist?
+ expect(caffeine).not_to be_installed
+ expect(Hbc.appdir.join("Transmission.app")).not_to exist
+ expect(transmission).not_to be_installed
+ expect(Hbc.appdir.join("Caffeine.app")).not_to exist
end
describe "when multiple versions of a cask are installed" do
@@ -67,34 +67,29 @@ describe Hbc::CLI::Uninstall do
end
end
- after(:each) do
- caskroom_path.rmtree if caskroom_path.exist?
- end
-
it "uninstalls one version at a time" do
shutup do
Hbc::CLI::Uninstall.run("versioned-cask")
end
- caskroom_path.join(first_installed_version).must_be :exist?
- caskroom_path.join(last_installed_version).wont_be :exist?
- caskroom_path.must_be :exist?
+ expect(caskroom_path.join(first_installed_version)).to exist
+ expect(caskroom_path.join(last_installed_version)).not_to exist
+ expect(caskroom_path).to exist
shutup do
Hbc::CLI::Uninstall.run("versioned-cask")
end
- caskroom_path.join(first_installed_version).wont_be :exist?
- caskroom_path.wont_be :exist?
+ expect(caskroom_path.join(first_installed_version)).not_to exist
+ expect(caskroom_path).not_to exist
end
it "displays a message when versions remain installed" do
- out, err = capture_io do
- Hbc::CLI::Uninstall.run("versioned-cask")
- end
-
- out.must_match(/#{token} #{first_installed_version} is still installed./)
- err.must_be :empty?
+ expect {
+ expect {
+ Hbc::CLI::Uninstall.run("versioned-cask")
+ }.not_to output.to_stderr
+ }.to output(/#{token} #{first_installed_version} is still installed./).to_stdout
end
end
@@ -121,34 +116,29 @@ describe Hbc::CLI::Uninstall do
EOS
end
- after do
- app.rmtree if app.exist?
- caskroom_path.rmtree if caskroom_path.exist?
- end
-
it "can still uninstall those Casks" do
shutup do
Hbc::CLI::Uninstall.run("ive-been-renamed")
end
- app.wont_be :exist?
- caskroom_path.wont_be :exist?
+ expect(app).not_to exist
+ expect(caskroom_path).not_to exist
end
end
describe "when no Cask is specified" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Uninstall.run
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
describe "when no Cask is specified, but an invalid option" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Uninstall.run("--notavalidoption")
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
end
diff --git a/Library/Homebrew/cask/spec/cask/cli/version_spec.rb b/Library/Homebrew/cask/spec/cask/cli/version_spec.rb
new file mode 100644
index 000000000..e6fcf4850
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/cli/version_spec.rb
@@ -0,0 +1,11 @@
+require "spec_helper"
+
+describe "brew cask --version" do
+ it "respects the --version argument" do
+ expect {
+ expect {
+ Hbc::CLI::NullCommand.new("--version").run
+ }.not_to output.to_stderr
+ }.to output(Hbc.full_version).to_stdout
+ end
+end
diff --git a/Library/Homebrew/cask/test/cask/cli/zap_test.rb b/Library/Homebrew/cask/spec/cask/cli/zap_spec.rb
index a9e862b11..d26114567 100644
--- a/Library/Homebrew/cask/test/cask/cli/zap_test.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/zap_spec.rb
@@ -1,33 +1,33 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::CLI::Zap do
it "shows an error when a bad Cask is provided" do
- lambda {
+ expect {
Hbc::CLI::Zap.run("notacask")
- }.must_raise Hbc::CaskUnavailableError
+ }.to raise_error(Hbc::CaskUnavailableError)
end
it "can zap and unlink multiple Casks at once" do
- caffeine = Hbc.load("local-caffeine")
- transmission = Hbc.load("local-transmission")
+ caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
+ transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
shutup do
Hbc::Installer.new(caffeine).install
Hbc::Installer.new(transmission).install
end
- caffeine.must_be :installed?
- transmission.must_be :installed?
+ expect(caffeine).to be_installed
+ expect(transmission).to be_installed
shutup do
Hbc::CLI::Zap.run("--notavalidoption",
"local-caffeine", "local-transmission")
end
- caffeine.wont_be :installed?
- Hbc.appdir.join("Transmission.app").wont_be :symlink?
- transmission.wont_be :installed?
- Hbc.appdir.join("Caffeine.app").wont_be :symlink?
+ expect(caffeine).not_to be_installed
+ expect(Hbc.appdir.join("Caffeine.app")).not_to be_a_symlink
+ expect(transmission).not_to be_installed
+ expect(Hbc.appdir.join("Transmission.app")).not_to be_a_symlink
end
# TODO: Explicit test that both zap and uninstall directives get dispatched.
@@ -59,17 +59,17 @@ describe Hbc::CLI::Zap do
describe "when no Cask is specified" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Zap.run
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
describe "when no Cask is specified, but an invalid option" do
it "raises an exception" do
- lambda {
+ expect {
Hbc::CLI::Zap.run("--notavalidoption")
- }.must_raise Hbc::CaskUnspecifiedError
+ }.to raise_error(Hbc::CaskUnspecifiedError)
end
end
end
diff --git a/Library/Homebrew/cask/spec/cask/cli_spec.rb b/Library/Homebrew/cask/spec/cask/cli_spec.rb
index 9964275f1..6b2313a41 100644
--- a/Library/Homebrew/cask/spec/cask/cli_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/cli_spec.rb
@@ -39,17 +39,17 @@ describe Hbc::CLI do
end
it "respects the env variable when choosing what appdir to create" do
- with_environment "HOMEBREW_CASK_OPTS" => "--appdir=/custom/appdir" do
- expect(Hbc).to receive(:appdir=).with(Pathname("/custom/appdir"))
- described_class.process("noop")
- end
+ allow(ENV).to receive(:[])
+ allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--appdir=/custom/appdir")
+ expect(Hbc).to receive(:appdir=).with(Pathname.new("/custom/appdir"))
+ described_class.process("noop")
end
it "respects the env variable when choosing a non-default Caskroom location" do
- with_environment "HOMEBREW_CASK_OPTS" => "--caskroom=/custom/caskdir" do
- expect(Hbc).to receive(:caskroom=).with(Pathname("/custom/caskdir"))
- described_class.process("noop")
- end
+ allow(ENV).to receive(:[])
+ allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--caskroom=/custom/caskdir")
+ expect(Hbc).to receive(:caskroom=).with(Pathname.new("/custom/caskdir"))
+ described_class.process("noop")
end
it "exits with a status of 1 when something goes wrong" do
diff --git a/Library/Homebrew/cask/test/cask/container/dmg_test.rb b/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb
index 2c33b88b6..af42d89b1 100644
--- a/Library/Homebrew/cask/test/cask/container/dmg_test.rb
+++ b/Library/Homebrew/cask/spec/cask/container/dmg_spec.rb
@@ -1,9 +1,9 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::Container::Dmg do
- describe "mount!" do
+ describe "#mount!" do
it "does not store nil mounts for dmgs with extra data" do
- transmission = Hbc.load("local-transmission")
+ transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
dmg = Hbc::Container::Dmg.new(
transmission,
@@ -13,7 +13,7 @@ describe Hbc::Container::Dmg do
begin
dmg.mount!
- dmg.mounts.wont_include nil
+ expect(dmg.mounts).not_to include nil
ensure
dmg.eject!
end
diff --git a/Library/Homebrew/cask/test/cask/container/naked_test.rb b/Library/Homebrew/cask/spec/cask/container/naked_spec.rb
index d40c16de5..ee4102eca 100644
--- a/Library/Homebrew/cask/test/cask/container/naked_test.rb
+++ b/Library/Homebrew/cask/spec/cask/container/naked_spec.rb
@@ -1,4 +1,4 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::Container::Naked do
it "saves files with spaces in them from uris with encoded spaces" do
@@ -13,8 +13,13 @@ describe Hbc::Container::Naked do
Hbc::FakeSystemCommand.stubs_command(expected_command)
container = Hbc::Container::Naked.new(cask, path, Hbc::FakeSystemCommand)
- container.extract
- Hbc::FakeSystemCommand.system_calls[expected_command].must_equal 1
+ expect {
+ shutup do
+ container.extract
+ end
+ }.not_to raise_error
+
+ expect(Hbc::FakeSystemCommand.system_calls[expected_command]).to eq(1)
end
end
diff --git a/Library/Homebrew/cask/spec/cask/depends_on_spec.rb b/Library/Homebrew/cask/spec/cask/depends_on_spec.rb
new file mode 100644
index 000000000..078a2bce7
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/depends_on_spec.rb
@@ -0,0 +1,92 @@
+require "spec_helper"
+
+# TODO: this test should be named after the corresponding class, once
+# that class is abstracted from installer.rb
+describe "Satisfy Dependencies and Requirements" do
+ subject {
+ lambda do
+ shutup do
+ Hbc::Installer.new(cask).install
+ end
+ end
+ }
+
+ describe "depends_on cask" do
+ context "when depends_on cask is cyclic" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-cyclic.rb") }
+ it { is_expected.to raise_error(Hbc::CaskCyclicCaskDependencyError) }
+ end
+
+ context do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask.rb") }
+ let(:dependency) { Hbc.load(cask.depends_on.cask.first) }
+
+ it "installs the dependency of a Cask and the Cask itself" do
+ expect(subject).not_to raise_error
+ expect(cask).to be_installed
+ expect(dependency).to be_installed
+ end
+ end
+ end
+
+ describe "depends_on macos" do
+ context "given an array" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-array.rb") }
+ it { is_expected.not_to raise_error }
+ end
+
+ context "given a comparisson" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-comparison.rb") }
+ it { is_expected.not_to raise_error }
+ end
+
+ context "given a string" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-string.rb") }
+ it { is_expected.not_to raise_error }
+ end
+
+ context "given a symbol" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-symbol.rb") }
+ it { is_expected.not_to raise_error }
+ end
+
+ context "when not satisfied" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-failure.rb") }
+ it { is_expected.to raise_error(Hbc::CaskError) }
+ end
+ end
+
+ describe "depends_on arch" do
+ context "when satisfied" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-arch.rb") }
+ it { is_expected.not_to raise_error }
+ end
+ end
+
+ describe "depends_on x11" do
+ before(:each) do
+ allow(MacOS::X11).to receive(:installed?).and_return(x11_installed)
+ end
+
+ context "when satisfied" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") }
+ let(:x11_installed) { true }
+
+ it { is_expected.not_to raise_error }
+ end
+
+ context "when not satisfied" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") }
+ let(:x11_installed) { false }
+
+ it { is_expected.to raise_error(Hbc::CaskX11DependencyError) }
+ end
+
+ context "when depends_on x11: false" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11-false.rb") }
+ let(:x11_installed) { false }
+
+ it { is_expected.not_to raise_error }
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb b/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb
index d0c7eef34..777491d66 100644
--- a/Library/Homebrew/cask/test/cask/dsl/caveats_test.rb
+++ b/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::DSL::Caveats do
- let(:cask) { Hbc.load("basic-cask") }
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:dsl) { Hbc::DSL::Caveats.new(cask) }
it_behaves_like Hbc::DSL::Base
diff --git a/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb b/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb
index c5e80b6d0..116a7c8a8 100644
--- a/Library/Homebrew/cask/test/cask/dsl/postflight_test.rb
+++ b/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::DSL::Postflight do
- let(:cask) { Hbc.load("basic-cask") }
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:dsl) { Hbc::DSL::Postflight.new(cask, Hbc::FakeSystemCommand) }
it_behaves_like Hbc::DSL::Base
diff --git a/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb b/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb
index 1c49a62ad..90d2634db 100644
--- a/Library/Homebrew/cask/test/cask/dsl/preflight_test.rb
+++ b/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::DSL::Preflight do
- let(:cask) { Hbc.load("basic-cask") }
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:dsl) { Hbc::DSL::Preflight.new(cask, Hbc::FakeSystemCommand) }
it_behaves_like Hbc::DSL::Base
diff --git a/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb b/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb
index c704706ad..4b7dd7557 100644
--- a/Library/Homebrew/cask/test/cask/dsl/uninstall_postflight_test.rb
+++ b/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::DSL::UninstallPostflight do
- let(:cask) { Hbc.load("basic-cask") }
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:dsl) { Hbc::DSL::UninstallPostflight.new(cask, Hbc::FakeSystemCommand) }
it_behaves_like Hbc::DSL::Base
diff --git a/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb b/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb
index f6ab36b60..a4930e99e 100644
--- a/Library/Homebrew/cask/test/cask/dsl/uninstall_preflight_test.rb
+++ b/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb
@@ -1,7 +1,7 @@
-require "test_helper"
+require "spec_helper"
describe Hbc::DSL::UninstallPreflight do
- let(:cask) { Hbc.load("basic-cask") }
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:dsl) { Hbc::DSL::UninstallPreflight.new(cask, Hbc::FakeSystemCommand) }
it_behaves_like Hbc::DSL::Base
diff --git a/Library/Homebrew/cask/spec/cask/dsl_spec.rb b/Library/Homebrew/cask/spec/cask/dsl_spec.rb
new file mode 100644
index 000000000..99525cc20
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/dsl_spec.rb
@@ -0,0 +1,548 @@
+require "spec_helper"
+
+describe Hbc::DSL do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/#{token}.rb") }
+ let(:token) { "basic-cask" }
+
+ context "stanzas" do
+ it "lets you set url, homepage, and version" do
+ expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg")
+ expect(cask.homepage).to eq("http://example.com/")
+ expect(cask.version.to_s).to eq("1.2.3")
+ end
+ end
+
+ describe "when a Cask includes an unknown method" do
+ let(:attempt_unknown_method) {
+ lambda do
+ Hbc::Cask.new("unexpected-method-cask") do
+ future_feature :not_yet_on_your_machine
+ end
+ end
+ }
+
+ it "prints a warning that it has encountered an unexpected method" do
+ expected = Regexp.compile(<<-EOS.undent.lines.map(&:chomp).join(""))
+ (?m)
+ Warning:
+ .*
+ Unexpected method 'future_feature' called on Cask unexpected-method-cask\\.
+ .*
+ https://github.com/caskroom/homebrew-cask/blob/master/doc/reporting_bugs/pre_bug_report.md
+ .*
+ https://github.com/caskroom/homebrew-cask#reporting-bugs
+ EOS
+
+ expect {
+ expect(attempt_unknown_method).not_to output.to_stdout
+ }.to output(expected).to_stderr
+ end
+
+ it "will simply warn, not throw an exception" do
+ expect {
+ shutup do
+ attempt_unknown_method.call
+ end
+ }.not_to raise_error
+ end
+ end
+
+ describe "header line" do
+ context "when invalid" do
+ let(:token) { "invalid/invalid-header-format" }
+ it "raises an error" do
+ expect { cask }.to raise_error(SyntaxError)
+ end
+ end
+
+ context "when token does not match the file name" do
+ let(:token) { "invalid/invalid-header-token-mismatch" }
+
+ it "raises an error" do
+ expect {
+ cask
+ }.to raise_error(Hbc::CaskTokenDoesNotMatchError, /Bad header line:.*does not match file name/)
+ end
+ end
+
+ context "when it contains no DSL version" do
+ let(:token) { "no-dsl-version" }
+
+ it "does not require a DSL version in the header" do
+ expect(cask.token).to eq("no-dsl-version")
+ expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg")
+ expect(cask.homepage).to eq("http://example.com/")
+ expect(cask.version.to_s).to eq("1.2.3")
+ end
+ end
+
+ context "when it contains a deprecated DSL version" do
+ let(:token) { "with-dsl-version" }
+
+ it "may use deprecated DSL version hash syntax" do
+ allow(ENV).to receive(:[]).with("HOMEBREW_DEVELOPER").and_return(nil)
+
+ shutup do
+ expect(cask.token).to eq("with-dsl-version")
+ expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg")
+ expect(cask.homepage).to eq("http://example.com/")
+ expect(cask.version.to_s).to eq("1.2.3")
+ end
+ end
+ end
+ end
+
+ describe "name stanza" do
+ it "lets you set the full name via a name stanza" do
+ cask = Hbc::Cask.new("name-cask") do
+ name "Proper Name"
+ end
+
+ expect(cask.name).to eq([
+ "Proper Name",
+ ])
+ end
+
+ it "Accepts an array value to the name stanza" do
+ cask = Hbc::Cask.new("array-name-cask") do
+ name ["Proper Name", "Alternate Name"]
+ end
+
+ expect(cask.name).to eq([
+ "Proper Name",
+ "Alternate Name",
+ ])
+ end
+
+ it "Accepts multiple name stanzas" do
+ cask = Hbc::Cask.new("multi-name-cask") do
+ name "Proper Name"
+ name "Alternate Name"
+ end
+
+ expect(cask.name).to eq([
+ "Proper Name",
+ "Alternate Name",
+ ])
+ end
+ end
+
+ describe "sha256 stanza" do
+ it "lets you set checksum via sha256" do
+ cask = Hbc::Cask.new("checksum-cask") do
+ sha256 "imasha2"
+ end
+
+ expect(cask.sha256).to eq("imasha2")
+ end
+ end
+
+ describe "language stanza" do
+ it "allows multilingual casks" do
+ cask = lambda do
+ Hbc::Cask.new("cask-with-apps") do
+ language "zh" do
+ sha256 "abc123"
+ "zh-CN"
+ end
+
+ language "en-US", default: true do
+ sha256 "xyz789"
+ "en-US"
+ end
+
+ url "https://example.org/#{language}.zip"
+ end
+ end
+
+ allow(MacOS).to receive(:languages).and_return(["zh"])
+ expect(cask.call.language).to eq("zh-CN")
+ expect(cask.call.sha256).to eq("abc123")
+ expect(cask.call.url.to_s).to eq("https://example.org/zh-CN.zip")
+
+ allow(MacOS).to receive(:languages).and_return(["zh-XX"])
+ expect(cask.call.language).to eq("zh-CN")
+ expect(cask.call.sha256).to eq("abc123")
+ expect(cask.call.url.to_s).to eq("https://example.org/zh-CN.zip")
+
+ allow(MacOS).to receive(:languages).and_return(["en"])
+ expect(cask.call.language).to eq("en-US")
+ expect(cask.call.sha256).to eq("xyz789")
+ expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip")
+
+ allow(MacOS).to receive(:languages).and_return(["xx-XX"])
+ expect(cask.call.language).to eq("en-US")
+ expect(cask.call.sha256).to eq("xyz789")
+ expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip")
+
+ allow(MacOS).to receive(:languages).and_return(["xx-XX", "zh", "en"])
+ expect(cask.call.language).to eq("zh-CN")
+ expect(cask.call.sha256).to eq("abc123")
+ expect(cask.call.url.to_s).to eq("https://example.org/zh-CN.zip")
+
+ allow(MacOS).to receive(:languages).and_return(["xx-XX", "en-US", "zh"])
+ expect(cask.call.language).to eq("en-US")
+ expect(cask.call.sha256).to eq("xyz789")
+ expect(cask.call.url.to_s).to eq("https://example.org/en-US.zip")
+ end
+ end
+
+ describe "app stanza" do
+ it "allows you to specify app stanzas" do
+ cask = Hbc::Cask.new("cask-with-apps") do
+ app "Foo.app"
+ app "Bar.app"
+ end
+
+ expect(Array(cask.artifacts[:app])).to eq([["Foo.app"], ["Bar.app"]])
+ end
+
+ it "allow app stanzas to be empty" do
+ cask = Hbc::Cask.new("cask-with-no-apps")
+ expect(Array(cask.artifacts[:app])).to eq([])
+ end
+ end
+
+ describe "caveats stanza" do
+ it "allows caveats to be specified via a method define" do
+ cask = Hbc::Cask.new("plain-cask")
+
+ expect(cask.caveats).to be_empty
+
+ cask = Hbc::Cask.new("cask-with-caveats") do
+ def caveats; <<-EOS.undent
+ When you install this Cask, you probably want to know this.
+ EOS
+ end
+ end
+
+ expect(cask.caveats).to eq("When you install this Cask, you probably want to know this.\n")
+ end
+ end
+
+ describe "pkg stanza" do
+ it "allows installable pkgs to be specified" do
+ cask = Hbc::Cask.new("cask-with-pkgs") do
+ pkg "Foo.pkg"
+ pkg "Bar.pkg"
+ end
+
+ expect(Array(cask.artifacts[:pkg])).to eq([["Foo.pkg"], ["Bar.pkg"]])
+ end
+ end
+
+ describe "url stanza" do
+ let(:token) { "invalid/invalid-two-url" }
+
+ it "prevents defining multiple urls" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError, /'url' stanza may only appear once/)
+ end
+ end
+
+ describe "homepage stanza" do
+ let(:token) { "invalid/invalid-two-homepage" }
+
+ it "prevents defining multiple homepages" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError, /'homepage' stanza may only appear once/)
+ end
+ end
+
+ describe "version stanza" do
+ let(:token) { "invalid/invalid-two-version" }
+ it "prevents defining multiple versions" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError, /'version' stanza may only appear once/)
+ end
+ end
+
+ describe "appcast stanza" do
+ let(:token) { "with-appcast" }
+
+ it "allows appcasts to be specified" do
+ expect(cask.appcast.to_s).to match(/^http/)
+ end
+
+ context "when multiple appcasts are defined" do
+ let(:token) { "invalid/invalid-appcast-multiple" }
+
+ it "raises an error" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError, /'appcast' stanza may only appear once/)
+ end
+ end
+
+ context "when appcast URL is invalid" do
+ let(:token) { "invalid/invalid-appcast-url" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+ end
+
+ describe "GPG stanza" do
+ context "valid" do
+ let(:token) { "with-gpg" }
+
+ it "is allowed to be specified" do
+ expect(cask.gpg.to_s).to match(/\S/)
+ end
+ end
+
+ context "with :key_url" do
+ let(:token) { "with-gpg-key-url" }
+ it "is allowed to be specified" do
+ expect(cask.gpg.to_s).to match(/\S/)
+ end
+ end
+
+ context "specifying mmultiple times" do
+ let(:token) { "invalid/invalid-gpg-multiple-stanzas" }
+
+ it "is not allowed" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError, /'gpg' stanza may only appear once/)
+ end
+ end
+
+ context "missing GPG key parameters" do
+ let(:token) { "invalid/invalid-gpg-missing-key" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError, /'gpg' stanza must include exactly one/)
+ end
+ end
+
+ context "conflicting GPG key parameters" do
+ let(:token) { "invalid/invalid-gpg-conflicting-keys" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError, /'gpg' stanza must include exactly one/)
+ end
+ end
+
+ context "invalid GPG signature URLs" do
+ let(:token) { "invalid/invalid-gpg-signature-url" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+
+ context "invalid GPG key URLs" do
+ let(:token) { "invalid/invalid-gpg-key-url" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+
+ context "invalid GPG key IDs" do
+ let(:token) { "invalid/invalid-gpg-key-id" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+
+ context "GPG parameter is unknown" do
+ let(:token) { "invalid/invalid-gpg-parameter" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+ end
+
+ describe "depends_on stanza" do
+ let(:token) { "invalid/invalid-depends-on-key" }
+
+ it "refuses to load with an invalid depends_on key" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+
+ describe "depends_on formula" do
+ context "with one Formula" do
+ let(:token) { "with-depends-on-formula" }
+
+ it "allows depends_on formula to be specified" do
+ expect(cask.depends_on.formula).not_to be nil
+ end
+ end
+
+ context "with multiple Formulae" do
+ let(:token) { "with-depends-on-formula-multiple" }
+
+ it "allows multiple depends_on formula to be specified" do
+ expect(cask.depends_on.formula).not_to be nil
+ end
+ end
+ end
+
+ describe "depends_on cask" do
+ context "specifying one" do
+ let(:token) { "with-depends-on-cask" }
+ it "is allowed" do
+ expect(cask.depends_on.cask).not_to be nil
+ end
+ end
+
+ context "specifying multiple" do
+ let(:token) { "with-depends-on-cask-multiple" }
+
+ it "is allowed" do
+ expect(cask.depends_on.cask).not_to be nil
+ end
+ end
+ end
+
+ describe "depends_on macos" do
+ context "valid" do
+ let(:token) { "with-depends-on-macos-string" }
+
+ it "allows depends_on macos to be specified" do
+ expect(cask.depends_on.macos).not_to be nil
+ end
+ end
+
+ context "invalid depends_on macos value" do
+ let(:token) { "invalid/invalid-depends-on-macos-bad-release" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+
+ context "conflicting depends_on macos forms" do
+ let(:token) { "invalid/invalid-depends-on-macos-conflicting-forms" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+ end
+
+ describe "depends_on arch" do
+ context "valid" do
+ let(:token) { "with-depends-on-arch" }
+
+ it "is allowed to be specified" do
+ expect(cask.depends_on.arch).not_to be nil
+ end
+ end
+
+ context "invalid depends_on arch value" do
+ let(:token) { "invalid/invalid-depends-on-arch-value" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+ end
+
+ describe "depends_on x11" do
+ context "valid" do
+ let(:token) { "with-depends-on-x11" }
+
+ it "is allowed to be specified" do
+ expect(cask.depends_on.x11).not_to be nil
+ end
+ end
+
+ context "invalid depends_on x11 value" do
+ let(:token) { "invalid/invalid-depends-on-x11-value" }
+
+ it "refuses to load" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+ end
+
+ describe "conflicts_with stanza" do
+ context "valid" do
+ let(:token) { "with-conflicts-with" }
+
+ it "allows conflicts_with stanza to be specified" do
+ expect(cask.conflicts_with.formula).not_to be nil
+ end
+ end
+
+ context "invalid conflicts_with key" do
+ let(:token) { "invalid/invalid-conflicts-with-key" }
+
+ it "refuses to load invalid conflicts_with key" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError)
+ end
+ end
+ end
+
+ describe "installer stanza" do
+ context "script" do
+ let(:token) { "with-installer-script" }
+
+ it "allows installer script to be specified" do
+ expect(cask.artifacts[:installer].first.script[:executable]).to eq("/usr/bin/true")
+ expect(cask.artifacts[:installer].first.script[:args]).to eq(["--flag"])
+ expect(cask.artifacts[:installer].to_a[1].script[:executable]).to eq("/usr/bin/false")
+ expect(cask.artifacts[:installer].to_a[1].script[:args]).to eq(["--flag"])
+ end
+ end
+
+ context "manual" do
+ let(:token) { "with-installer-manual" }
+
+ it "allows installer manual to be specified" do
+ expect(cask.artifacts[:installer].first.manual).to eq("Caffeine.app")
+ end
+ end
+ end
+
+ describe "stage_only stanza" do
+ context "when there is no other activatable artifact" do
+ let(:token) { "stage-only" }
+
+ it "allows stage_only stanza to be specified" do
+ expect(cask.artifacts[:stage_only].first).to eq([true])
+ end
+ end
+
+ context "when there is are activatable artifacts" do
+ let(:token) { "invalid/invalid-stage-only-conflict" }
+
+ it "prevents specifying stage_only" do
+ expect { cask }.to raise_error(Hbc::CaskInvalidError, /'stage_only' must be the only activatable artifact/)
+ end
+ end
+ end
+
+ describe "auto_updates stanza" do
+ let(:token) { "auto-updates" }
+
+ it "allows auto_updates stanza to be specified" do
+ expect(cask.auto_updates).to be true
+ end
+ end
+
+ describe "appdir" do
+ context "interpolation of the appdir in stanzas" do
+ let(:token) { "appdir-interpolation" }
+
+ it "is allowed" do
+ expect(cask.artifacts[:binary].first).to eq(["#{Hbc.appdir}/some/path"])
+ end
+ end
+
+ it "does not include a trailing slash" do
+ begin
+ original_appdir = Hbc.appdir
+ Hbc.appdir = "#{original_appdir}/"
+
+ cask = Hbc::Cask.new("appdir-trailing-slash") do
+ binary "#{appdir}/some/path"
+ end
+
+ expect(cask.artifacts[:binary].first).to eq(["#{original_appdir}/some/path"])
+ ensure
+ Hbc.appdir = original_appdir
+ end
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/spec/cask/installer_spec.rb b/Library/Homebrew/cask/spec/cask/installer_spec.rb
new file mode 100644
index 000000000..c0148c387
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/installer_spec.rb
@@ -0,0 +1,398 @@
+require "spec_helper"
+
+describe Hbc::Installer do
+ describe "install" do
+ let(:empty_depends_on_stub) {
+ double(formula: [], cask: [], macos: nil, arch: nil, x11: nil)
+ }
+
+ it "downloads and installs a nice fresh Cask" do
+ caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
+
+ shutup do
+ Hbc::Installer.new(caffeine).install
+ end
+
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory
+ expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory
+ end
+
+ it "works with dmg-based Casks" do
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-dmg.rb")
+
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-dmg", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container")).to be_a_file
+ end
+
+ it "works with tar-gz-based Casks" do
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-tar-gz.rb")
+
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-tar-gz", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container")).to be_a_file
+ end
+
+ it "works with cab-based Casks" do
+ skip("cabextract not installed") if which("cabextract").nil?
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-cab.rb")
+
+ allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub)
+
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-cab", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container")).to be_a_file
+ end
+
+ it "works with Adobe AIR-based Casks" do
+ skip("Adobe AIR not installed") unless Hbc::Container::Air.installer_exist?
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-air.rb")
+
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-air", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container.app")).to be_a_directory
+ end
+
+ it "works with 7z-based Casks" do
+ skip("unar not installed") if which("unar").nil?
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-7z.rb")
+
+ allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub)
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-7z", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container")).to be_a_file
+ end
+
+ it "works with xar-based Casks" do
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xar.rb")
+
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-xar", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container")).to be_a_file
+ end
+
+ it "works with Stuffit-based Casks" do
+ skip("unar not installed") if which("unar").nil?
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-sit.rb")
+
+ allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub)
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-sit", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container")).to be_a_file
+ end
+
+ it "works with RAR-based Casks" do
+ skip("unar not installed") if which("unar").nil?
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-rar.rb")
+
+ allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub)
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-rar", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container")).to be_a_file
+ end
+
+ it "works with pure bzip2-based Casks" do
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-bzip2.rb")
+
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-bzip2", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container-bzip2--#{asset.version}")).to be_a_file
+ end
+
+ it "works with pure gzip-based Casks" do
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-gzip.rb")
+
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-gzip", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container")).to be_a_file
+ end
+
+ it "works with pure xz-based Casks" do
+ skip("unxz not installed") if which("unxz").nil?
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xz.rb")
+
+ allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub)
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-xz", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container-xz--#{asset.version}")).to be_a_file
+ end
+
+ it "works with lzma-based Casks" do
+ skip("unlzma not installed") if which("unlzma").nil?
+ asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-lzma.rb")
+
+ allow(asset).to receive(:depends_on).and_return(empty_depends_on_stub)
+ shutup do
+ Hbc::Installer.new(asset).install
+ end
+
+ expect(Hbc.caskroom.join("container-lzma", asset.version)).to be_a_directory
+ expect(Hbc.appdir.join("container-lzma--#{asset.version}")).to be_a_file
+ end
+
+ it "blows up on a bad checksum" do
+ bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb")
+ expect {
+ shutup do
+ Hbc::Installer.new(bad_checksum).install
+ end
+ }.to raise_error(Hbc::CaskSha256MismatchError)
+ end
+
+ it "blows up on a missing checksum" do
+ missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb")
+ expect {
+ shutup do
+ Hbc::Installer.new(missing_checksum).install
+ end
+ }.to raise_error(Hbc::CaskSha256MissingError)
+ end
+
+ it "installs fine if sha256 :no_check is used" do
+ no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb")
+
+ shutup do
+ Hbc::Installer.new(no_checksum).install
+ end
+
+ expect(no_checksum).to be_installed
+ end
+
+ it "fails to install if sha256 :no_check is used with --require-sha" do
+ no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb")
+ expect {
+ Hbc::Installer.new(no_checksum, require_sha: true).install
+ }.to raise_error(Hbc::CaskNoShasumError)
+ end
+
+ it "installs fine if sha256 :no_check is used with --require-sha and --force" do
+ no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb")
+
+ shutup do
+ Hbc::Installer.new(no_checksum, require_sha: true, force: true).install
+ end
+
+ expect(no_checksum).to be_installed
+ end
+
+ it "prints caveats if they're present" do
+ with_caveats = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-caveats.rb")
+
+ expect {
+ Hbc::Installer.new(with_caveats).install
+ }.to output(/Here are some things you might want to know/).to_stdout
+
+ expect(with_caveats).to be_installed
+ end
+
+ it "prints installer :manual instructions when present" do
+ with_installer_manual = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb")
+
+ expect {
+ Hbc::Installer.new(with_installer_manual).install
+ }.to output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'/).to_stdout
+
+ expect(with_installer_manual).to be_installed
+ end
+
+ it "does not extract __MACOSX directories from zips" do
+ with_macosx_dir = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-macosx-dir.rb")
+
+ shutup do
+ Hbc::Installer.new(with_macosx_dir).install
+ end
+
+ expect(with_macosx_dir.staged_path.join("__MACOSX")).not_to be_a_directory
+ end
+
+ it "installer method raises an exception when already-installed Casks which auto-update are attempted" do
+ with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb")
+
+ expect(with_auto_updates).not_to be_installed
+
+ installer = Hbc::Installer.new(with_auto_updates)
+
+ shutup do
+ installer.install
+ end
+
+ expect {
+ installer.install
+ }.to raise_error(Hbc::CaskAlreadyInstalledAutoUpdatesError)
+ end
+
+ it "allows already-installed Casks which auto-update to be installed if force is provided" do
+ with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb")
+
+ expect(with_auto_updates).not_to be_installed
+
+ shutup do
+ Hbc::Installer.new(with_auto_updates).install
+ end
+
+ expect {
+ shutup do
+ Hbc::Installer.new(with_auto_updates, force: true).install
+ end
+ }.not_to raise_error
+ end
+
+ # unlike the CLI, the internal interface throws exception on double-install
+ it "installer method raises an exception when already-installed Casks are attempted" do
+ transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
+
+ expect(transmission).not_to be_installed
+
+ installer = Hbc::Installer.new(transmission)
+
+ shutup do
+ installer.install
+ end
+
+ expect {
+ installer.install
+ }.to raise_error(Hbc::CaskAlreadyInstalledError)
+ end
+
+ it "allows already-installed Casks to be installed if force is provided" do
+ transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
+
+ expect(transmission).not_to be_installed
+
+ shutup do
+ Hbc::Installer.new(transmission).install
+ end
+
+ shutup do
+ Hbc::Installer.new(transmission, force: true).install
+ end # wont_raise
+ end
+
+ it "works naked-pkg-based Casks" do
+ naked_pkg = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-pkg.rb")
+
+ shutup do
+ Hbc::Installer.new(naked_pkg).install
+ end
+
+ expect(Hbc.caskroom.join("container-pkg", naked_pkg.version, "container.pkg")).to be_a_file
+ end
+
+ it "works properly with an overridden container :type" do
+ naked_executable = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/naked-executable.rb")
+
+ shutup do
+ Hbc::Installer.new(naked_executable).install
+ end
+
+ expect(Hbc.caskroom.join("naked-executable", naked_executable.version, "naked_executable")).to be_a_file
+ end
+
+ it "works fine with a nested container" do
+ nested_app = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb")
+
+ shutup do
+ Hbc::Installer.new(nested_app).install
+ end
+
+ expect(Hbc.appdir.join("MyNestedApp.app")).to be_a_directory
+ end
+
+ it "generates and finds a timestamped metadata directory for an installed Cask" do
+ caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
+
+ shutup do
+ Hbc::Installer.new(caffeine).install
+ end
+
+ m_path = caffeine.metadata_path(:now, true)
+ expect(caffeine.metadata_path(:now, false)).to eq(m_path)
+ expect(caffeine.metadata_path(:latest)).to eq(m_path)
+ end
+
+ it "generates and finds a metadata subdirectory for an installed Cask" do
+ caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
+
+ shutup do
+ Hbc::Installer.new(caffeine).install
+ end
+
+ subdir_name = "Casks"
+ m_subdir = caffeine.metadata_subdir(subdir_name, :now, true)
+ expect(caffeine.metadata_subdir(subdir_name, :now, false)).to eq(m_subdir)
+ expect(caffeine.metadata_subdir(subdir_name, :latest)).to eq(m_subdir)
+ end
+ end
+
+ describe "uninstall" do
+ it "fully uninstalls a Cask" do
+ caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
+ installer = Hbc::Installer.new(caffeine)
+
+ shutup do
+ installer.install
+ installer.uninstall
+ end
+
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app")).not_to be_a_directory
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory
+ expect(Hbc.caskroom.join("local-caffeine")).not_to be_a_directory
+ end
+
+ it "uninstalls all versions if force is set" do
+ caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
+ mutated_version = caffeine.version + ".1"
+
+ shutup do
+ Hbc::Installer.new(caffeine).install
+ end
+
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory
+ expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory
+ FileUtils.mv(Hbc.caskroom.join("local-caffeine", caffeine.version), Hbc.caskroom.join("local-caffeine", mutated_version))
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory
+ expect(Hbc.caskroom.join("local-caffeine", mutated_version)).to be_a_directory
+
+ shutup do
+ Hbc::Installer.new(caffeine, force: true).uninstall
+ end
+
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).not_to be_a_directory
+ expect(Hbc.caskroom.join("local-caffeine", mutated_version)).not_to be_a_directory
+ expect(Hbc.caskroom.join("local-caffeine")).not_to be_a_directory
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/spec/cask/pkg_spec.rb b/Library/Homebrew/cask/spec/cask/pkg_spec.rb
new file mode 100644
index 000000000..2f0ba0839
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/pkg_spec.rb
@@ -0,0 +1,114 @@
+require "spec_helper"
+
+describe Hbc::Pkg do
+ describe "uninstall" do
+ let(:fake_system_command) { Hbc::NeverSudoSystemCommand }
+ let(:empty_response) { double(stdout: "") }
+ let(:pkg) { described_class.new("my.fake.pkg", fake_system_command) }
+
+ it "removes files and dirs referenced by the pkg" do
+ some_files = Array.new(3) { Pathname.new(Tempfile.new("testfile").path) }
+ allow(pkg).to receive(:pkgutil_bom_files).and_return(some_files)
+
+ some_specials = Array.new(3) { Pathname.new(Tempfile.new("testfile").path) }
+ allow(pkg).to receive(:pkgutil_bom_specials).and_return(some_specials)
+
+ some_dirs = Array.new(3) { Pathname.new(Dir.mktmpdir) }
+ allow(pkg).to receive(:pkgutil_bom_dirs).and_return(some_dirs)
+
+ allow(pkg).to receive(:forget)
+
+ pkg.uninstall
+
+ some_files.each do |file|
+ expect(file).not_to exist
+ end
+
+ some_dirs.each do |dir|
+ expect(dir).not_to exist
+ end
+ end
+
+ context "pkgutil" do
+ let(:fake_system_command) { class_double(Hbc::SystemCommand) }
+
+ it "forgets the pkg" do
+ allow(fake_system_command).to receive(:run!).with(
+ "/usr/sbin/pkgutil",
+ args: ["--only-files", "--files", "my.fake.pkg"]
+ ).and_return(empty_response)
+
+ allow(fake_system_command).to receive(:run!).with(
+ "/usr/sbin/pkgutil",
+ args: ["--only-dirs", "--files", "my.fake.pkg"]
+ ).and_return(empty_response)
+
+ allow(fake_system_command).to receive(:run!).with(
+ "/usr/sbin/pkgutil",
+ args: ["--files", "my.fake.pkg"]
+ ).and_return(empty_response)
+
+ expect(fake_system_command).to receive(:run!).with(
+ "/usr/sbin/pkgutil",
+ args: ["--forget", "my.fake.pkg"],
+ sudo: true
+ )
+
+ pkg.uninstall
+ end
+ end
+
+ it "removes broken symlinks" do
+ fake_dir = Pathname.new(Dir.mktmpdir)
+ fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) }
+
+ intact_symlink = fake_dir.join("intact_symlink").tap { |path| path.make_symlink(fake_file) }
+ broken_symlink = fake_dir.join("broken_symlink").tap { |path| path.make_symlink("im_nota_file") }
+
+ allow(pkg).to receive(:pkgutil_bom_specials).and_return([])
+ allow(pkg).to receive(:pkgutil_bom_files).and_return([])
+ allow(pkg).to receive(:pkgutil_bom_dirs).and_return([fake_dir])
+ allow(pkg).to receive(:forget)
+
+ pkg.uninstall
+
+ expect(intact_symlink).to exist
+ expect(broken_symlink).not_to exist
+ expect(fake_dir).to exist
+ end
+
+ it "removes files incorrectly reportes as directories" do
+ fake_dir = Pathname.new(Dir.mktmpdir)
+ fake_file = fake_dir.join("ima_file_pretending_to_be_a_dir").tap { |path| FileUtils.touch(path) }
+
+ allow(pkg).to receive(:pkgutil_bom_specials).and_return([])
+ allow(pkg).to receive(:pkgutil_bom_files).and_return([])
+ allow(pkg).to receive(:pkgutil_bom_dirs).and_return([fake_file, fake_dir])
+ allow(pkg).to receive(:forget)
+
+ pkg.uninstall
+
+ expect(fake_file).not_to exist
+ expect(fake_dir).not_to exist
+ end
+
+ it "snags permissions on ornery dirs, but returns them afterwards" do
+ fake_dir = Pathname.new(Dir.mktmpdir)
+ fake_file = fake_dir.join("ima_installed_file").tap { |path| FileUtils.touch(path) }
+ fake_dir.chmod(0000)
+
+ allow(pkg).to receive(:pkgutil_bom_specials).and_return([])
+ allow(pkg).to receive(:pkgutil_bom_files).and_return([fake_file])
+ allow(pkg).to receive(:pkgutil_bom_dirs).and_return([fake_dir])
+ allow(pkg).to receive(:forget)
+
+ shutup do
+ pkg.uninstall
+ end
+
+ expect(fake_dir).to be_a_directory
+ expect(fake_file).not_to be_a_file
+ expect((fake_dir.stat.mode % 01000).to_s(8)).to eq("0")
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/spec/cask/scopes_spec.rb b/Library/Homebrew/cask/spec/cask/scopes_spec.rb
index 12c1a697f..abf4b6401 100644
--- a/Library/Homebrew/cask/spec/cask/scopes_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/scopes_spec.rb
@@ -1,39 +1,31 @@
describe Hbc::Scopes do
describe "installed" do
- let(:fake_caskroom) { Pathname(Dir.mktmpdir) }
-
- before do
- allow(Hbc).to receive(:caskroom) { fake_caskroom }
- end
-
- after do
- fake_caskroom.rmtree
- end
-
it "returns a list installed Casks by loading Casks for all the dirs that exist in the caskroom" do
allow(Hbc).to receive(:load) { |token| "loaded-#{token}" }
- fake_caskroom.join("cask-bar").mkdir
- fake_caskroom.join("cask-foo").mkdir
+ Hbc.caskroom.join("cask-bar").mkpath
+ Hbc.caskroom.join("cask-foo").mkpath
installed_casks = Hbc.installed
expect(Hbc).to have_received(:load).with("cask-bar")
expect(Hbc).to have_received(:load).with("cask-foo")
- expect(installed_casks).to eq(%w[
- loaded-cask-bar
- loaded-cask-foo
- ])
+ expect(installed_casks).to eq(
+ %w[
+ loaded-cask-bar
+ loaded-cask-foo
+ ]
+ )
end
it "optimizes performance by resolving to a fully qualified path before calling Hbc.load" do
- fake_tapped_cask_dir = Pathname(Dir.mktmpdir).join("Casks")
+ fake_tapped_cask_dir = Pathname.new(Dir.mktmpdir).join("Casks")
absolute_path_to_cask = fake_tapped_cask_dir.join("some-cask.rb")
allow(Hbc).to receive(:load)
allow(Hbc).to receive(:all_tapped_cask_dirs) { [fake_tapped_cask_dir] }
- fake_caskroom.join("some-cask").mkdir
+ Hbc.caskroom.join("some-cask").mkdir
fake_tapped_cask_dir.mkdir
FileUtils.touch(absolute_path_to_cask)
diff --git a/Library/Homebrew/cask/test/cask/staged_test.rb b/Library/Homebrew/cask/spec/cask/staged_spec.rb
index fe3bf2339..10f1cbb47 100644
--- a/Library/Homebrew/cask/test/cask/staged_test.rb
+++ b/Library/Homebrew/cask/spec/cask/staged_spec.rb
@@ -1,18 +1,18 @@
-require "test_helper"
+require "spec_helper"
# TODO: this test should be named after the corresponding class, once
# that class is abstracted from installer.rb. It makes little sense
# to be invoking bundle_identifier off of the installer instance.
describe "Operations on staged Casks" do
describe "bundle ID" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") }
+ let(:installer) { Hbc::Installer.new(cask) }
it "fetches the bundle ID from a staged cask" do
- transmission_cask = Hbc.load("local-transmission")
- tr_installer = Hbc::Installer.new(transmission_cask)
-
shutup do
- tr_installer.install
+ installer.install
end
- tr_installer.bundle_identifier.must_equal("org.m0k.transmission")
+
+ expect(installer.bundle_identifier).to eq("org.m0k.transmission")
end
end
end
diff --git a/Library/Homebrew/cask/spec/cask/url_checker_spec.rb b/Library/Homebrew/cask/spec/cask/url_checker_spec.rb
new file mode 100644
index 000000000..3b46bc587
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/url_checker_spec.rb
@@ -0,0 +1,44 @@
+require "spec_helper"
+
+describe Hbc::UrlChecker do
+ describe "request processing" do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
+ let(:checker) { Hbc::UrlChecker.new(cask) }
+
+ before(:each) do
+ allow(Hbc::Fetcher).to receive(:head).and_return(response)
+ checker.run
+ end
+
+ context "with an empty response" do
+ let(:response) { "" }
+
+ it "adds an error" do
+ expect(checker.errors).to include("timeout while requesting #{cask.url}")
+ end
+ end
+
+ context "with a valid http response" do
+ let(:response) {
+ <<-EOS.undent
+ HTTP/1.1 200 OK
+ Content-Type: application/x-apple-diskimage
+ ETag: "b4208f3e84967be4b078ecaa03fba941"
+ Content-Length: 23726161
+ Last-Modified: Sun, 12 Aug 2012 21:17:21 GMT
+ EOS
+ }
+
+ it "properly populates the response code and headers" do
+ expect(checker.errors).to be_empty
+ expect(checker.response_status).to eq("HTTP/1.1 200 OK")
+ expect(checker.headers).to eq(
+ "Content-Type" => "application/x-apple-diskimage",
+ "ETag" => '"b4208f3e84967be4b078ecaa03fba941"',
+ "Content-Length" => "23726161",
+ "Last-Modified" => "Sun, 12 Aug 2012 21:17:21 GMT"
+ )
+ end
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb b/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb
index a379dafb9..d803c566d 100644
--- a/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb
@@ -1,6 +1,4 @@
describe Hbc::Verify::Checksum do
- include Sha256Helper
-
let(:cask) { double("cask") }
let(:downloaded_path) { double("downloaded_path") }
let(:verification) { described_class.new(cask, downloaded_path) }
@@ -35,7 +33,7 @@ describe Hbc::Verify::Checksum do
end
context "sha256 is a valid shasum" do
- let(:sha256) { random_sha256 }
+ let(:sha256) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" }
it { is_expected.to be true }
end
@@ -44,7 +42,7 @@ describe Hbc::Verify::Checksum do
describe "#verify" do
subject { verification.verify }
- let(:computed) { random_sha256 }
+ let(:computed) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" }
before do
allow(verification).to receive(:computed).and_return(computed)
@@ -67,7 +65,7 @@ describe Hbc::Verify::Checksum do
end
context "sha256 does not match computed" do
- let(:sha256) { random_sha256 }
+ let(:sha256) { "d3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33f" }
it "raises an error" do
expect { subject }.to raise_error(Hbc::CaskSha256MismatchError)
diff --git a/Library/Homebrew/cask/spec/plist/parser_spec.rb b/Library/Homebrew/cask/spec/plist/parser_spec.rb
new file mode 100644
index 000000000..9d4a59fdc
--- /dev/null
+++ b/Library/Homebrew/cask/spec/plist/parser_spec.rb
@@ -0,0 +1,75 @@
+require "spec_helper"
+
+describe Plist do
+ subject { described_class.parse_xml(input) }
+
+ describe "::parse_xml" do
+ context "given a hdiutil output as input" do
+ let(:input) {
+ <<-EOS.undent
+ <?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+ <plist version="1.0">
+ <dict>
+ <key>system-entities</key>
+ <array>
+ <dict>
+ <key>content-hint</key>
+ <string>Apple_partition_map</string>
+ <key>dev-entry</key>
+ <string>/dev/disk3s1</string>
+ <key>potentially-mountable</key>
+ <false/>
+ <key>unmapped-content-hint</key>
+ <string>Apple_partition_map</string>
+ </dict>
+ <dict>
+ <key>content-hint</key>
+ <string>Apple_partition_scheme</string>
+ <key>dev-entry</key>
+ <string>/dev/disk3</string>
+ <key>potentially-mountable</key>
+ <false/>
+ <key>unmapped-content-hint</key>
+ <string>Apple_partition_scheme</string>
+ </dict>
+ <dict>
+ <key>content-hint</key>
+ <string>Apple_HFS</string>
+ <key>dev-entry</key>
+ <string>/dev/disk3s2</string>
+ <key>mount-point</key>
+ <string>/private/tmp/dmg.BhfS2g</string>
+ <key>potentially-mountable</key>
+ <true/>
+ <key>unmapped-content-hint</key>
+ <string>Apple_HFS</string>
+ <key>volume-kind</key>
+ <string>hfs</string>
+ </dict>
+ </array>
+ </dict>
+ </plist>
+ EOS
+ }
+
+ it "successfully parses it" do
+ expect(subject.keys).to eq(["system-entities"])
+ expect(subject["system-entities"].length).to eq(3)
+ expect(subject["system-entities"].map { |e| e["dev-entry"] }).to eq(
+ %w[
+ /dev/disk3s1
+ /dev/disk3
+ /dev/disk3s2
+ ]
+ )
+ end
+ end
+
+ context "given an empty input" do
+ let(:input) { "" }
+
+ it { is_expected.to be_nil }
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb
index 458fe00f4..ea6a87f41 100644
--- a/Library/Homebrew/cask/spec/spec_helper.rb
+++ b/Library/Homebrew/cask/spec/spec_helper.rb
@@ -15,17 +15,12 @@ require "global"
# add Homebrew-Cask to load path
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
-require "test/support/helper/env"
require "test/support/helper/shutup"
-Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).each(&method(:require))
+Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "**", "*.rb")).each(&method(:require))
require "hbc"
-module Hbc
- class TestCask < Cask; end
-end
-
# create and override default directories
Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath)
Hbc.cache.mkpath
@@ -33,11 +28,42 @@ Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath)
Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|
# link test casks
FileUtils.mkdir_p tap.path.dirname
- FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), tap.path
+ FileUtils.ln_s TEST_FIXTURE_DIR.join("cask"), tap.path
end
+# pretend that the caskroom/cask Tap is installed
+FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path
+
+HOMEBREW_CASK_DIRS = [
+ :appdir,
+ :caskroom,
+ :prefpanedir,
+ :qlplugindir,
+ :servicedir,
+ :binarydir,
+].freeze
+
RSpec.configure do |config|
config.order = :random
- config.include(Test::Helper::Env)
config.include(Test::Helper::Shutup)
+ config.around(:each) do |example|
+ begin
+ @__dirs = HOMEBREW_CASK_DIRS.map { |dir|
+ Pathname.new(TEST_TMPDIR).join(dir.to_s).tap { |path|
+ path.mkpath
+ Hbc.public_send("#{dir}=", path)
+ }
+ }
+
+ @__argv = ARGV.dup
+ @__env = ENV.to_hash # dup doesn't work on ENV
+
+ example.run
+ ensure
+ ARGV.replace(@__argv)
+ ENV.replace(@__env)
+
+ FileUtils.rm_rf @__dirs.map(&:children)
+ end
+ end
end
diff --git a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb b/Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb
deleted file mode 100644
index f7657dbb5..000000000
--- a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-no-target.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-test_cask 'generic-artifact-no-target' do
- artifact 'Caffeine.app'
-end
diff --git a/Library/Homebrew/cask/test/support/fake_system_command.rb b/Library/Homebrew/cask/spec/support/fake_system_command.rb
index 97efd0761..b9390d482 100644
--- a/Library/Homebrew/cask/test/support/fake_system_command.rb
+++ b/Library/Homebrew/cask/spec/support/fake_system_command.rb
@@ -1,3 +1,7 @@
+def sudo(*args)
+ %w[/usr/bin/sudo -E --] + args.flatten
+end
+
module Hbc
class FakeSystemCommand
def self.responses
@@ -42,6 +46,7 @@ module Hbc
def self.run(command_string, options = {})
command = Hbc::SystemCommand.new(command_string, options).command
+ puts command
unless responses.key?(command)
raise("no response faked for #{command.inspect}, faked responses are: #{responses.inspect}")
end
@@ -61,17 +66,12 @@ module Hbc
end
end
-module FakeSystemCommandHooks
- def after_teardown
- super
- Hbc::FakeSystemCommand.verify_expectations!
- ensure
- Hbc::FakeSystemCommand.clear
- end
-end
-
-module MiniTest
- class Spec
- include FakeSystemCommandHooks
+RSpec.configure do |config|
+ config.after(:each) do
+ begin
+ Hbc::FakeSystemCommand.verify_expectations!
+ ensure
+ Hbc::FakeSystemCommand.clear
+ end
end
end
diff --git a/Library/Homebrew/cask/spec/support/file_helper.rb b/Library/Homebrew/cask/spec/support/file_helper.rb
deleted file mode 100644
index abe7b2618..000000000
--- a/Library/Homebrew/cask/spec/support/file_helper.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-module FileHelper
- module_function
-
- def valid_alias?(candidate)
- return false unless candidate.symlink?
- candidate.readlink.exist?
- end
-end
diff --git a/Library/Homebrew/cask/spec/support/install_helper.rb b/Library/Homebrew/cask/spec/support/install_helper.rb
index c8023c66b..d91b9ea57 100644
--- a/Library/Homebrew/cask/spec/support/install_helper.rb
+++ b/Library/Homebrew/cask/spec/support/install_helper.rb
@@ -1,10 +1,42 @@
module InstallHelper
- class << self
- def install_without_artifacts(cask)
- Hbc::Installer.new(cask).tap do |i|
+ module_function
+
+ require "test/support/helper/shutup"
+ extend Test::Helper::Shutup
+
+ def self.install_without_artifacts(cask)
+ Hbc::Installer.new(cask).tap do |i|
+ shutup do
i.download
i.extract_primary_container
end
end
end
+
+ def self.install_without_artifacts_with_caskfile(cask)
+ Hbc::Installer.new(cask).tap do |i|
+ shutup do
+ i.download
+ i.extract_primary_container
+ i.save_caskfile
+ end
+ end
+ end
+
+ def install_without_artifacts(cask)
+ Hbc::Installer.new(cask).tap do |i|
+ shutup do
+ i.download
+ i.extract_primary_container
+ end
+ end
+ end
+
+ def install_with_caskfile(cask)
+ Hbc::Installer.new(cask).tap do |i|
+ shutup do
+ i.save_caskfile
+ end
+ end
+ end
end
diff --git a/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb b/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb
deleted file mode 100644
index b5c84869b..000000000
--- a/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module Kernel
- alias real_at_exit at_exit
-
- def at_exit(&block)
- real_at_exit(&block) unless ENV["DISABLE_AT_EXIT"]
- end
-
- def with_disabled_at_exit
- ENV["DISABLE_AT_EXIT"] = "1"
- yield
- ENV.delete("DISABLE_AT_EXIT")
- end
-end
diff --git a/Library/Homebrew/cask/test/support/never_sudo_system_command.rb b/Library/Homebrew/cask/spec/support/never_sudo_system_command.rb
index 8a370df44..eb8b677f2 100644
--- a/Library/Homebrew/cask/test/support/never_sudo_system_command.rb
+++ b/Library/Homebrew/cask/spec/support/never_sudo_system_command.rb
@@ -1,3 +1,5 @@
+require "hbc/system_command"
+
module Hbc
class NeverSudoSystemCommand < SystemCommand
def self.run(command, options = {})
diff --git a/Library/Homebrew/cask/spec/support/sha256_helper.rb b/Library/Homebrew/cask/spec/support/sha256_helper.rb
deleted file mode 100644
index 14f2a2519..000000000
--- a/Library/Homebrew/cask/spec/support/sha256_helper.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require"digest"
-
-module Sha256Helper
- def random_sha256
- seed = "--#{rand(10_000)}--#{Time.now}--"
- Digest::SHA2.hexdigest(seed)
- end
-end
diff --git a/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb b/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb
new file mode 100644
index 000000000..400ff40f6
--- /dev/null
+++ b/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb
@@ -0,0 +1,23 @@
+require "hbc/dsl/base"
+
+shared_examples Hbc::DSL::Base do
+ it "supports the token method" do
+ expect(dsl.token).to eq(cask.token)
+ end
+
+ it "supports the version method" do
+ expect(dsl.version).to eq(cask.version)
+ end
+
+ it "supports the caskroom_path method" do
+ expect(dsl.caskroom_path).to eq(cask.caskroom_path)
+ end
+
+ it "supports the staged_path method" do
+ expect(dsl.staged_path).to eq(cask.staged_path)
+ end
+
+ it "supports the appdir method" do
+ expect(dsl.appdir).to eq(cask.appdir)
+ end
+end
diff --git a/Library/Homebrew/cask/spec/support/shared_examples/staged.rb b/Library/Homebrew/cask/spec/support/shared_examples/staged.rb
new file mode 100644
index 000000000..f791696ac
--- /dev/null
+++ b/Library/Homebrew/cask/spec/support/shared_examples/staged.rb
@@ -0,0 +1,143 @@
+require "spec_helper"
+
+require "hbc/staged"
+
+shared_examples Hbc::Staged do
+ let(:fake_pathname_exists) {
+ fake_pathname = Pathname.new("/path/to/file/that/exists")
+ allow(fake_pathname).to receive(:exist?).and_return(true)
+ allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname)
+ fake_pathname
+ }
+
+ let(:fake_pathname_does_not_exist) {
+ fake_pathname = Pathname.new("/path/to/file/that/does/not/exist")
+ allow(fake_pathname).to receive(:exist?).and_return(false)
+ allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname)
+ fake_pathname
+ }
+
+ it "can run system commands with list-form arguments" do
+ Hbc::FakeSystemCommand.expects_command(
+ ["echo", "homebrew-cask", "rocks!"]
+ )
+
+ shutup do
+ staged.system_command("echo", args: ["homebrew-cask", "rocks!"])
+ end
+ end
+
+ it "can get the Info.plist file for the primary app" do
+ expect(staged.info_plist_file.to_s).to include Hbc.appdir.join("TestCask.app/Contents/Info.plist")
+ end
+
+ it "can execute commands on the Info.plist file" do
+ allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask")
+
+ Hbc::FakeSystemCommand.expects_command(
+ ["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file]
+ )
+
+ shutup do
+ staged.plist_exec("Print CFBundleIdentifier")
+ end
+ end
+
+ it "can set a key in the Info.plist file" do
+ allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask")
+
+ Hbc::FakeSystemCommand.expects_command(
+ ["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file]
+ )
+
+ shutup do
+ staged.plist_set(":JVMOptions:JVMVersion", "1.6+")
+ end
+ end
+
+ it "can set the permissions of a file" do
+ fake_pathname = fake_pathname_exists
+ allow(staged).to receive(:Pathname).and_return(fake_pathname)
+
+ Hbc::FakeSystemCommand.expects_command(
+ ["/bin/chmod", "-R", "--", "777", fake_pathname]
+ )
+
+ shutup do
+ staged.set_permissions(fake_pathname.to_s, "777")
+ end
+ end
+
+ it "can set the permissions of multiple files" do
+ fake_pathname = fake_pathname_exists
+ allow(staged).to receive(:Pathname).and_return(fake_pathname)
+
+ Hbc::FakeSystemCommand.expects_command(
+ ["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname]
+ )
+
+ shutup do
+ staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777")
+ end
+ end
+
+ it "cannot set the permissions of a file that does not exist" do
+ fake_pathname = fake_pathname_does_not_exist
+ allow(staged).to receive(:Pathname).and_return(fake_pathname)
+ staged.set_permissions(fake_pathname.to_s, "777")
+ end
+
+ it "can set the ownership of a file" do
+ fake_pathname = fake_pathname_exists
+
+ allow(staged).to receive(:current_user).and_return("fake_user")
+ allow(staged).to receive(:Pathname).and_return(fake_pathname)
+
+ Hbc::FakeSystemCommand.expects_command(
+ ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname]
+ )
+
+ shutup do
+ staged.set_ownership(fake_pathname.to_s)
+ end
+ end
+
+ it "can set the ownership of multiple files" do
+ fake_pathname = fake_pathname_exists
+
+ allow(staged).to receive(:current_user).and_return("fake_user")
+ allow(staged).to receive(:Pathname).and_return(fake_pathname)
+
+ Hbc::FakeSystemCommand.expects_command(
+ ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname]
+ )
+
+ shutup do
+ staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s])
+ end
+ end
+
+ it "can set the ownership of a file with a different user and group" do
+ fake_pathname = fake_pathname_exists
+
+ allow(staged).to receive(:Pathname).and_return(fake_pathname)
+
+ Hbc::FakeSystemCommand.expects_command(
+ ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname]
+ )
+
+ shutup do
+ staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group")
+ end
+ end
+
+ it "cannot set the ownership of a file that does not exist" do
+ allow(staged).to receive(:current_user).and_return("fake_user")
+ fake_pathname = fake_pathname_does_not_exist
+ allow(staged).to receive(:Pathname).and_return(fake_pathname)
+
+ shutup do
+ staged.set_ownership(fake_pathname.to_s)
+ end
+ end
+end
diff --git a/Library/Homebrew/cask/spec/upload_coverage.rb b/Library/Homebrew/cask/spec/upload_coverage.rb
new file mode 100755
index 000000000..06d38157d
--- /dev/null
+++ b/Library/Homebrew/cask/spec/upload_coverage.rb
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+require "simplecov"
+require "codecov"
+
+formatter = SimpleCov::Formatter::Codecov.new
+formatter.format SimpleCov::ResultMerger.merged_result
diff --git a/Library/Homebrew/cask/test/README.md b/Library/Homebrew/cask/test/README.md
deleted file mode 100644
index 4b73af8c4..000000000
--- a/Library/Homebrew/cask/test/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Naming
-
-Only files matching `*_test.rb` will be executed as tests.
diff --git a/Library/Homebrew/cask/test/cask/accessibility_test.rb b/Library/Homebrew/cask/test/cask/accessibility_test.rb
deleted file mode 100644
index 7c6484dd4..000000000
--- a/Library/Homebrew/cask/test/cask/accessibility_test.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require "test_helper"
-
-# TODO: this test should be named after the corresponding class, once
-# that class is abstracted from installer.rb.
-describe "Accessibility Access" do
- let(:cask) { Hbc.load("with-accessibility-access") }
- let(:with_fake_command) { { command: Hbc::FakeSystemCommand } }
- let(:installer) { Hbc::Installer.new(cask, with_fake_command) }
-
- describe "install" do
- it "can enable accessibility access" do
- MacOS.stub :version, MacOS::Version.new("10.9") do
- installer.stub :bundle_identifier, "com.example.BasicCask" do
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/usr/bin/sqlite3", Hbc.tcc_db, "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);"]
- )
- shutup do
- installer.enable_accessibility_access
- end
- end
- end
- end
-
- it "can enable accessibility access in macOS releases prior to Mavericks" do
- MacOS.stub :version, MacOS::Version.new("10.8") do
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/usr/bin/touch", Hbc.pre_mavericks_accessibility_dotfile]
- )
- shutup do
- installer.enable_accessibility_access
- end
- end
- end
-
- it "warns about enabling accessibility access on new macOS releases" do
- MacOS.stub :version, MacOS::Version.new("10.12") do
- installer.stub :bundle_identifier, "com.example.BasicCask" do
- capture_io { installer.enable_accessibility_access }[1]
- .must_match("Warning: Accessibility access cannot be enabled automatically on this version of macOS.")
- end
- end
- end
- end
-
- describe "uninstall" do
- it "can disable accessibility access" do
- MacOS.stub :version, MacOS::Version.new("10.9") do
- installer.stub :bundle_identifier, "com.example.BasicCask" do
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/usr/bin/sqlite3", Hbc.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"]
- )
- shutup do
- installer.disable_accessibility_access
- end
- end
- end
- end
-
- it "warns about disabling accessibility access on old macOS releases" do
- MacOS.stub :version, MacOS::Version.new("10.8") do
- installer.stub :bundle_identifier, "com.example.BasicCask" do
- capture_io { installer.disable_accessibility_access }[1]
- .must_match("Warning: Accessibility access cannot be disabled automatically on this version of macOS.")
- end
- end
- end
-
- it "warns about disabling accessibility access on new macOS releases" do
- MacOS.stub :version, MacOS::Version.new("10.12") do
- installer.stub :bundle_identifier, "com.example.BasicCask" do
- capture_io { installer.disable_accessibility_access }[1]
- .must_match("Warning: Accessibility access cannot be disabled automatically on this version of macOS.")
- end
- end
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb b/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb
deleted file mode 100644
index 42740cd44..000000000
--- a/Library/Homebrew/cask/test/cask/artifact/generic_artifact_test.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require "test_helper"
-
-describe Hbc::Artifact::Artifact do
- let(:cask) { Hbc.load("with-generic-artifact") }
-
- let(:install_phase) {
- -> { Hbc::Artifact::Artifact.new(cask).install_phase }
- }
-
- let(:source_path) { cask.staged_path.join("Caffeine.app") }
- let(:target_path) { Hbc.appdir.join("Caffeine.app") }
-
- before do
- TestHelper.install_without_artifacts(cask)
- end
-
- describe "with no target" do
- let(:cask) { Hbc.load("with-generic-artifact-no-target") }
-
- it "fails to install with no target" do
- install_phase.must_raise Hbc::CaskInvalidError
- end
- end
-
- it "moves the artifact to the proper directory" do
- shutup do
- install_phase.call
- end
-
- target_path.must_be :directory?
- source_path.wont_be :exist?
- end
-
- it "avoids clobbering an existing artifact" do
- target_path.mkpath
-
- assert_raises Hbc::CaskError do
- shutup do
- install_phase.call
- end
- end
-
- source_path.must_be :directory?
- target_path.must_be :directory?
- File.identical?(source_path, target_path).must_equal false
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb b/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb
deleted file mode 100644
index b771ba345..000000000
--- a/Library/Homebrew/cask/test/cask/artifact/nested_container_test.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require "test_helper"
-
-describe Hbc::Artifact::NestedContainer do
- describe "install" do
- it "extracts the specified paths as containers" do
- cask = Hbc.load("nested-app").tap do |c|
- TestHelper.install_without_artifacts(c)
- end
-
- shutup do
- Hbc::Artifact::NestedContainer.new(cask).install_phase
- end
-
- cask.staged_path.join("MyNestedApp.app").must_be :directory?
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb b/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb
deleted file mode 100644
index 3ed427763..000000000
--- a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-require "test_helper"
-
-describe Hbc::Artifact::Pkg do
- before do
- @cask = Hbc.load("with-installable")
- shutup do
- TestHelper.install_without_artifacts(@cask)
- end
- end
-
- describe "install_phase" do
- it "runs the system installer on the specified pkgs" do
- pkg = Hbc::Artifact::Pkg.new(@cask,
- command: Hbc::FakeSystemCommand)
-
- Hbc::FakeSystemCommand.expects_command(["/usr/bin/sudo", "-E", "--", "/usr/sbin/installer", "-pkg", @cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/"])
-
- shutup do
- pkg.install_phase
- end
- end
- end
-
- describe "uninstall_phase" do
- it "does nothing, because the uninstall_phase method is a no-op" do
- pkg = Hbc::Artifact::Pkg.new(@cask,
- command: Hbc::FakeSystemCommand)
- shutup do
- pkg.uninstall_phase
- end
- end
- end
-
- describe "choices" do
- before do
- @cask = Hbc.load("with-choices")
- shutup do
- TestHelper.install_without_artifacts(@cask)
- end
- end
-
- it "passes the choice changes xml to the system installer" do
- pkg = Hbc::Artifact::Pkg.new(@cask, command: Hbc::FakeSystemCommand)
-
- file = mock
- file.expects(:write).with <<-EOS.undent
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
- <plist version="1.0">
- <array>
- \t<dict>
- \t\t<key>attributeSetting</key>
- \t\t<integer>1</integer>
- \t\t<key>choiceAttribute</key>
- \t\t<string>selected</string>
- \t\t<key>choiceIdentifier</key>
- \t\t<string>choice1</string>
- \t</dict>
- </array>
- </plist>
- EOS
- file.stubs path: Pathname.new("/tmp/choices.xml")
- file.expects(:close)
- file.expects(:unlink)
- Tempfile.expects(:open).yields file
-
- Hbc::FakeSystemCommand.expects_command(["/usr/bin/sudo", "-E", "--", "/usr/sbin/installer", "-pkg", @cask.staged_path.join("MyFancyPkg", "Fancy.pkg"), "-target", "/", "-applyChoiceChangesXML", @cask.staged_path.join("/tmp/choices.xml")])
-
- shutup do
- pkg.install_phase
- end
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb
deleted file mode 100644
index b2949950e..000000000
--- a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-require "test_helper"
-
-describe Hbc::Artifact::Suite do
- let(:cask) { Hbc.load("with-suite") }
-
- let(:install_phase) { -> { Hbc::Artifact::Suite.new(cask).install_phase } }
-
- let(:target_path) { Hbc.appdir.join("Caffeine") }
- let(:source_path) { cask.staged_path.join("Caffeine") }
-
- before do
- TestHelper.install_without_artifacts(cask)
- end
-
- it "moves the suite to the proper directory" do
- shutup do
- install_phase.call
- end
-
- target_path.must_be :directory?
- TestHelper.valid_alias?(target_path).must_equal false
- source_path.wont_be :exist?
- end
-
- it "creates a suite containing the expected app" do
- shutup do
- install_phase.call
- end
-
- target_path.join("Caffeine.app").must_be :exist?
- end
-
- it "avoids clobbering an existing suite by moving over it" do
- target_path.mkpath
-
- assert_raises Hbc::CaskError do
- shutup do
- install_phase.call
- end
- end
-
- source_path.must_be :directory?
- target_path.must_be :directory?
- File.identical?(source_path, target_path).must_equal false
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb b/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb
deleted file mode 100644
index c699d247f..000000000
--- a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-require "test_helper"
-
-describe Hbc::Artifact::App do
- describe "multiple apps" do
- let(:cask) { Hbc.load("with-two-apps-correct") }
-
- let(:install_phase) {
- -> { Hbc::Artifact::App.new(cask).install_phase }
- }
-
- let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") }
- let(:target_path_mini) { Hbc.appdir.join("Caffeine Mini.app") }
-
- let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") }
- let(:target_path_pro) { Hbc.appdir.join("Caffeine Pro.app") }
-
- before do
- TestHelper.install_without_artifacts(cask)
- end
-
- it "installs both apps using the proper target directory" do
- shutup do
- install_phase.call
- end
-
- target_path_mini.must_be :directory?
- source_path_mini.wont_be :exist?
-
- target_path_pro.must_be :directory?
- source_path_pro.wont_be :exist?
- end
-
- describe "when apps are in a subdirectory" do
- let(:cask) { Hbc.load("with-two-apps-subdir") }
-
- it "installs both apps using the proper target directory" do
- shutup do
- install_phase.call
- end
-
- target_path_mini.must_be :directory?
- source_path_mini.wont_be :exist?
-
- target_path_pro.must_be :directory?
- source_path_pro.wont_be :exist?
- end
- end
-
- it "only uses apps when they are specified" do
- FileUtils.cp_r source_path_mini, source_path_mini.sub("Caffeine Mini.app", "Caffeine Deluxe.app")
-
- shutup do
- install_phase.call
- end
-
- target_path_mini.must_be :directory?
- source_path_mini.wont_be :exist?
-
- Hbc.appdir.join("Caffeine Deluxe.app").wont_be :exist?
- cask.staged_path.join("Caffeine Deluxe.app").must_be :exist?
- end
-
- describe "avoids clobbering an existing app" do
- it "when the first app of two already exists" do
- target_path_mini.mkpath
-
- err = assert_raises Hbc::CaskError do
- install_phase.must_output <<-EOS.undent
- ==> Moving App 'Caffeine Pro.app' to '#{target_path_pro}'
- EOS
- end
-
- err.message.must_equal("It seems there is already an App at '#{target_path_mini}'.")
-
- source_path_mini.must_be :directory?
- target_path_mini.must_be :directory?
- File.identical?(source_path_mini, target_path_mini).must_equal false
- end
-
- it "when the second app of two already exists" do
- target_path_pro.mkpath
-
- err = assert_raises Hbc::CaskError do
- install_phase.must_output <<-EOS.undent
- ==> Moving App 'Caffeine Mini.app' to '#{target_path_mini}'
- EOS
- end
-
- err.message.must_equal("It seems there is already an App at '#{target_path_pro}'.")
-
- source_path_pro.must_be :directory?
- target_path_pro.must_be :directory?
- File.identical?(source_path_pro, target_path_pro).must_equal false
- end
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb b/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb
deleted file mode 100644
index a89a94fba..000000000
--- a/Library/Homebrew/cask/test/cask/artifact/two_apps_incorrect_test.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require "test_helper"
-
-describe Hbc::Artifact::App do
- it "must raise" do
- exception_raised = begin
- Hbc.load("two-apps-incorrect")
- false
- rescue
- true
- end
- # TODO: later give the user a nice exception for this case and check for it here
- assert exception_raised
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/cli/audit_test.rb b/Library/Homebrew/cask/test/cask/cli/audit_test.rb
deleted file mode 100644
index 89a7d140a..000000000
--- a/Library/Homebrew/cask/test/cask/cli/audit_test.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require "test_helper"
-
-describe Hbc::CLI::Audit do
- let(:auditor) { mock }
- let(:cask) { mock }
-
- describe "selection of Casks to audit" do
- it "audits all Casks if no tokens are given" do
- Hbc.stub :all, [cask, cask] do
- auditor.expects(:audit).times(2)
-
- run_audit([], auditor)
- end
- end
-
- it "audits specified Casks if tokens are given" do
- cask_token = "nice-app"
- Hbc.expects(:load).with(cask_token).returns(cask)
- auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false)
-
- run_audit([cask_token], auditor)
- end
- end
-
- describe "rules for downloading a Cask" do
- it "does not download the Cask per default" do
- Hbc.stub :load, cask do
- auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false)
-
- run_audit(["casktoken"], auditor)
- end
- end
-
- it "download a Cask if --download flag is set" do
- Hbc.stub :load, cask do
- auditor.expects(:audit).with(cask, audit_download: true, check_token_conflicts: false)
-
- run_audit(["casktoken", "--download"], auditor)
- end
- end
- end
-
- describe "rules for checking token conflicts" do
- it "does not check for token conflicts per default" do
- Hbc.stub :load, cask do
- auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: false)
-
- run_audit(["casktoken"], auditor)
- end
- end
-
- it "checks for token conflicts if --token-conflicts flag is set" do
- Hbc.stub :load, cask do
- auditor.expects(:audit).with(cask, audit_download: false, check_token_conflicts: true)
-
- run_audit(["casktoken", "--token-conflicts"], auditor)
- end
- end
- end
-
- def run_audit(args, auditor)
- Hbc::CLI::Audit.new(args, auditor).run
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb b/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb
deleted file mode 100644
index 02cdeb763..000000000
--- a/Library/Homebrew/cask/test/cask/cli/reinstall_test.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require "test_helper"
-
-describe Hbc::CLI::Reinstall do
- it "allows reinstalling a Cask" do
- shutup do
- Hbc::CLI::Install.run("local-transmission")
- end
- Hbc.load("local-transmission").must_be :installed?
-
- shutup do
- Hbc::CLI::Reinstall.run("local-transmission")
- end
- Hbc.load("local-transmission").must_be :installed?
- end
-
- it "allows reinstalling a non installed Cask" do
- Hbc.load("local-transmission").wont_be :installed?
-
- shutup do
- Hbc::CLI::Reinstall.run("local-transmission")
- end
- Hbc.load("local-transmission").must_be :installed?
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/cli/search_test.rb b/Library/Homebrew/cask/test/cask/cli/search_test.rb
deleted file mode 100644
index 6eb6badb9..000000000
--- a/Library/Homebrew/cask/test/cask/cli/search_test.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-require "test_helper"
-
-describe Hbc::CLI::Search do
- it "lists the available Casks that match the search term" do
- lambda {
- Hbc::CLI::Search.run("photoshop")
- }.must_output <<-EOS.undent
- ==> Partial matches
- adobe-photoshop-cc
- adobe-photoshop-lightroom
- EOS
- end
-
- it "shows that there are no Casks matching a search term that did not result in anything" do
- lambda {
- Hbc::CLI::Search.run("foo-bar-baz")
- }.must_output("No Cask found for \"foo-bar-baz\".\n")
- end
-
- it "lists all available Casks with no search term" do
- out = capture_io { Hbc::CLI::Search.run }[0]
- out.must_match(/google-chrome/)
- out.length.must_be :>, 1000
- end
-
- it "ignores hyphens in search terms" do
- out = capture_io { Hbc::CLI::Search.run("goo-gle-chrome") }[0]
- out.must_match(/google-chrome/)
- out.length.must_be :<, 100
- end
-
- it "ignores hyphens in Cask tokens" do
- out = capture_io { Hbc::CLI::Search.run("googlechrome") }[0]
- out.must_match(/google-chrome/)
- out.length.must_be :<, 100
- end
-
- it "accepts multiple arguments" do
- out = capture_io { Hbc::CLI::Search.run("google chrome") }[0]
- out.must_match(/google-chrome/)
- out.length.must_be :<, 100
- end
-
- it "accepts a regexp argument" do
- lambda {
- Hbc::CLI::Search.run("/^google-c[a-z]rome$/")
- }.must_output "==> Regexp matches\ngoogle-chrome\n"
- end
-
- it "Returns both exact and partial matches" do
- out = capture_io { Hbc::CLI::Search.run("mnemosyne") }[0]
- out.must_match(/^==> Exact match\nmnemosyne\n==> Partial matches\nsubclassed-mnemosyne/)
- end
-
- it "does not search the Tap name" do
- out = capture_io { Hbc::CLI::Search.run("caskroom") }[0]
- out.must_match(/^No Cask found for "caskroom"\.\n/)
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/cli/version_test.rb b/Library/Homebrew/cask/test/cask/cli/version_test.rb
deleted file mode 100644
index 60e6d22ae..000000000
--- a/Library/Homebrew/cask/test/cask/cli/version_test.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require "test_helper"
-
-describe "brew cask --version" do
- it "respects the --version argument" do
- lambda {
- Hbc::CLI::NullCommand.new("--version").run
- }.must_output Hbc.full_version
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/depends_on_test.rb b/Library/Homebrew/cask/test/cask/depends_on_test.rb
deleted file mode 100644
index 4516dad37..000000000
--- a/Library/Homebrew/cask/test/cask/depends_on_test.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-require "test_helper"
-
-# TODO: this test should be named after the corresponding class, once
-# that class is abstracted from installer.rb
-describe "Satisfy Dependencies and Requirements" do
- # TODO: test that depends_on formula invokes Homebrew
- #
- # describe "depends_on formula" do
- # it "" do
- # end
- # end
- #
-
- describe "depends_on cask" do
- it "raises an exception when depends_on cask is cyclic" do
- dep_cask = Hbc.load("with-depends-on-cask-cyclic")
- lambda {
- shutup do
- Hbc::Installer.new(dep_cask).install
- end
- }.must_raise(Hbc::CaskCyclicCaskDependencyError)
- end
-
- it "installs the dependency of a Cask and the Cask itself" do
- csk = Hbc.load("with-depends-on-cask")
- dependency = Hbc.load(csk.depends_on.cask.first)
- shutup do
- Hbc::Installer.new(csk).install
- end
-
- csk.must_be :installed?
- dependency.must_be :installed?
- end
- end
-
- describe "depends_on macos" do
- it "understands depends_on macos: <array>" do
- macos_cask = Hbc.load("with-depends-on-macos-array")
- shutup do
- Hbc::Installer.new(macos_cask).install
- end
- end
-
- it "understands depends_on macos: <comparison>" do
- macos_cask = Hbc.load("with-depends-on-macos-comparison")
- shutup do
- Hbc::Installer.new(macos_cask).install
- end
- end
-
- it "understands depends_on macos: <string>" do
- macos_cask = Hbc.load("with-depends-on-macos-string")
- shutup do
- Hbc::Installer.new(macos_cask).install
- end
- end
-
- it "understands depends_on macos: <symbol>" do
- macos_cask = Hbc.load("with-depends-on-macos-symbol")
- shutup do
- Hbc::Installer.new(macos_cask).install
- end
- end
-
- it "raises an exception when depends_on macos is not satisfied" do
- macos_cask = Hbc.load("with-depends-on-macos-failure")
- lambda {
- shutup do
- Hbc::Installer.new(macos_cask).install
- end
- }.must_raise(Hbc::CaskError)
- end
- end
-
- describe "depends_on arch" do
- it "succeeds when depends_on arch is satisfied" do
- arch_cask = Hbc.load("with-depends-on-arch")
- shutup do
- Hbc::Installer.new(arch_cask).install
- end
- end
- end
-
- describe "depends_on x11" do
- it "succeeds when depends_on x11 is satisfied" do
- x11_cask = Hbc.load("with-depends-on-x11")
- MacOS::X11.stubs(:installed?).returns(true)
- shutup do
- Hbc::Installer.new(x11_cask).install
- end
- end
-
- it "raises an exception when depends_on x11 is not satisfied" do
- x11_cask = Hbc.load("with-depends-on-x11")
- MacOS::X11.stubs(:installed?).returns(false)
- lambda {
- shutup do
- Hbc::Installer.new(x11_cask).install
- end
- }.must_raise(Hbc::CaskX11DependencyError)
- end
-
- it "never raises when depends_on x11: false" do
- x11_cask = Hbc.load("with-depends-on-x11-false")
- MacOS::X11.stubs(:installed?).returns(false)
- lambda do
- shutup do
- Hbc::Installer.new(x11_cask).install
- end
- end # won't raise
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/dsl_test.rb b/Library/Homebrew/cask/test/cask/dsl_test.rb
deleted file mode 100644
index 96d24a1a1..000000000
--- a/Library/Homebrew/cask/test/cask/dsl_test.rb
+++ /dev/null
@@ -1,475 +0,0 @@
-require "test_helper"
-
-describe Hbc::DSL do
- it "lets you set url, homepage, and version" do
- test_cask = Hbc.load("basic-cask")
- test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
- test_cask.homepage.must_equal "http://example.com/"
- test_cask.version.to_s.must_equal "1.2.3"
- end
-
- describe "when a Cask includes an unknown method" do
- attempt_unknown_method = nil
-
- before do
- attempt_unknown_method = lambda do
- Hbc::Cask.new("unexpected-method-cask") do
- future_feature :not_yet_on_your_machine
- end
- end
- end
-
- it "prints a warning that it has encountered an unexpected method" do
- expected = Regexp.compile(<<-EOS.undent.lines.map(&:chomp).join(""))
- (?m)
- Warning:
- .*
- Unexpected method 'future_feature' called on Cask unexpected-method-cask\\.
- .*
- https://github.com/caskroom/homebrew-cask/blob/master/doc/reporting_bugs/pre_bug_report.md
- .*
- https://github.com/caskroom/homebrew-cask#reporting-bugs
- EOS
-
- attempt_unknown_method.must_output nil, expected
- end
-
- it "will simply warn, not throw an exception" do
- begin
- shutup do
- attempt_unknown_method.call
- end
- rescue StandardError => e
- flunk("Wanted unexpected method to simply warn, but got exception #{e}")
- end
- end
- end
-
- describe "header line" do
- it "requires a valid header format" do
- lambda {
- Hbc.load("invalid/invalid-header-format")
- }.must_raise(SyntaxError)
- end
-
- it "requires the header token to match the file name" do
- err = lambda {
- Hbc.load("invalid/invalid-header-token-mismatch")
- }.must_raise(Hbc::CaskTokenDoesNotMatchError)
- err.message.must_include "Bad header line:"
- err.message.must_include "does not match file name"
- end
-
- it "does not require a DSL version in the header" do
- test_cask = Hbc.load("no-dsl-version")
- test_cask.token.must_equal "no-dsl-version"
- test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
- test_cask.homepage.must_equal "http://example.com/"
- test_cask.version.to_s.must_equal "1.2.3"
- end
-
- it "may use deprecated DSL version hash syntax" do
- with_environment "HOMEBREW_DEVELOPER" => nil do
- shutup do
- test_cask = Hbc.load("with-dsl-version")
- test_cask.token.must_equal "with-dsl-version"
- test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
- test_cask.homepage.must_equal "http://example.com/"
- test_cask.version.to_s.must_equal "1.2.3"
- end
- end
- end
- end
-
- describe "name stanza" do
- it "lets you set the full name via a name stanza" do
- cask = Hbc::Cask.new("name-cask") do
- name "Proper Name"
- end
-
- cask.name.must_equal [
- "Proper Name",
- ]
- end
-
- it "Accepts an array value to the name stanza" do
- cask = Hbc::Cask.new("array-name-cask") do
- name ["Proper Name", "Alternate Name"]
- end
-
- cask.name.must_equal [
- "Proper Name",
- "Alternate Name",
- ]
- end
-
- it "Accepts multiple name stanzas" do
- cask = Hbc::Cask.new("multi-name-cask") do
- name "Proper Name"
- name "Alternate Name"
- end
-
- cask.name.must_equal [
- "Proper Name",
- "Alternate Name",
- ]
- end
- end
-
- describe "sha256 stanza" do
- it "lets you set checksum via sha256" do
- cask = Hbc::Cask.new("checksum-cask") do
- sha256 "imasha2"
- end
-
- cask.sha256.must_equal "imasha2"
- end
- end
-
- describe "language stanza" do
- it "allows multilingual casks" do
- cask = lambda do
- Hbc::Cask.new("cask-with-apps") do
- language "zh" do
- sha256 "abc123"
- "zh-CN"
- end
-
- language "en-US", default: true do
- sha256 "xyz789"
- "en-US"
- end
-
- url "https://example.org/#{language}.zip"
- end
- end
-
- MacOS.stub :languages, ["zh"] do
- cask.call.language.must_equal "zh-CN"
- cask.call.sha256.must_equal "abc123"
- cask.call.url.to_s.must_equal "https://example.org/zh-CN.zip"
- end
-
- MacOS.stub :languages, ["zh-XX"] do
- cask.call.language.must_equal "zh-CN"
- cask.call.sha256.must_equal "abc123"
- cask.call.url.to_s.must_equal "https://example.org/zh-CN.zip"
- end
-
- MacOS.stub :languages, ["en"] do
- cask.call.language.must_equal "en-US"
- cask.call.sha256.must_equal "xyz789"
- cask.call.url.to_s.must_equal "https://example.org/en-US.zip"
- end
-
- MacOS.stub :languages, ["xx-XX"] do
- cask.call.language.must_equal "en-US"
- cask.call.sha256.must_equal "xyz789"
- cask.call.url.to_s.must_equal "https://example.org/en-US.zip"
- end
-
- MacOS.stub :languages, ["xx-XX", "zh", "en"] do
- cask.call.language.must_equal "zh-CN"
- cask.call.sha256.must_equal "abc123"
- cask.call.url.to_s.must_equal "https://example.org/zh-CN.zip"
- end
-
- MacOS.stub :languages, ["xx-XX", "en-US", "zh"] do
- cask.call.language.must_equal "en-US"
- cask.call.sha256.must_equal "xyz789"
- cask.call.url.to_s.must_equal "https://example.org/en-US.zip"
- end
- end
- end
-
- describe "app stanza" do
- it "allows you to specify app stanzas" do
- cask = Hbc::Cask.new("cask-with-apps") do
- app "Foo.app"
- app "Bar.app"
- end
-
- Array(cask.artifacts[:app]).must_equal [["Foo.app"], ["Bar.app"]]
- end
-
- it "allow app stanzas to be empty" do
- cask = Hbc::Cask.new("cask-with-no-apps")
- Array(cask.artifacts[:app]).must_equal %w[]
- end
- end
-
- describe "caveats stanza" do
- it "allows caveats to be specified via a method define" do
- cask = Hbc::Cask.new("plain-cask")
-
- cask.caveats.must_be :empty?
-
- cask = Hbc::Cask.new("cask-with-caveats") do
- def caveats; <<-EOS.undent
- When you install this Cask, you probably want to know this.
- EOS
- end
- end
-
- cask.caveats.must_equal "When you install this Cask, you probably want to know this.\n"
- end
- end
-
- describe "pkg stanza" do
- it "allows installable pkgs to be specified" do
- cask = Hbc::Cask.new("cask-with-pkgs") do
- pkg "Foo.pkg"
- pkg "Bar.pkg"
- end
-
- Array(cask.artifacts[:pkg]).must_equal [["Foo.pkg"], ["Bar.pkg"]]
- end
- end
-
- describe "url stanza" do
- it "prevents defining multiple urls" do
- err = lambda {
- Hbc.load("invalid/invalid-two-url")
- }.must_raise(Hbc::CaskInvalidError)
- err.message.must_include "'url' stanza may only appear once"
- end
- end
-
- describe "homepage stanza" do
- it "prevents defining multiple homepages" do
- err = lambda {
- Hbc.load("invalid/invalid-two-homepage")
- }.must_raise(Hbc::CaskInvalidError)
- err.message.must_include "'homepage' stanza may only appear once"
- end
- end
-
- describe "version stanza" do
- it "prevents defining multiple versions" do
- err = lambda {
- Hbc.load("invalid/invalid-two-version")
- }.must_raise(Hbc::CaskInvalidError)
- err.message.must_include "'version' stanza may only appear once"
- end
- end
-
- describe "appcast stanza" do
- it "allows appcasts to be specified" do
- cask = Hbc.load("with-appcast")
- cask.appcast.to_s.must_match(/^http/)
- end
-
- it "prevents defining multiple appcasts" do
- err = lambda {
- Hbc.load("invalid/invalid-appcast-multiple")
- }.must_raise(Hbc::CaskInvalidError)
- err.message.must_include "'appcast' stanza may only appear once"
- end
-
- it "refuses to load invalid appcast URLs" do
- lambda {
- Hbc.load("invalid/invalid-appcast-url")
- }.must_raise(Hbc::CaskInvalidError)
- end
- end
-
- describe "gpg stanza" do
- it "allows gpg stanza to be specified" do
- cask = Hbc.load("with-gpg")
- cask.gpg.to_s.must_match(/\S/)
- end
-
- it "allows gpg stanza to be specified with :key_url" do
- cask = Hbc.load("with-gpg-key-url")
- cask.gpg.to_s.must_match(/\S/)
- end
-
- it "prevents specifying gpg stanza multiple times" do
- err = lambda {
- Hbc.load("invalid/invalid-gpg-multiple-stanzas")
- }.must_raise(Hbc::CaskInvalidError)
- err.message.must_include "'gpg' stanza may only appear once"
- end
-
- it "prevents missing gpg key parameters" do
- err = lambda {
- Hbc.load("invalid/invalid-gpg-missing-key")
- }.must_raise(Hbc::CaskInvalidError)
- err.message.must_include "'gpg' stanza must include exactly one"
- end
-
- it "prevents conflicting gpg key parameters" do
- err = lambda {
- Hbc.load("invalid/invalid-gpg-conflicting-keys")
- }.must_raise(Hbc::CaskInvalidError)
- err.message.must_include "'gpg' stanza must include exactly one"
- end
-
- it "refuses to load invalid gpg signature URLs" do
- lambda {
- Hbc.load("invalid/invalid-gpg-signature-url")
- }.must_raise(Hbc::CaskInvalidError)
- end
-
- it "refuses to load invalid gpg key URLs" do
- lambda {
- Hbc.load("invalid/invalid-gpg-key-url")
- }.must_raise(Hbc::CaskInvalidError)
- end
-
- it "refuses to load invalid gpg key IDs" do
- lambda {
- Hbc.load("invalid/invalid-gpg-key-id")
- }.must_raise(Hbc::CaskInvalidError)
- end
-
- it "refuses to load if gpg parameter is unknown" do
- lambda {
- Hbc.load("invalid/invalid-gpg-parameter")
- }.must_raise(Hbc::CaskInvalidError)
- end
- end
-
- describe "depends_on stanza" do
- it "refuses to load with an invalid depends_on key" do
- lambda {
- Hbc.load("invalid/invalid-depends-on-key")
- }.must_raise(Hbc::CaskInvalidError)
- end
- end
-
- describe "depends_on formula" do
- it "allows depends_on formula to be specified" do
- cask = Hbc.load("with-depends-on-formula")
- cask.depends_on.formula.wont_be_nil
- end
-
- it "allows multiple depends_on formula to be specified" do
- cask = Hbc.load("with-depends-on-formula-multiple")
- cask.depends_on.formula.wont_be_nil
- end
- end
-
- describe "depends_on cask" do
- it "allows depends_on cask to be specified" do
- cask = Hbc.load("with-depends-on-cask")
- cask.depends_on.cask.wont_be_nil
- end
-
- it "allows multiple depends_on cask to be specified" do
- cask = Hbc.load("with-depends-on-cask-multiple")
- cask.depends_on.cask.wont_be_nil
- end
- end
-
- describe "depends_on macos" do
- it "allows depends_on macos to be specified" do
- cask = Hbc.load("with-depends-on-macos-string")
- cask.depends_on.macos.wont_be_nil
- end
- it "refuses to load with an invalid depends_on macos value" do
- lambda {
- Hbc.load("invalid/invalid-depends-on-macos-bad-release")
- }.must_raise(Hbc::CaskInvalidError)
- end
- it "refuses to load with conflicting depends_on macos forms" do
- lambda {
- Hbc.load("invalid/invalid-depends-on-macos-conflicting-forms")
- }.must_raise(Hbc::CaskInvalidError)
- end
- end
-
- describe "depends_on arch" do
- it "allows depends_on arch to be specified" do
- cask = Hbc.load("with-depends-on-arch")
- cask.depends_on.arch.wont_be_nil
- end
- it "refuses to load with an invalid depends_on arch value" do
- lambda {
- Hbc.load("invalid/invalid-depends-on-arch-value")
- }.must_raise(Hbc::CaskInvalidError)
- end
- end
-
- describe "depends_on x11" do
- it "allows depends_on x11 to be specified" do
- cask = Hbc.load("with-depends-on-x11")
- cask.depends_on.x11.wont_be_nil
- end
- it "refuses to load with an invalid depends_on x11 value" do
- lambda {
- Hbc.load("invalid/invalid-depends-on-x11-value")
- }.must_raise(Hbc::CaskInvalidError)
- end
- end
-
- describe "conflicts_with stanza" do
- it "allows conflicts_with stanza to be specified" do
- cask = Hbc.load("with-conflicts-with")
- cask.conflicts_with.formula.wont_be_nil
- end
-
- it "refuses to load invalid conflicts_with key" do
- lambda {
- Hbc.load("invalid/invalid-conflicts-with-key")
- }.must_raise(Hbc::CaskInvalidError)
- end
- end
-
- describe "installer stanza" do
- it "allows installer script to be specified" do
- cask = Hbc.load("with-installer-script")
- cask.artifacts[:installer].first.script[:executable].must_equal "/usr/bin/true"
- cask.artifacts[:installer].first.script[:args].must_equal ["--flag"]
- cask.artifacts[:installer].to_a[1].script[:executable].must_equal "/usr/bin/false"
- cask.artifacts[:installer].to_a[1].script[:args].must_equal ["--flag"]
- end
- it "allows installer manual to be specified" do
- cask = Hbc.load("with-installer-manual")
- cask.artifacts[:installer].first.manual.must_equal "Caffeine.app"
- end
- end
-
- describe "stage_only stanza" do
- it "allows stage_only stanza to be specified" do
- cask = Hbc.load("stage-only")
- cask.artifacts[:stage_only].first.must_equal [true]
- end
-
- it "prevents specifying stage_only with other activatables" do
- err = lambda {
- Hbc.load("invalid/invalid-stage-only-conflict")
- }.must_raise(Hbc::CaskInvalidError)
- err.message.must_include "'stage_only' must be the only activatable artifact"
- end
- end
-
- describe "auto_updates stanza" do
- it "allows auto_updates stanza to be specified" do
- cask = Hbc.load("auto-updates")
- cask.auto_updates.must_equal true
- end
- end
-
- describe "appdir" do
- it "allows interpolation of the appdir value in stanzas" do
- cask = Hbc.load("appdir-interpolation")
- cask.artifacts[:binary].first.must_equal ["#{Hbc.appdir}/some/path"]
- end
-
- it "does not include a trailing slash" do
- original_appdir = Hbc.appdir
- Hbc.appdir = "#{original_appdir}/"
-
- begin
- cask = Hbc::Cask.new("appdir-trailing-slash") do
- binary "#{appdir}/some/path"
- end
-
- cask.artifacts[:binary].first.must_equal ["#{original_appdir}/some/path"]
- ensure
- Hbc.appdir = original_appdir
- end
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb
deleted file mode 100644
index d76411ae6..000000000
--- a/Library/Homebrew/cask/test/cask/installer_test.rb
+++ /dev/null
@@ -1,422 +0,0 @@
-require "test_helper"
-
-describe Hbc::Installer do
- describe "install" do
- let(:empty_depends_on_stub) {
- stub(formula: [], cask: [], macos: nil, arch: nil, x11: nil)
- }
-
- it "downloads and installs a nice fresh Cask" do
- caffeine = Hbc.load("local-caffeine")
-
- shutup do
- Hbc::Installer.new(caffeine).install
- end
-
- dest_path = Hbc.caskroom.join("local-caffeine", caffeine.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("Caffeine.app")
- application.must_be :directory?
- end
-
- it "works with dmg-based Casks" do
- asset = Hbc.load("container-dmg")
-
- shutup do
- Hbc::Installer.new(asset).install
- end
-
- dest_path = Hbc.caskroom.join("container-dmg", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container")
- file.must_be :file?
- end
-
- it "works with tar-gz-based Casks" do
- asset = Hbc.load("container-tar-gz")
-
- shutup do
- Hbc::Installer.new(asset).install
- end
-
- dest_path = Hbc.caskroom.join("container-tar-gz", asset.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("container")
- application.must_be :file?
- end
-
- it "works with cab-based Casks" do
- skip("cabextract not installed") if which("cabextract").nil?
- asset = Hbc.load("container-cab")
-
- asset.stub :depends_on, empty_depends_on_stub do
- shutup do
- Hbc::Installer.new(asset).install
- end
- end
-
- dest_path = Hbc.caskroom.join("container-cab", asset.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("container")
- application.must_be :file?
- end
-
- it "works with Adobe AIR-based Casks" do
- skip("Adobe AIR not installed") unless Hbc::Container::Air.installer_exist?
- asset = Hbc.load("container-air")
-
- shutup do
- Hbc::Installer.new(asset).install
- end
-
- dest_path = Hbc.caskroom.join("container-air", asset.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("container.app")
- application.must_be :directory?
- end
-
- it "works with 7z-based Casks" do
- skip("unar not installed") if which("unar").nil?
- asset = Hbc.load("container-7z")
-
- asset.stub :depends_on, empty_depends_on_stub do
- shutup do
- Hbc::Installer.new(asset).install
- end
- end
-
- dest_path = Hbc.caskroom.join("container-7z", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container")
- file.must_be :file?
- end
-
- it "works with xar-based Casks" do
- asset = Hbc.load("container-xar")
-
- shutup do
- Hbc::Installer.new(asset).install
- end
-
- dest_path = Hbc.caskroom.join("container-xar", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container")
- file.must_be :file?
- end
-
- it "works with Stuffit-based Casks" do
- skip("unar not installed") if which("unar").nil?
- asset = Hbc.load("container-sit")
-
- asset.stub :depends_on, empty_depends_on_stub do
- shutup do
- Hbc::Installer.new(asset).install
- end
- end
-
- dest_path = Hbc.caskroom.join("container-sit", asset.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("container")
- application.must_be :file?
- end
-
- it "works with RAR-based Casks" do
- skip("unar not installed") if which("unar").nil?
- asset = Hbc.load("container-rar")
-
- asset.stub :depends_on, empty_depends_on_stub do
- shutup do
- Hbc::Installer.new(asset).install
- end
- end
-
- dest_path = Hbc.caskroom.join("container-rar", asset.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("container")
- application.must_be :file?
- end
-
- it "works with pure bzip2-based Casks" do
- asset = Hbc.load("container-bzip2")
-
- shutup do
- Hbc::Installer.new(asset).install
- end
-
- dest_path = Hbc.caskroom.join("container-bzip2", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container-bzip2--#{asset.version}")
- file.must_be :file?
- end
-
- it "works with pure gzip-based Casks" do
- asset = Hbc.load("container-gzip")
-
- shutup do
- Hbc::Installer.new(asset).install
- end
-
- dest_path = Hbc.caskroom.join("container-gzip", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container")
- file.must_be :file?
- end
-
- it "works with pure xz-based Casks" do
- skip("unxz not installed") if which("unxz").nil?
- asset = Hbc.load("container-xz")
-
- asset.stub :depends_on, empty_depends_on_stub do
- shutup do
- Hbc::Installer.new(asset).install
- end
- end
-
- dest_path = Hbc.caskroom.join("container-xz", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container-xz--#{asset.version}")
- file.must_be :file?
- end
-
- it "works with lzma-based Casks" do
- skip("unlzma not installed") if which("unlzma").nil?
- asset = Hbc.load("container-lzma")
-
- asset.stub :depends_on, empty_depends_on_stub do
- shutup do
- Hbc::Installer.new(asset).install
- end
- end
-
- dest_path = Hbc.caskroom.join("container-lzma", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container-lzma--#{asset.version}")
- file.must_be :file?
- end
-
- it "blows up on a bad checksum" do
- bad_checksum = Hbc.load("bad-checksum")
- lambda {
- shutup do
- Hbc::Installer.new(bad_checksum).install
- end
- }.must_raise(Hbc::CaskSha256MismatchError)
- end
-
- it "blows up on a missing checksum" do
- missing_checksum = Hbc.load("missing-checksum")
- lambda {
- shutup do
- Hbc::Installer.new(missing_checksum).install
- end
- }.must_raise(Hbc::CaskSha256MissingError)
- end
-
- it "installs fine if sha256 :no_check is used" do
- no_checksum = Hbc.load("no-checksum")
-
- shutup do
- Hbc::Installer.new(no_checksum).install
- end
-
- no_checksum.must_be :installed?
- end
-
- it "fails to install if sha256 :no_check is used with --require-sha" do
- no_checksum = Hbc.load("no-checksum")
- lambda {
- Hbc::Installer.new(no_checksum, require_sha: true).install
- }.must_raise(Hbc::CaskNoShasumError)
- end
-
- it "installs fine if sha256 :no_check is used with --require-sha and --force" do
- no_checksum = Hbc.load("no-checksum")
-
- shutup do
- Hbc::Installer.new(no_checksum, require_sha: true, force: true).install
- end
-
- no_checksum.must_be :installed?
- end
-
- it "prints caveats if they're present" do
- with_caveats = Hbc.load("with-caveats")
- lambda {
- Hbc::Installer.new(with_caveats).install
- }.must_output(/Here are some things you might want to know/)
- with_caveats.must_be :installed?
- end
-
- it "prints installer :manual instructions when present" do
- with_installer_manual = Hbc.load("with-installer-manual")
- lambda {
- Hbc::Installer.new(with_installer_manual).install
- }.must_output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'/)
- with_installer_manual.must_be :installed?
- end
-
- it "does not extract __MACOSX directories from zips" do
- with_macosx_dir = Hbc.load("with-macosx-dir")
-
- shutup do
- Hbc::Installer.new(with_macosx_dir).install
- end
-
- with_macosx_dir.staged_path.join("__MACOSX").wont_be :directory?
- end
-
- it "installer method raises an exception when already-installed Casks which auto-update are attempted" do
- auto_updates = Hbc.load("auto-updates")
- auto_updates.installed?.must_equal false
- installer = Hbc::Installer.new(auto_updates)
-
- shutup do
- installer.install
- end
-
- lambda {
- installer.install
- }.must_raise(Hbc::CaskAlreadyInstalledAutoUpdatesError)
- end
-
- it "allows already-installed Casks which auto-update to be installed if force is provided" do
- auto_updates = Hbc.load("auto-updates")
- auto_updates.installed?.must_equal false
-
- shutup do
- Hbc::Installer.new(auto_updates).install
- end
-
- shutup do
- Hbc::Installer.new(auto_updates, force: true).install
- end # wont_raise
- end
-
- # unlike the CLI, the internal interface throws exception on double-install
- it "installer method raises an exception when already-installed Casks are attempted" do
- transmission = Hbc.load("local-transmission")
- transmission.installed?.must_equal false
- installer = Hbc::Installer.new(transmission)
-
- shutup do
- installer.install
- end
-
- lambda {
- installer.install
- }.must_raise(Hbc::CaskAlreadyInstalledError)
- end
-
- it "allows already-installed Casks to be installed if force is provided" do
- transmission = Hbc.load("local-transmission")
- transmission.installed?.must_equal false
-
- shutup do
- Hbc::Installer.new(transmission).install
- end
-
- shutup do
- Hbc::Installer.new(transmission, force: true).install
- end # wont_raise
- end
-
- it "works naked-pkg-based Casks" do
- naked_pkg = Hbc.load("container-pkg")
-
- shutup do
- Hbc::Installer.new(naked_pkg).install
- end
-
- dest_path = Hbc.caskroom.join("container-pkg", naked_pkg.version)
- pkg = dest_path.join("container.pkg")
- pkg.must_be :file?
- end
-
- it "works properly with an overridden container :type" do
- naked_executable = Hbc.load("naked-executable")
-
- shutup do
- Hbc::Installer.new(naked_executable).install
- end
-
- dest_path = Hbc.caskroom.join("naked-executable", naked_executable.version)
- executable = dest_path.join("naked_executable")
- executable.must_be :file?
- end
-
- it "works fine with a nested container" do
- nested_app = Hbc.load("nested-app")
-
- shutup do
- Hbc::Installer.new(nested_app).install
- end
-
- dest_path = Hbc.appdir.join("MyNestedApp.app")
- dest_path.must_be :directory?
- end
-
- it "generates and finds a timestamped metadata directory for an installed Cask" do
- caffeine = Hbc.load("local-caffeine")
-
- shutup do
- Hbc::Installer.new(caffeine).install
- end
-
- m_path = caffeine.metadata_path(:now, true)
- caffeine.metadata_path(:now, false).must_equal(m_path)
- caffeine.metadata_path(:latest).must_equal(m_path)
- end
-
- it "generates and finds a metadata subdirectory for an installed Cask" do
- caffeine = Hbc.load("local-caffeine")
-
- shutup do
- Hbc::Installer.new(caffeine).install
- end
-
- subdir_name = "Casks"
- m_subdir = caffeine.metadata_subdir(subdir_name, :now, true)
- caffeine.metadata_subdir(subdir_name, :now, false).must_equal(m_subdir)
- caffeine.metadata_subdir(subdir_name, :latest).must_equal(m_subdir)
- end
- end
-
- describe "uninstall" do
- it "fully uninstalls a Cask" do
- caffeine = Hbc.load("local-caffeine")
- installer = Hbc::Installer.new(caffeine)
-
- shutup do
- installer.install
- installer.uninstall
- end
-
- Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app").wont_be :directory?
- Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory?
- Hbc.caskroom.join("local-caffeine").wont_be :directory?
- end
-
- it "uninstalls all versions if force is set" do
- caffeine = Hbc.load("local-caffeine")
- mutated_version = caffeine.version + ".1"
-
- shutup do
- Hbc::Installer.new(caffeine).install
- end
-
- Hbc.caskroom.join("local-caffeine", caffeine.version).must_be :directory?
- Hbc.caskroom.join("local-caffeine", mutated_version).wont_be :directory?
- FileUtils.mv(Hbc.caskroom.join("local-caffeine", caffeine.version), Hbc.caskroom.join("local-caffeine", mutated_version))
- Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory?
- Hbc.caskroom.join("local-caffeine", mutated_version).must_be :directory?
-
- shutup do
- Hbc::Installer.new(caffeine, force: true).uninstall
- end
-
- Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory?
- Hbc.caskroom.join("local-caffeine", mutated_version).wont_be :directory?
- Hbc.caskroom.join("local-caffeine").wont_be :directory?
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/pkg_test.rb b/Library/Homebrew/cask/test/cask/pkg_test.rb
deleted file mode 100644
index 85a42356e..000000000
--- a/Library/Homebrew/cask/test/cask/pkg_test.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-require "test_helper"
-
-describe Hbc::Pkg do
- describe "uninstall" do
- it "removes files and dirs referenced by the pkg" do
- pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand)
-
- some_files = Array.new(3) { Pathname(Tempfile.new("testfile").path) }
- pkg.stubs(:pkgutil_bom_files).returns some_files
-
- some_specials = Array.new(3) { Pathname(Tempfile.new("testfile").path) }
- pkg.stubs(:pkgutil_bom_specials).returns some_specials
-
- some_dirs = Array.new(3) { Pathname(Dir.mktmpdir) }
- pkg.stubs(:pkgutil_bom_dirs).returns some_dirs
-
- pkg.stubs(:forget)
-
- pkg.uninstall
-
- some_files.each do |file|
- file.wont_be :exist?
- end
-
- some_dirs.each do |dir|
- dir.wont_be :exist?
- end
- end
-
- it "forgets the pkg" do
- pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::FakeSystemCommand)
-
- Hbc::FakeSystemCommand.stubs_command(
- ["/usr/sbin/pkgutil", "--only-files", "--files", "my.fake.pkg"]
- )
- Hbc::FakeSystemCommand.stubs_command(
- ["/usr/sbin/pkgutil", "--only-dirs", "--files", "my.fake.pkg"]
- )
- Hbc::FakeSystemCommand.stubs_command(
- ["/usr/sbin/pkgutil", "--files", "my.fake.pkg"]
- )
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/usr/sbin/pkgutil", "--forget", "my.fake.pkg"]
- )
-
- pkg.uninstall
- end
-
- it "cleans broken symlinks, but leaves AOK symlinks" do
- pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand)
-
- fake_dir = Pathname(Dir.mktmpdir)
- fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) }
-
- intact_symlink = fake_dir.join("intact_symlink").tap { |path| path.make_symlink(fake_file) }
- broken_symlink = fake_dir.join("broken_symlink").tap { |path| path.make_symlink("im_nota_file") }
-
- pkg.stubs(:pkgutil_bom_specials).returns([])
- pkg.stubs(:pkgutil_bom_files).returns([])
- pkg.stubs(:pkgutil_bom_dirs).returns([fake_dir])
- pkg.stubs(:forget)
-
- pkg.uninstall
-
- intact_symlink.must_be :exist?
- broken_symlink.wont_be :exist?
- fake_dir.must_be :exist?
- end
-
- it "snags permissions on ornery dirs, but returns them afterwords" do
- pkg = Hbc::Pkg.new("my.fake.pkg", Hbc::NeverSudoSystemCommand)
-
- fake_dir = Pathname(Dir.mktmpdir)
-
- fake_file = fake_dir.join("ima_installed_file").tap { |path| FileUtils.touch(path) }
-
- fake_dir.chmod(0000)
-
- pkg.stubs(:pkgutil_bom_specials).returns([])
- pkg.stubs(:pkgutil_bom_files).returns([fake_file])
- pkg.stubs(:pkgutil_bom_dirs).returns([fake_dir])
- pkg.stubs(:forget)
-
- shutup do
- pkg.uninstall
- end
-
- fake_dir.must_be :directory?
- fake_file.wont_be :file?
- (fake_dir.stat.mode % 01000).to_s(8).must_equal "0"
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/url_checker_test.rb b/Library/Homebrew/cask/test/cask/url_checker_test.rb
deleted file mode 100644
index 199182bf2..000000000
--- a/Library/Homebrew/cask/test/cask/url_checker_test.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require "test_helper"
-
-describe Hbc::UrlChecker do
- describe "request processing" do
- let(:cask) { Hbc.load("basic-cask") }
- let(:checker) { Hbc::UrlChecker.new(cask) }
- let(:with_stubbed_fetcher) {
- lambda { |&block|
- Hbc::Fetcher.stub(:head, response) do
- checker.run
- instance_eval(&block)
- end
- }
- }
-
- describe "with an empty response" do
- let(:response) { "" }
-
- it "adds an error" do
- with_stubbed_fetcher.call do
- expect(checker.errors).must_include("timeout while requesting #{cask.url}")
- end
- end
- end
-
- describe "with a valid http response" do
- let(:response) {
- <<-EOS.undent
- HTTP/1.1 200 OK
- Content-Type: application/x-apple-diskimage
- ETag: "b4208f3e84967be4b078ecaa03fba941"
- Content-Length: 23726161
- Last-Modified: Sun, 12 Aug 2012 21:17:21 GMT
- EOS
- }
-
- it "properly populates the response code and headers" do
- with_stubbed_fetcher.call do
- expect(checker.errors).must_be_empty
- expect(checker.response_status).must_equal("HTTP/1.1 200 OK")
- expect(checker.headers).must_equal(
- "Content-Type" => "application/x-apple-diskimage",
- "ETag" => '"b4208f3e84967be4b078ecaa03fba941"',
- "Content-Length" => "23726161",
- "Last-Modified" => "Sun, 12 Aug 2012 21:17:21 GMT"
- )
- end
- end
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/cask_test.rb b/Library/Homebrew/cask/test/cask_test.rb
deleted file mode 100644
index 64fc21965..000000000
--- a/Library/Homebrew/cask/test/cask_test.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-require "test_helper"
-
-describe "Cask" do
- hbc_relative_tap_path = "../../Taps/caskroom/homebrew-cask"
- describe "load" do
- it "returns an instance of the Cask for the given token" do
- c = Hbc.load("adium")
- c.must_be_kind_of(Hbc::Cask)
- c.token.must_equal("adium")
- end
-
- it "returns an instance of the Cask from a specific file location" do
- location = File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb")
- c = Hbc.load(location)
- c.must_be_kind_of(Hbc::Cask)
- c.token.must_equal("dia")
- end
-
- it "returns an instance of the Cask from a url" do
- url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/dia.rb")
- c = shutup do
- Hbc.load(url)
- end
- c.must_be_kind_of(Hbc::Cask)
- c.token.must_equal("dia")
- end
-
- it "raises an error when failing to download a Cask from a url" do
- lambda {
- url = "file://" + File.expand_path(hbc_relative_tap_path + "/Casks/notacask.rb")
- shutup do
- Hbc.load(url)
- end
- }.must_raise(Hbc::CaskUnavailableError)
- end
-
- it "returns an instance of the Cask from a relative file location" do
- c = Hbc.load(hbc_relative_tap_path + "/Casks/bbedit.rb")
- c.must_be_kind_of(Hbc::Cask)
- c.token.must_equal("bbedit")
- end
-
- it "uses exact match when loading by token" do
- Hbc.load("test-opera").token.must_equal("test-opera")
- Hbc.load("test-opera-mail").token.must_equal("test-opera-mail")
- end
-
- it "raises an error when attempting to load a Cask that doesn't exist" do
- lambda {
- Hbc.load("notacask")
- }.must_raise(Hbc::CaskUnavailableError)
- end
- end
-
- describe "all_tokens" do
- it "returns a token for every Cask" do
- all_cask_tokens = Hbc.all_tokens
- all_cask_tokens.count.must_be :>, 20
- all_cask_tokens.each { |token| token.must_be_kind_of String }
- end
- end
-
- describe "metadata" do
- it "proposes a versioned metadata directory name for each instance" do
- cask_token = "adium"
- c = Hbc.load(cask_token)
- metadata_path = Hbc.caskroom.join(cask_token, ".metadata", c.version)
- c.metadata_versioned_container_path.to_s.must_equal(metadata_path.to_s)
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/plist/parser_test.rb b/Library/Homebrew/cask/test/plist/parser_test.rb
deleted file mode 100644
index 7f844e377..000000000
--- a/Library/Homebrew/cask/test/plist/parser_test.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-require "test_helper"
-
-describe Plist do
- it "parses some hdiutil output okay" do
- hdiutil_output = <<-EOS.undent
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
- <plist version="1.0">
- <dict>
- <key>system-entities</key>
- <array>
- <dict>
- <key>content-hint</key>
- <string>Apple_partition_map</string>
- <key>dev-entry</key>
- <string>/dev/disk3s1</string>
- <key>potentially-mountable</key>
- <false/>
- <key>unmapped-content-hint</key>
- <string>Apple_partition_map</string>
- </dict>
- <dict>
- <key>content-hint</key>
- <string>Apple_partition_scheme</string>
- <key>dev-entry</key>
- <string>/dev/disk3</string>
- <key>potentially-mountable</key>
- <false/>
- <key>unmapped-content-hint</key>
- <string>Apple_partition_scheme</string>
- </dict>
- <dict>
- <key>content-hint</key>
- <string>Apple_HFS</string>
- <key>dev-entry</key>
- <string>/dev/disk3s2</string>
- <key>mount-point</key>
- <string>/private/tmp/dmg.BhfS2g</string>
- <key>potentially-mountable</key>
- <true/>
- <key>unmapped-content-hint</key>
- <string>Apple_HFS</string>
- <key>volume-kind</key>
- <string>hfs</string>
- </dict>
- </array>
- </dict>
- </plist>
- EOS
-
- parsed = Plist.parse_xml(hdiutil_output)
-
- parsed.keys.must_equal ["system-entities"]
- parsed["system-entities"].length.must_equal 3
- parsed["system-entities"].map { |e| e["dev-entry"] }.must_equal %w[
- /dev/disk3s1
- /dev/disk3
- /dev/disk3s2
- ]
- end
-
- it "does not choke on empty input" do
- Plist.parse_xml("").must_equal {}
- end
-end
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb
deleted file mode 100644
index 2b8ad5619..000000000
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-token-mismatch.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-test_cask 'invalid-header-token-mismatch-this-text-does-not-belong' do
- version '1.2.3'
- sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
-
- url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
- homepage 'http://example.com/local-caffeine'
-
- app 'Caffeine.app'
-end
diff --git a/Library/Homebrew/cask/test/support/cleanup.rb b/Library/Homebrew/cask/test/support/cleanup.rb
deleted file mode 100644
index c31a74be2..000000000
--- a/Library/Homebrew/cask/test/support/cleanup.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-module MiniTest
- class Spec
- def after_teardown
- super
- Hbc.installed.each do |cask|
- Hbc::Installer.new(cask).purge_versioned_files
- end
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/support/fake_dirs.rb b/Library/Homebrew/cask/test/support/fake_dirs.rb
deleted file mode 100644
index ea7acc685..000000000
--- a/Library/Homebrew/cask/test/support/fake_dirs.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# wire in a set of fake link dirs per-test
-module FakeDirHooks
- DIRS = [:appdir, :qlplugindir, :binarydir].freeze
-
- def before_setup
- super
-
- @canned_dirs = {}
-
- DIRS.each do |dir_name|
- dir = HOMEBREW_PREFIX.join("#{dir_name}-#{Time.now.to_i}-#{rand(1024)}")
- dir.mkpath
- Hbc.send("#{dir_name}=", dir)
- @canned_dirs[:dir_name] = dir
- end
- end
-
- def after_teardown
- super
-
- @canned_dirs.each_value do |dir|
- dir.rmtree if dir.exist?
- end
- end
-end
-
-module MiniTest
- class Spec
- include FakeDirHooks
- end
-end
diff --git a/Library/Homebrew/cask/test/support/shared_examples.rb b/Library/Homebrew/cask/test/support/shared_examples.rb
deleted file mode 100644
index 594ca81c1..000000000
--- a/Library/Homebrew/cask/test/support/shared_examples.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# Adapted from https://gist.github.com/jodosha/1560208
-MiniTest::Spec.class_eval do
- def self.shared_examples
- @shared_examples ||= {}
- end
-end
-
-module MiniTest
- class Spec
- module SharedExamples
- def shared_examples_for(desc, &block)
- MiniTest::Spec.shared_examples[desc] = block
- end
-
- def it_behaves_like(desc, *args, &block)
- instance_exec(*args, &MiniTest::Spec.shared_examples[desc])
- instance_eval(&block) if block_given?
- end
- end
- end
-end
-
-Object.class_eval do
- include(MiniTest::Spec::SharedExamples)
-end
diff --git a/Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb b/Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb
deleted file mode 100644
index 28115bb4b..000000000
--- a/Library/Homebrew/cask/test/support/shared_examples/dsl_base.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require "test_helper"
-
-shared_examples_for Hbc::DSL::Base do
- it "supports the token method" do
- dsl.token.must_equal cask.token
- end
-
- it "supports the version method" do
- dsl.version.must_equal cask.version
- end
-
- it "supports the caskroom_path method" do
- dsl.caskroom_path.must_equal cask.caskroom_path
- end
-
- it "supports the staged_path method" do
- dsl.staged_path.must_equal cask.staged_path
- end
-
- it "supports the appdir method" do
- dsl.appdir.must_equal cask.appdir
- end
-end
diff --git a/Library/Homebrew/cask/test/support/shared_examples/staged.rb b/Library/Homebrew/cask/test/support/shared_examples/staged.rb
deleted file mode 100644
index ef4ff0341..000000000
--- a/Library/Homebrew/cask/test/support/shared_examples/staged.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-require "test_helper"
-
-shared_examples_for Hbc::Staged do
- let(:fake_pathname_exists) {
- fake_pathname = Pathname("/path/to/file/that/exists")
- fake_pathname.stubs(exist?: true, expand_path: fake_pathname)
- fake_pathname
- }
-
- let(:fake_pathname_does_not_exist) {
- fake_pathname = Pathname("/path/to/file/that/does/not/exist")
- fake_pathname.stubs(exist?: false, expand_path: fake_pathname)
- fake_pathname
- }
-
- it "can run system commands with list-form arguments" do
- Hbc::FakeSystemCommand.expects_command(
- ["echo", "homebrew-cask", "rocks!"]
- )
- staged.system_command("echo", args: ["homebrew-cask", "rocks!"])
- end
-
- it "can get the Info.plist file for the primary app" do
- staged.info_plist_file.to_s.must_include Hbc.appdir.join("TestCask.app/Contents/Info.plist")
- end
-
- it "can execute commands on the Info.plist file" do
- staged.stubs(bundle_identifier: "com.example.BasicCask")
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file]
- )
- staged.plist_exec("Print CFBundleIdentifier")
- end
-
- it "can set a key in the Info.plist file" do
- staged.stubs(bundle_identifier: "com.example.BasicCask")
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file]
- )
- staged.plist_set(":JVMOptions:JVMVersion", "1.6+")
- end
-
- it "can set the permissions of a file" do
- fake_pathname = fake_pathname_exists
- staged.stubs(Pathname: fake_pathname)
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/bin/chmod", "-R", "--", "777", fake_pathname]
- )
- staged.set_permissions(fake_pathname.to_s, "777")
- end
-
- it "can set the permissions of multiple files" do
- fake_pathname = fake_pathname_exists
- staged.stubs(:Pathname).returns(fake_pathname)
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname]
- )
- staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777")
- end
-
- it "cannot set the permissions of a file that does not exist" do
- fake_pathname = fake_pathname_does_not_exist
- staged.stubs(Pathname: fake_pathname)
- staged.set_permissions(fake_pathname.to_s, "777")
- end
-
- it "can set the ownership of a file" do
- staged.stubs(current_user: "fake_user")
- fake_pathname = fake_pathname_exists
- staged.stubs(Pathname: fake_pathname)
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname]
- )
- staged.set_ownership(fake_pathname.to_s)
- end
-
- it "can set the ownership of multiple files" do
- staged.stubs(current_user: "fake_user")
- fake_pathname = fake_pathname_exists
- staged.stubs(Pathname: fake_pathname)
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname]
- )
- staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s])
- end
-
- it "can set the ownership of a file with a different user and group" do
- fake_pathname = fake_pathname_exists
- staged.stubs(Pathname: fake_pathname)
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname]
- )
- staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group")
- end
-
- it "cannot set the ownership of a file that does not exist" do
- staged.stubs(current_user: "fake_user")
- fake_pathname = fake_pathname_does_not_exist
- staged.stubs(Pathname: fake_pathname)
- staged.set_ownership(fake_pathname.to_s)
- end
-end
diff --git a/Library/Homebrew/cask/test/syntax_test.rb b/Library/Homebrew/cask/test/syntax_test.rb
deleted file mode 100644
index 0ea832bde..000000000
--- a/Library/Homebrew/cask/test/syntax_test.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require "test_helper"
-
-describe "Syntax check" do
- project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../"))
- backend_files = Dir[project_root.join("**", "*.rb")].reject { |f| f.match %r{/vendor/|/Casks/} }
- interpreter = RUBY_PATH
- flags = %w[-c]
- flags.unshift "--disable-all"
- backend_files.each do |file|
- it "#{file} is valid Ruby" do
- args = flags + ["--", file]
- shutup do
- raise SyntaxError, "#{file} failed syntax check" unless system(interpreter, *args)
- end
- end
- end
-end
diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb
deleted file mode 100644
index 275ede304..000000000
--- a/Library/Homebrew/cask/test/test_helper.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-require "bundler"
-require "bundler/setup"
-require "pathname"
-
-require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
-
-# add Homebrew to load path
-$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
-$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew/test/support/lib"))
-
-require "global"
-
-# add Homebrew-Cask to load path
-$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
-
-require "test/support/helper/env"
-require "test/support/helper/shutup"
-include Test::Helper::Env
-include Test::Helper::Shutup
-
-def sudo(*args)
- %w[/usr/bin/sudo -E --] + args.flatten
-end
-
-# must be called after testing_env so at_exit hooks are in proper order
-require "minitest/autorun"
-require "minitest/reporters"
-Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true)
-
-require "parallel_tests/test/runtime_logger"
-
-# Force mocha to patch MiniTest since we have both loaded thanks to homebrew's testing_env
-require "mocha/api"
-require "mocha/integration/mini_test"
-Mocha::Integration::MiniTest.activate
-
-# our baby
-require "hbc"
-
-module Hbc
- class TestCask < Cask; end
-end
-
-# create and override default directories
-Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath)
-Hbc.cache.mkpath
-Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath)
-Hbc.default_tap = Tap.fetch("caskroom", "test").tap do |tap|
- # link test casks
- FileUtils.mkdir_p tap.path.dirname
- FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), tap.path
-end
-
-# pretend that the caskroom/cask Tap is installed
-FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path
-
-class TestHelper
- # helpers for test Casks to reference local files easily
- def self.local_binary_path(name)
- File.expand_path(File.join(File.dirname(__FILE__), "support", "binaries", name))
- end
-
- def self.local_binary_url(name)
- "file://" + local_binary_path(name)
- end
-
- def self.valid_alias?(candidate)
- return false unless candidate.symlink?
- candidate.readlink.exist?
- end
-
- def self.install_without_artifacts(cask)
- Hbc::Installer.new(cask).tap do |i|
- shutup do
- i.download
- i.extract_primary_container
- end
- end
- end
-
- def self.install_with_caskfile(cask)
- Hbc::Installer.new(cask).tap do |i|
- shutup do
- i.save_caskfile
- end
- end
- end
-
- def self.install_without_artifacts_with_caskfile(cask)
- Hbc::Installer.new(cask).tap do |i|
- shutup do
- i.download
- i.extract_primary_container
- i.save_caskfile
- end
- end
- end
-end
-
-# Extend MiniTest API with support for RSpec-style shared examples
-require "support/shared_examples"
-require "support/shared_examples/dsl_base.rb"
-require "support/shared_examples/staged.rb"
-
-require "support/fake_dirs"
-require "support/fake_system_command"
-require "support/cleanup"
-require "support/never_sudo_system_command"
-require "tmpdir"
-require "tempfile"
diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb
index d1dda9d4c..f5543cf49 100644
--- a/Library/Homebrew/caveats.rb
+++ b/Library/Homebrew/caveats.rb
@@ -47,21 +47,24 @@ class Caveats
return unless f.keg_only?
s = "This formula is keg-only, which means it was not symlinked into #{HOMEBREW_PREFIX}."
- s << "\n\n#{f.keg_only_reason}"
- if f.lib.directory? || f.include.directory?
- s <<
- <<-EOS.undent_________________________________________________________72
-
-
- Generally there are no consequences of this for you. If you build your
- own software and it requires this formula, you'll need to add to your
- build variables:
+ s << "\n\n#{f.keg_only_reason}\n"
+ if f.bin.directory? || f.sbin.directory?
+ s << "\nIf you need to have this software first in your PATH run:\n"
+ if f.bin.directory?
+ s << " #{Utils::Shell.prepend_path_in_shell_profile(f.opt_bin.to_s)}\n"
+ end
+ if f.sbin.directory?
+ s << " #{Utils::Shell.prepend_path_in_shell_profile(f.opt_sbin.to_s)}\n"
+ end
+ end
- EOS
+ if f.lib.directory? || f.include.directory?
+ s << "\nFor compilers to find this software you may need to set:\n"
s << " LDFLAGS: -L#{f.opt_lib}\n" if f.lib.directory?
s << " CPPFLAGS: -I#{f.opt_include}\n" if f.include.directory?
-
- if which("pkg-config")
+ if which("pkg-config") &&
+ ((f.lib/"pkgconfig").directory? || (f.share/"pkgconfig").directory?)
+ s << "For pkg-config to find this software you may need to set:\n"
s << " PKG_CONFIG_PATH: #{f.opt_lib}/pkgconfig\n" if (f.lib/"pkgconfig").directory?
s << " PKG_CONFIG_PATH: #{f.opt_share}/pkgconfig\n" if (f.share/"pkgconfig").directory?
end
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index fbfe46e71..5a3aeb7b3 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -184,6 +184,14 @@ module Homebrew
# FormulaInstaller will handle this case.
formulae << f
end
+
+ # Even if we don't install this formula mark it as no longer just
+ # installed as a dependency.
+ next unless f.opt_prefix.directory?
+ keg = Keg.new(f.opt_prefix.resolved_path)
+ tab = Tab.for_keg(keg)
+ tab.installed_on_request = true
+ tab.write
end
perform_preinstall_checks
diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb
index 2eb2840a5..586405909 100644
--- a/Library/Homebrew/cmd/reinstall.rb
+++ b/Library/Homebrew/cmd/reinstall.rb
@@ -25,19 +25,21 @@ module Homebrew
backup keg
end
- options = BuildOptions.new(Options.create(ARGV.flags_only), f.options).used_options
+ build_options = BuildOptions.new(Options.create(ARGV.flags_only), f.options)
+ options = build_options.used_options
options |= f.build.used_options
options &= f.options
fi = FormulaInstaller.new(f)
- fi.options = options
- fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?)
- fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source?
- fi.force_bottle = ARGV.force_bottle?
- fi.interactive = ARGV.interactive?
- fi.git = ARGV.git?
- fi.verbose = ARGV.verbose?
- fi.debug = ARGV.debug?
+ fi.options = options
+ fi.invalid_option_names = build_options.invalid_option_names
+ fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?)
+ fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source?
+ fi.force_bottle = ARGV.force_bottle?
+ fi.interactive = ARGV.interactive?
+ fi.git = ARGV.git?
+ fi.verbose = ARGV.verbose?
+ fi.debug = ARGV.debug?
fi.prelude
oh1 "Reinstalling #{f.full_name} #{options.to_a.join " "}"
diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb
index 9befcf9ac..586c6da6b 100644
--- a/Library/Homebrew/cmd/style.rb
+++ b/Library/Homebrew/cmd/style.rb
@@ -47,7 +47,7 @@ module Homebrew
def check_style_impl(files, output_type, options = {})
fix = options[:fix]
- Homebrew.install_gem_setup_path! "rubocop", "0.45.0"
+ Homebrew.install_gem_setup_path! "rubocop", "0.47.1"
args = %w[
--force-exclusion
diff --git a/Library/Homebrew/cmd/update-reset.sh b/Library/Homebrew/cmd/update-reset.sh
index 32daffc96..3a9e1caa9 100644
--- a/Library/Homebrew/cmd/update-reset.sh
+++ b/Library/Homebrew/cmd/update-reset.sh
@@ -37,7 +37,7 @@ EOS
echo
echo "==> Resetting $DIR..."
- git checkout -B master origin/master
+ git checkout --force -B master origin/master
echo
done
}
diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh
index 678622230..c5e618403 100644
--- a/Library/Homebrew/cmd/update.sh
+++ b/Library/Homebrew/cmd/update.sh
@@ -1,6 +1,6 @@
#: * `update` [`--merge`] [`--force`]:
#: Fetch the newest version of Homebrew and all formulae from GitHub using
-#: `git`(1).
+#: `git`(1) and perform any necessary migrations.
#:
#: If `--merge` is specified then `git merge` is used to include updates
#: (rather than `git rebase`).
diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb
index 5b49a9f65..ce892f85c 100644
--- a/Library/Homebrew/cmd/upgrade.rb
+++ b/Library/Homebrew/cmd/upgrade.rb
@@ -94,14 +94,24 @@ module Homebrew
.select(&:directory?)
.map { |k| Keg.new(k.resolved_path) }
+ if f.opt_prefix.directory?
+ keg = Keg.new(f.opt_prefix.resolved_path)
+ tab = Tab.for_keg(keg)
+ end
+
fi = FormulaInstaller.new(f)
- fi.options = f.build.used_options
- fi.options &= f.options
- fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?)
- fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source?
- fi.verbose = ARGV.verbose?
- fi.quieter = ARGV.quieter?
- fi.debug = ARGV.debug?
+ fi.options = f.build.used_options
+ fi.options &= f.options
+ fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?)
+ fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source?
+ fi.verbose = ARGV.verbose?
+ fi.quieter = ARGV.quieter?
+ fi.debug = ARGV.debug?
+ fi.installed_on_request = !ARGV.named.empty?
+ if tab
+ fi.installed_as_dependency = tab.installed_as_dependency
+ fi.installed_on_request ||= tab.installed_on_request
+ end
fi.prelude
oh1 "Upgrading #{f.full_specified_name} #{fi.options.to_a.join " "}"
diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb
index fb11a31a7..5f6611dfc 100644
--- a/Library/Homebrew/cmd/uses.rb
+++ b/Library/Homebrew/cmd/uses.rb
@@ -57,16 +57,36 @@ module Homebrew
elsif dep.build?
Dependency.prune unless includes.include?("build?")
end
+
+ # If a tap isn't installed, we can't find the dependencies of one
+ # its formulae, and an exception will be thrown if we try.
+ if dep.is_a?(TapDependency) && !dep.tap.installed?
+ Dependency.keep_but_prune_recursive_deps
+ end
+ end
+
+ dep_formulae = deps.map do |dep|
+ begin
+ dep.to_formula
+ rescue
+ end
+ end.compact
+
+ reqs_by_formula = ([f] + dep_formulae).flat_map do |formula|
+ formula.requirements.map { |req| [formula, req] }
end
- reqs = f.recursive_requirements do |dependent, req|
+
+ reqs_by_formula.reject! do |dependent, req|
if req.recommended?
- Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req)
+ ignores.include?("recommended?") || dependent.build.without?(req)
elsif req.optional?
- Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req)
+ !includes.include?("optional?") && !dependent.build.with?(req)
elsif req.build?
- Requirement.prune unless includes.include?("build?")
+ !includes.include?("build?")
end
end
+
+ reqs = reqs_by_formula.map(&:last)
else
deps = f.deps.reject do |dep|
ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) }
diff --git a/Library/Homebrew/compat/hbc/cask_loader.rb b/Library/Homebrew/compat/hbc/cask_loader.rb
index e7f3a4aac..a7c84e3ce 100644
--- a/Library/Homebrew/compat/hbc/cask_loader.rb
+++ b/Library/Homebrew/compat/hbc/cask_loader.rb
@@ -1,7 +1,7 @@
module CaskLoaderCompatibilityLayer
private
- def build_cask(header_token, &block)
+ def cask(header_token, &block)
if header_token.is_a?(Hash) && header_token.key?(:v1)
odeprecated %q("cask :v1 => 'token'"), %q("cask 'token'")
header_token = header_token[:v1]
diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb
index 253ba4bee..4a452440a 100644
--- a/Library/Homebrew/dependency.rb
+++ b/Library/Homebrew/dependency.rb
@@ -175,7 +175,7 @@ class TapDependency < Dependency
attr_reader :tap
def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name.split("/").last])
- @tap = name.rpartition("/").first
+ @tap = Tap.fetch(name.rpartition("/").first)
super(name, tags, env_proc, option_names)
end
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 5ad12d4b6..0e7c11005 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -173,7 +173,7 @@ class FormulaAuditor
@specs = %w[stable devel head].map { |s| formula.send(s) }.compact
end
- def url_status_code(url, range: false, user_agent: :default)
+ def url_status_code(url, range: false)
# The system Curl is too old and unreliable with HTTPS homepages on
# Yosemite and below.
return "200" unless DevelopmentTools.curl_handles_most_https_homepages?
@@ -186,14 +186,13 @@ class FormulaAuditor
extra_args << "--range" << "0-0" if range
extra_args << url
- args = curl_args(
- extra_args: extra_args,
- show_output: true,
- user_agent: user_agent
- )
- retries = 3
status_code = nil
- retries.times do
+ [:browser, :default].each do |user_agent|
+ args = curl_args(
+ extra_args: extra_args,
+ show_output: true,
+ user_agent: user_agent
+ )
status_code = Open3.popen3(*args) { |_, stdout, _, _| stdout.read }
break if status_code.start_with? "20"
end
@@ -463,6 +462,14 @@ class FormulaAuditor
end
def audit_conflicts
+ if formula.conflicts.any? && formula.versioned_formula?
+ problem <<-EOS
+ Versioned formulae should not use `conflicts_with`.
+ Use `keg_only :versioned_formula` instead.
+ EOS
+ return
+ end
+
formula.conflicts.each do |c|
begin
Formulary.factory(c.name)
@@ -485,6 +492,10 @@ class FormulaAuditor
next unless @strict
+ if o.name == "universal" && !Formula["wine"].recursive_dependencies.map(&:name).include?(formula.name)
+ problem "macOS has been 64-bit only since 10.6 so universal options are deprecated."
+ end
+
if o.name !~ /with(out)?-/ && o.name != "c++11" && o.name != "universal"
problem "Options should begin with with/without. Migrate '--#{o.name}' with `deprecated_option`."
end
@@ -497,7 +508,7 @@ class FormulaAuditor
return unless @new_formula
return if formula.deprecated_options.empty?
- return if formula.name.include?("@")
+ return if formula.versioned_formula?
problem "New formulae should not use `deprecated_option`."
end
@@ -577,6 +588,10 @@ class FormulaAuditor
problem "Please use https:// for #{homepage}"
end
+ if homepage =~ %r{^http://([^/]*)\.(sf|sourceforge)\.net(/|$)}
+ problem "#{homepage} should be `https://#{$1}.sourceforge.io/`"
+ end
+
# There's an auto-redirect here, but this mistake is incredibly common too.
# Only applies to the homepage and subdomains for now, not the FTP URLs.
if homepage =~ %r{^http://((?:build|cloud|developer|download|extensions|git|glade|help|library|live|nagios|news|people|projects|rt|static|wiki|www)\.)?gnome\.org}
@@ -601,7 +616,7 @@ class FormulaAuditor
return unless @online
- status_code = url_status_code(homepage, user_agent: :browser)
+ status_code = url_status_code(homepage)
return if status_code.start_with? "20"
problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})"
end
@@ -1336,6 +1351,7 @@ class ResourceAuditor
%r{^http://(?:[^/]*\.)?bintray\.com/},
%r{^http://tools\.ietf\.org/},
%r{^http://launchpad\.net/},
+ %r{^http://github\.com/},
%r{^http://bitbucket\.org/},
%r{^http://anonscm\.debian\.org/},
%r{^http://cpan\.metacpan\.org/},
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index 9618cf412..7367e5c37 100644
--- a/Library/Homebrew/dev-cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -435,6 +435,7 @@ module Homebrew
else
string = s.sub!(
/(
+ (\ {2}\#[^\n]*\n)* # comments
\ {2}( # two spaces at the beginning
(url|head)\ ['"][\S\ ]+['"] # url or head with a string
(
@@ -442,7 +443,7 @@ module Homebrew
(\n^\ {3}[\S\ ]+$)* # options can be in multiple lines
)?|
(homepage|desc|sha1|sha256|version|mirror)\ ['"][\S\ ]+['"]| # specs with a string
- rebuild\ \d+ # rebuild with a number
+ revision\ \d+ # revision with a number
)\n+ # multiple empty lines
)+
/mx, '\0' + output + "\n"
diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb
index 07dd1b322..b4cda0fad 100644
--- a/Library/Homebrew/dev-cmd/create.rb
+++ b/Library/Homebrew/dev-cmd/create.rb
@@ -142,12 +142,10 @@ class FormulaCreator
def generate!
raise "#{path} already exists" if path.exist?
- if version.nil?
+ if version.nil? || version.null?
opoo "Version cannot be determined from URL."
puts "You'll need to add an explicit 'version' to the formula."
- end
-
- if fetch? && version
+ elsif fetch?
r = Resource.new
r.url(url)
r.version(version)
diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb
index 64c970453..581db38ca 100644
--- a/Library/Homebrew/dev-cmd/man.rb
+++ b/Library/Homebrew/dev-cmd/man.rb
@@ -23,10 +23,10 @@ module Homebrew
if ARGV.flag? "--link"
odie "`brew man --link` is now done automatically by `brew update`."
- else
- regenerate_man_pages
end
+ regenerate_man_pages
+
if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/brew.1.html", "manpages"
puts "No changes to manpage output detected."
elsif ARGV.include?("--fail-if-changed")
diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb
index f7006baaa..c2342d39c 100644
--- a/Library/Homebrew/dev-cmd/pull.rb
+++ b/Library/Homebrew/dev-cmd/pull.rb
@@ -248,7 +248,6 @@ module Homebrew
changed_formulae_names.each do |name|
f = Formula[name]
next if f.bottle_unneeded? || f.bottle_disabled?
- ohai "Publishing on Bintray: #{f.name} #{f.pkg_version}"
publish_bottle_file_on_bintray(f, bintray_creds)
published << f.full_name
end
@@ -377,7 +376,7 @@ module Homebrew
subject_strs << "remove stable"
formula_name_str += ":" # just for cosmetics
else
- subject_strs << formula.version.to_s
+ subject_strs << new[:stable]
end
end
if old[:devel] != new[:devel]
@@ -388,7 +387,7 @@ module Homebrew
formula_name_str += ":" # just for cosmetics
end
else
- subject_strs << "#{formula.devel.version} (devel)"
+ subject_strs << "#{new[:devel]} (devel)"
end
end
subject = subject_strs.empty? ? nil : "#{formula_name_str} #{subject_strs.join(", ")}"
@@ -408,7 +407,12 @@ module Homebrew
if info.nil?
raise "Failed publishing bottle: failed reading formula info for #{f.full_name}"
end
+ unless info.bottle_info_any
+ opoo "No bottle defined in formula #{package}"
+ return
+ end
version = info.pkg_version
+ ohai "Publishing on Bintray: #{package} #{version}"
curl "-w", '\n', "--silent", "--fail",
"-u#{creds[:user]}:#{creds[:key]}", "-X", "POST",
"-H", "Content-Type: application/json",
diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb
index b4f3c2d40..244fbe027 100644
--- a/Library/Homebrew/dev-cmd/tests.rb
+++ b/Library/Homebrew/dev-cmd/tests.rb
@@ -1,4 +1,4 @@
-#: * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`<test_script/test_method>] [`--seed` <seed>] [`--trace`] [`--online`] [`--official-cmd-taps`]:
+#: * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`<test_script:test_method>] [`--seed` <seed>] [`--trace`] [`--online`] [`--official-cmd-taps`]:
#: Run Homebrew's unit and integration tests.
require "fileutils"
@@ -7,10 +7,21 @@ require "tap"
module Homebrew
module_function
+ def run_tests(executable, files, args = [])
+ opts = []
+ opts << "--serialize-stdout" if ENV["CI"]
+
+ system "bundle", "exec", executable, *opts, "--", *args, "--", *files
+
+ return if $?.success?
+ Homebrew.failed = true
+ end
+
def tests
HOMEBREW_LIBRARY_PATH.cd do
ENV.delete "HOMEBREW_VERBOSE"
ENV.delete "VERBOSE"
+ ENV.delete("HOMEBREW_CASK_OPTS")
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
ENV["HOMEBREW_DEVELOPER"] = "1"
ENV["TESTOPTS"] = "-v" if ARGV.verbose?
@@ -34,6 +45,7 @@ module Homebrew
%w[AUTHOR COMMITTER].each do |role|
ENV["GIT_#{role}_NAME"] = "brew tests"
ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost"
+ ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000"
end
Homebrew.install_gem_setup_path! "bundler"
@@ -44,27 +56,35 @@ module Homebrew
# Make it easier to reproduce test runs.
ENV["SEED"] = ARGV.next if ARGV.include? "--seed"
- files = Dir.glob("test/**/*_test.rb")
+ files = Dir.glob("test/**/*_{spec,test}.rb")
.reject { |p| !OS.mac? && p.start_with?("test/os/mac/") }
+ .reject { |p| !OS.mac? && p.start_with?("test/cask/") }
.reject { |p| p.start_with?("test/vendor/bundle/") }
- opts = []
- opts << "--serialize-stdout" if ENV["CI"]
-
- args = []
- args << "--trace" if ARGV.include? "--trace"
+ test_args = []
+ test_args << "--trace" if ARGV.include? "--trace"
if ARGV.value("only")
test_name, test_method = ARGV.value("only").split(":", 2)
- files = Dir.glob("test/{#{test_name},#{test_name}/**/*}_test.rb")
- args << "--name=test_#{test_method}" if test_method
+ files = Dir.glob("test/{#{test_name},#{test_name}/**/*}_{spec,test}.rb")
+ test_args << "--name=test_#{test_method}" if test_method
end
- args += ARGV.named.select { |v| v[/^TEST(OPTS)?=/] }
-
- system "bundle", "exec", "parallel_test", *opts, "--", *args, "--", *files
-
- Homebrew.failed = !$?.success?
+ test_files = files.select { |p| p.end_with?("_test.rb") }
+ spec_files = files.select { |p| p.end_with?("_spec.rb") }
+
+ test_args += ARGV.named.select { |v| v[/^TEST(OPTS)?=/] }
+ run_tests "parallel_test", test_files, test_args
+
+ spec_args = [
+ "--color",
+ "-I", HOMEBREW_LIBRARY_PATH/"test",
+ "--require", "spec_helper",
+ "--format", "progress",
+ "--format", "ParallelTests::RSpec::RuntimeLogger",
+ "--out", "tmp/parallel_runtime_rspec.log"
+ ]
+ run_tests "parallel_rspec", spec_files, spec_args
if (fs_leak_log = HOMEBREW_LIBRARY_PATH/"tmp/fs_leak.log").file?
fs_leak_log_content = fs_leak_log.read
diff --git a/Library/Homebrew/emoji.rb b/Library/Homebrew/emoji.rb
index 8c58ca895..43fa781e6 100644
--- a/Library/Homebrew/emoji.rb
+++ b/Library/Homebrew/emoji.rb
@@ -1,17 +1,7 @@
module Emoji
class << self
- def tick
- # necessary for 1.8.7 unicode handling since many installs are on 1.8.7
- @tick ||= ["2714".hex].pack("U*")
- end
-
- def cross
- # necessary for 1.8.7 unicode handling since many installs are on 1.8.7
- @cross ||= ["2718".hex].pack("U*")
- end
-
def install_badge
- ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba"
+ ENV["HOMEBREW_INSTALL_BADGE"] || "🍺"
end
def enabled?
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb
index c5d888d64..77da4489e 100644
--- a/Library/Homebrew/exceptions.rb
+++ b/Library/Homebrew/exceptions.rb
@@ -131,6 +131,19 @@ class FormulaClassUnavailableError < FormulaUnavailableError
end
end
+class FormulaUnreadableError < FormulaUnavailableError
+ attr_reader :formula_error
+
+ def initialize(name, error)
+ super(name)
+ @formula_error = error
+ end
+
+ def to_s
+ "#{name}: " + formula_error.to_s
+ end
+end
+
class TapFormulaAmbiguityError < RuntimeError
attr_reader :name, :paths, :formulae
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index a93c1ee1f..7b468574a 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -17,7 +17,7 @@ module SharedEnvExtension
FC_FLAG_VARS = %w[FCFLAGS FFLAGS].freeze
# @private
SANITIZED_VARS = %w[
- CDPATH GREP_OPTIONS CLICOLOR_FORCE
+ CDPATH CLICOLOR_FORCE
CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_PATH
CC CXX OBJC OBJCXX CPP MAKE LD LDSHARED
CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS
diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb
index 4f20d36a3..287a1408f 100644
--- a/Library/Homebrew/extend/fileutils.rb
+++ b/Library/Homebrew/extend/fileutils.rb
@@ -3,7 +3,7 @@ require "tmpdir"
require "etc"
# Homebrew extends Ruby's `FileUtils` to make our code more readable.
-# @see http://ruby-doc.org/stdlib-1.8.7/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API
+# @see http://ruby-doc.org/stdlib-2.0.0/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API
module FileUtils
# Create a temporary directory then yield. When the block returns,
# recursively delete the temporary directory. Passing opts[:retain]
diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb
index 6d30cd294..3e0c1d04d 100644
--- a/Library/Homebrew/extend/os/mac/diagnostic.rb
+++ b/Library/Homebrew/extend/os/mac/diagnostic.rb
@@ -53,8 +53,8 @@ module Homebrew
return unless MacOS::Xcode.installed?
return unless MacOS::Xcode.outdated?
- # Travis CI images are going to end up outdated so don't complain.
- return if ENV["TRAVIS"]
+ # CI images are going to end up outdated so don't complain.
+ return if ENV["TRAVIS"] || ENV["CIRCLECI"]
message = <<-EOS.undent
Your Xcode (#{MacOS::Xcode.version}) is outdated.
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 91a3e8150..a4ef11276 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -382,6 +382,11 @@ class Formula
PkgVersion.new(version, revision)
end
+ # If this is a `@`-versioned formula.
+ def versioned_formula?
+ name.include?("@")
+ end
+
# A named Resource for the currently active {SoftwareSpec}.
# Additional downloads can be defined as {#resource}s.
# {Resource#stage} will create a temporary directory and yield to a block.
@@ -1519,10 +1524,15 @@ class Formula
# Returns a list of Dependency objects that are required at runtime.
# @private
def runtime_dependencies
- recursive_dependencies do |_dependent, dependency|
+ runtime_dependencies = recursive_dependencies do |_, dependency|
Dependency.prune if dependency.build?
Dependency.prune if !dependency.required? && build.without?(dependency)
end
+ runtime_requirement_deps = recursive_requirements do |_, requirement|
+ Requirement.prune if requirement.build?
+ Requirement.prune if !requirement.required? && build.without?(requirement)
+ end.map(&:to_dependency).compact
+ runtime_dependencies + runtime_requirement_deps
end
# Returns a list of formulae depended on by this formula that aren't
@@ -1619,6 +1629,8 @@ class Formula
"built_as_bottle" => tab.built_as_bottle,
"poured_from_bottle" => tab.poured_from_bottle,
"runtime_dependencies" => tab.runtime_dependencies,
+ "installed_as_dependency" => tab.installed_as_dependency,
+ "installed_on_request" => tab.installed_on_request,
}
end
@@ -1831,7 +1843,16 @@ class Formula
eligible_kegs = if head? && (head_prefix = latest_head_prefix)
installed_kegs - [Keg.new(head_prefix)]
else
- installed_kegs.select { |k| pkg_version > k.version }
+ installed_kegs.select do |keg|
+ tab = Tab.for_keg(keg)
+ if version_scheme > tab.version_scheme
+ true
+ elsif version_scheme == tab.version_scheme
+ pkg_version > keg.version
+ else
+ false
+ end
+ end
end
unless eligible_kegs.empty?
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 115d38c45..e8f0e4bf8 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -32,6 +32,7 @@ class FormulaInstaller
attr_reader :formula
attr_accessor :options, :build_bottle, :invalid_option_names
+ attr_accessor :installed_as_dependency, :installed_on_request
mode_attr_accessor :show_summary_heading, :show_header
mode_attr_accessor :build_from_source, :force_bottle
mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git
@@ -50,6 +51,8 @@ class FormulaInstaller
@verbose = false
@quieter = false
@debug = false
+ @installed_as_dependency = false
+ @installed_on_request = true
@options = Options.new
@invalid_option_names = []
@requirement_messages = []
@@ -250,6 +253,12 @@ class FormulaInstaller
category = "install"
action = ([formula.full_name] + options).join(" ")
Utils::Analytics.report_event(category, action)
+
+ if installed_on_request
+ category = "install_on_request"
+ action = ([formula.full_name] + options).join(" ")
+ Utils::Analytics.report_event(category, action)
+ end
end
@@attempted << formula
@@ -287,6 +296,12 @@ class FormulaInstaller
brew_prefix = formula.prefix/".brew"
brew_prefix.mkdir
Pathname(brew_prefix/"#{formula.name}.rb").atomic_write(s)
+
+ keg = Keg.new(formula.prefix)
+ tab = Tab.for_keg(keg)
+ tab.installed_as_dependency = installed_as_dependency
+ tab.installed_on_request = installed_on_request
+ tab.write
end
build_bottle_postinstall if build_bottle?
@@ -370,8 +385,8 @@ class FormulaInstaller
raise UnsatisfiedRequirements, fatals
end
- def install_requirement_default_formula?(req, dependent, build)
- return false unless req.default_formula?
+ def install_requirement_formula?(req, dependent, build)
+ return false unless req.to_dependency
return true unless req.satisfied?
return false if req.run?
install_bottle_for?(dependent, build) || build_bottle?
@@ -390,7 +405,7 @@ class FormulaInstaller
Requirement.prune
elsif req.build? && install_bottle_for?(dependent, build)
Requirement.prune
- elsif install_requirement_default_formula?(req, dependent, build)
+ elsif install_requirement_formula?(req, dependent, build)
dep = req.to_dependency
deps.unshift(dep)
formulae.unshift(dep.to_formula)
@@ -483,6 +498,8 @@ class FormulaInstaller
fi.build_from_source = ARGV.build_formula_from_source?(df)
fi.verbose = verbose? && !quieter?
fi.debug = debug?
+ fi.installed_as_dependency = true
+ fi.installed_on_request = false
fi.prelude
oh1 "Installing #{formula.full_name} dependency: #{Formatter.identifier(dep.name)}"
fi.install
@@ -809,6 +826,8 @@ class FormulaInstaller
tab.time = Time.now.to_i
tab.head = HOMEBREW_REPOSITORY.git_head
tab.source["path"] = formula.specified_path.to_s
+ tab.installed_as_dependency = installed_as_dependency
+ tab.installed_on_request = installed_on_request
tab.write
end
diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb
index e4f800364..dcb995a6b 100644
--- a/Library/Homebrew/formula_support.rb
+++ b/Library/Homebrew/formula_support.rb
@@ -29,27 +29,32 @@ class KegOnlyReason
def to_s
return @explanation unless @explanation.empty?
case @reason
- when :provided_by_macos, :provided_by_osx then <<-EOS
-macOS already provides this software and installing another version in
-parallel can cause all kinds of trouble.
-EOS
- when :shadowed_by_macos, :shadowed_by_osx then <<-EOS
-macOS provides similar software and installing this software in
-parallel can cause all kinds of trouble.
-EOS
- when :provided_pre_mountain_lion then <<-EOS
-macOS already provides this software in versions before Mountain Lion.
-EOS
- when :provided_pre_mavericks then <<-EOS
-macOS already provides this software in versions before Mavericks.
-EOS
- when :provided_pre_el_capitan then <<-EOS
-macOS already provides this software in versions before El Capitan.
-EOS
- when :provided_until_xcode43
- "Xcode provides this software prior to version 4.3."
- when :provided_until_xcode5
- "Xcode provides this software prior to version 5."
+ when :versioned_formula then <<-EOS.undent
+ This is an alternate version of another formula.
+ EOS
+ when :provided_by_macos, :provided_by_osx then <<-EOS.undent
+ macOS already provides this software and installing another version in
+ parallel can cause all kinds of trouble.
+ EOS
+ when :shadowed_by_macos, :shadowed_by_osx then <<-EOS.undent
+ macOS provides similar software and installing this software in
+ parallel can cause all kinds of trouble.
+ EOS
+ when :provided_pre_mountain_lion then <<-EOS.undent
+ macOS already provides this software in versions before Mountain Lion.
+ EOS
+ when :provided_pre_mavericks then <<-EOS.undent
+ macOS already provides this software in versions before Mavericks.
+ EOS
+ when :provided_pre_el_capitan then <<-EOS.undent
+ macOS already provides this software in versions before El Capitan.
+ EOS
+ when :provided_until_xcode43 then <<-EOS.undent
+ Xcode provides this software prior to version 4.3.
+ EOS
+ when :provided_until_xcode5 then <<-EOS.undent
+ Xcode provides this software prior to version 5.
+ EOS
else
@reason
end.strip
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index 25df57cdc..cf85ba03f 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -22,7 +22,11 @@ class Formulary
mod = Module.new
const_set(namespace, mod)
- mod.module_eval(contents, path)
+ begin
+ mod.module_eval(contents, path)
+ rescue ScriptError => e
+ raise FormulaUnreadableError.new(name, e)
+ end
class_name = class_s(name)
begin
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index 031178421..5fd356909 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -26,7 +26,7 @@ RUBY_BIN = RUBY_PATH.dirname
HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"]
HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".freeze
-HOMEBREW_USER_AGENT_FAKE_SAFARI = "Mozilla/5.0 (#{ENV["HOMEBREW_SYSTEM"]}; #{ENV["HOMEBREW_PROCESSOR"]} #{ENV["HOMEBREW_OS_VERSION"]}) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0.2 Safari/602.3.12".freeze
+HOMEBREW_USER_AGENT_FAKE_SAFARI = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8".freeze
require "tap_constants"
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index 14eb0e3f3..17ff3bcef 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -174,6 +174,12 @@ class Keg
attr_reader :path, :name, :linked_keg_record, :opt_record
protected :path
+ extend Forwardable
+
+ def_delegators :path,
+ :to_s, :hash, :abv, :disk_usage, :file_count, :directory?, :exist?, :/,
+ :join, :rename, :find
+
def initialize(path)
path = path.resolved_path if path.to_s.start_with?("#{HOMEBREW_PREFIX}/opt/")
raise "#{path} is not a valid keg" unless path.parent.parent.realpath == HOMEBREW_CELLAR.realpath
@@ -182,21 +188,14 @@ class Keg
@name = path.parent.basename.to_s
@linked_keg_record = HOMEBREW_LINKED_KEGS/name
@opt_record = HOMEBREW_PREFIX/"opt/#{name}"
- end
-
- def to_s
- path.to_s
+ @require_relocation = false
end
def rack
path.parent
end
- if Pathname.method_defined?(:to_path)
- alias to_path to_s
- else
- alias to_str to_s
- end
+ alias to_path to_s
def inspect
"#<#{self.class.name}:#{path}>"
@@ -207,30 +206,6 @@ class Keg
end
alias eql? ==
- def hash
- path.hash
- end
-
- def abv
- path.abv
- end
-
- def disk_usage
- path.disk_usage
- end
-
- def file_count
- path.file_count
- end
-
- def directory?
- path.directory?
- end
-
- def exist?
- path.exist?
- end
-
def empty_installation?
Pathname.glob("#{path}/**/*") do |file|
next if file.directory?
@@ -243,16 +218,8 @@ class Keg
true
end
- def /(other)
- path / other
- end
-
- def join(*args)
- path.join(*args)
- end
-
- def rename(*args)
- path.rename(*args)
+ def require_relocation?
+ @require_relocation
end
def linked?
@@ -400,10 +367,6 @@ class Keg
end
end
- def find(*args, &block)
- path.find(*args, &block)
- end
-
def oldname_opt_record
@oldname_opt_record ||= if (opt_dir = HOMEBREW_PREFIX/"opt").directory?
opt_dir.subdirs.detect do |dir|
diff --git a/Library/Homebrew/manpages/brew-cask.1.md b/Library/Homebrew/manpages/brew-cask.1.md
index f0a70d4a7..a9da5bca6 100644
--- a/Library/Homebrew/manpages/brew-cask.1.md
+++ b/Library/Homebrew/manpages/brew-cask.1.md
@@ -120,6 +120,18 @@ names, and other aspects of this manual are still subject to change.
**`zap` may remove files which are shared between applications.**
+## INTERNAL COMMANDS
+
+ * `_appcast_checkpoint` [--calculate] [ <token> ... | <URL> ... ]:
+ Given a `token`, returns the current appcast checkpoint, or calculates
+ the appcast checkpoint if the `--calculate` flag is specified.
+ Given a `URL`, calculates the appcast checkpoint for it.
+
+ * `_stanza` <stanza_name> [ --table | --yaml | --inspect | --quiet ] [ <cask_token> ... ]:
+ Given a `stanza_name` and a `cask_token`, returns the current stanza
+ for a given Cask. If no `cask_token` is given, then data for all
+ Casks is returned.
+
## OPTIONS
To make these options persistent, see the ENVIRONMENT section, below.
diff --git a/Library/Homebrew/official_taps.rb b/Library/Homebrew/official_taps.rb
index c1ef431b6..35295c1e8 100644
--- a/Library/Homebrew/official_taps.rb
+++ b/Library/Homebrew/official_taps.rb
@@ -1,17 +1,12 @@
OFFICIAL_TAPS = %w[
apache
- completions
dupes
emacs
fuse
- games
- gui
nginx
php
- python
science
tex
- x11
].freeze
OFFICIAL_CMD_TAPS = {
diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb
index 9468a6c1e..e09a9b3fd 100644
--- a/Library/Homebrew/os/mac.rb
+++ b/Library/Homebrew/os/mac.rb
@@ -27,6 +27,11 @@ module OS
@full_version ||= Version.new((ENV["HOMEBREW_MACOS_VERSION"] || ENV["HOMEBREW_OSX_VERSION"]).chomp)
end
+ def full_version=(version)
+ @full_version = Version.new(version.chomp)
+ @version = nil
+ end
+
def prerelease?
# TODO: bump version when new OS is released
version >= "10.13"
diff --git a/Library/Homebrew/os/mac/keg.rb b/Library/Homebrew/os/mac/keg.rb
index b2a769849..674ea3330 100644
--- a/Library/Homebrew/os/mac/keg.rb
+++ b/Library/Homebrew/os/mac/keg.rb
@@ -24,8 +24,4 @@ class Keg
EOS
raise
end
-
- def require_relocation?
- @require_relocation
- end
end
diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb
index e85f21c63..aa4504a17 100644
--- a/Library/Homebrew/os/mac/xcode.rb
+++ b/Library/Homebrew/os/mac/xcode.rb
@@ -226,7 +226,7 @@ module OS
def minimum_version
case MacOS.version
when "10.12" then "8.0.0"
- else "4.0.0"
+ else "1.0.0"
end
end
diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb
index fe1a3c020..49108ca75 100644
--- a/Library/Homebrew/requirement.rb
+++ b/Library/Homebrew/requirement.rb
@@ -15,6 +15,7 @@ class Requirement
@default_formula = self.class.default_formula
@cask ||= self.class.cask
@download ||= self.class.download
+ @formula = nil
tags.each do |tag|
next unless tag.is_a? Hash
@cask ||= tag[:cask]
@@ -56,7 +57,14 @@ class Requirement
def satisfied?
result = self.class.satisfy.yielder { |p| instance_eval(&p) }
@satisfied_result = result
- result ? true : false
+ return false unless result
+
+ if parent = satisfied_result_parent
+ parent.to_s =~ %r{(#{Regexp.escape(HOMEBREW_CELLAR)}|#{Regexp.escape(HOMEBREW_PREFIX)}/opt)/([\w+-.@]+)}
+ @formula = $2
+ end
+
+ true
end
# Overriding #fatal? is deprecated.
@@ -69,6 +77,11 @@ class Requirement
self.class.default_formula || false
end
+ def satisfied_result_parent
+ return unless @satisfied_result.is_a?(Pathname)
+ @satisfied_result.resolved_path.parent
+ end
+
# Overriding #modify_build_environment is deprecated.
# Pass a block to the env DSL method instead.
# Note: #satisfied? should be called before invoking this method
@@ -81,11 +94,8 @@ class Requirement
# satisfy { which("executable") }
# work, even under superenv where "executable" wouldn't normally be on the
# PATH.
- # This is undocumented magic and it should be removed, but we need to add
- # a way to declare path-based requirements that work with superenv first.
- return unless @satisfied_result.is_a?(Pathname)
- parent = @satisfied_result.parent
-
+ parent = satisfied_result_parent
+ return unless parent
return if ENV["PATH"].split(File::PATH_SEPARATOR).include?(parent.to_s)
ENV.append_path("PATH", parent)
end
@@ -111,13 +121,15 @@ class Requirement
"#<#{self.class.name}: #{name.inspect} #{tags.inspect}>"
end
+ def formula
+ @formula || self.class.default_formula
+ end
+
def to_dependency
- f = self.class.default_formula
- raise "No default formula defined for #{inspect}" if f.nil?
- if f =~ HOMEBREW_TAP_FORMULA_REGEX
- TapDependency.new(f, tags, method(:modify_build_environment), name)
- else
- Dependency.new(f, tags, method(:modify_build_environment), name)
+ if formula =~ HOMEBREW_TAP_FORMULA_REGEX
+ TapDependency.new(formula, tags, method(:modify_build_environment), name)
+ elsif formula
+ Dependency.new(formula, tags, method(:modify_build_environment), name)
end
end
diff --git a/Library/Homebrew/requirements/language_module_requirement.rb b/Library/Homebrew/requirements/language_module_requirement.rb
index e20f48361..392bc9b7a 100644
--- a/Library/Homebrew/requirements/language_module_requirement.rb
+++ b/Library/Homebrew/requirements/language_module_requirement.rb
@@ -32,12 +32,18 @@ class LanguageModuleRequirement < Requirement
def the_test
case @language
- when :lua then %W[/usr/bin/env luarocks-5.2 show #{@import_name}]
- when :lua51 then %W[/usr/bin/env luarocks-5.1 show #{@import_name}]
- when :perl then %W[/usr/bin/env perl -e use\ #{@import_name}]
- when :python then %W[/usr/bin/env python -c import\ #{@import_name}]
- when :python3 then %W[/usr/bin/env python3 -c import\ #{@import_name}]
- when :ruby then %W[/usr/bin/env ruby -rubygems -e require\ '#{@import_name}']
+ when :lua
+ ["/usr/bin/env", "luarocks-5.2", "show", @import_name.to_s]
+ when :lua51
+ ["/usr/bin/env", "luarocks-5.1", "show", @import_name.to_s]
+ when :perl
+ ["/usr/bin/env", "perl", "-e", "use #{@import_name}"]
+ when :python
+ ["/usr/bin/env", "python", "-c", "import #{@import_name}"]
+ when :python3
+ ["/usr/bin/env", "python3", "-c", "import #{@import_name}"]
+ when :ruby
+ ["/usr/bin/env", "ruby", "-rubygems", "-e", "require '#{@import_name}'"]
end
end
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index 746c3dd92..fd59539df 100644
--- a/Library/Homebrew/tab.rb
+++ b/Library/Homebrew/tab.rb
@@ -25,6 +25,8 @@ class Tab < OpenStruct
"unused_options" => build.unused_options.as_flags,
"tabfile" => formula.prefix.join(FILENAME),
"built_as_bottle" => build.bottle?,
+ "installed_as_dependency" => false,
+ "installed_on_request" => true,
"poured_from_bottle" => false,
"time" => Time.now.to_i,
"source_modified_time" => formula.source_modified_time.to_i,
@@ -172,6 +174,8 @@ class Tab < OpenStruct
"used_options" => [],
"unused_options" => [],
"built_as_bottle" => false,
+ "installed_as_dependency" => false,
+ "installed_on_request" => true,
"poured_from_bottle" => false,
"time" => nil,
"source_modified_time" => 0,
@@ -313,6 +317,8 @@ class Tab < OpenStruct
"unused_options" => unused_options.as_flags,
"built_as_bottle" => built_as_bottle,
"poured_from_bottle" => poured_from_bottle,
+ "installed_as_dependency" => installed_as_dependency,
+ "installed_on_request" => installed_on_request,
"changed_files" => changed_files && changed_files.map(&:to_s),
"time" => time,
"source_modified_time" => source_modified_time.to_i,
diff --git a/Library/Homebrew/test/ARGV_spec.rb b/Library/Homebrew/test/ARGV_spec.rb
new file mode 100644
index 000000000..bcb7c3f70
--- /dev/null
+++ b/Library/Homebrew/test/ARGV_spec.rb
@@ -0,0 +1,149 @@
+require "extend/ARGV"
+
+describe HomebrewArgvExtension do
+ subject { argv.extend(HomebrewArgvExtension) }
+ let(:argv) { ["mxcl"] }
+
+ describe "#formulae" do
+ it "raises an error when a Formula is unavailable" do
+ expect { subject.formulae }.to raise_error FormulaUnavailableError
+ end
+
+ context "when there are no Formulae" do
+ let(:argv) { [] }
+
+ it "returns an empty array" do
+ expect(subject.formulae).to be_empty
+ end
+ end
+ end
+
+ describe "#casks" do
+ it "returns an empty array if there is no match" do
+ expect(subject.casks).to eq []
+ end
+ end
+
+ describe "#kegs" do
+ context "when there are matching Kegs" do
+ before(:each) do
+ keg = HOMEBREW_CELLAR + "mxcl/10.0"
+ keg.mkpath
+ end
+
+ it "returns an array of Kegs" do
+ expect(subject.kegs.length).to eq 1
+ end
+ end
+
+ context "when there are no matching Kegs" do
+ let(:argv) { [] }
+
+ it "returns an empty array" do
+ expect(subject.kegs).to be_empty
+ end
+ end
+ end
+
+ describe "#named" do
+ let(:argv) { ["foo", "--debug", "-v"] }
+
+ it "returns an array of non-option arguments" do
+ expect(subject.named).to eq ["foo"]
+ end
+
+ context "when there are no named arguments" do
+ let(:argv) { [] }
+
+ it "returns an empty array" do
+ expect(subject.named).to be_empty
+ end
+ end
+ end
+
+ describe "#options_only" do
+ let(:argv) { ["--foo", "-vds", "a", "b", "cdefg"] }
+
+ it "returns an array of option arguments" do
+ expect(subject.options_only).to eq ["--foo", "-vds"]
+ end
+ end
+
+ describe "#flags_only" do
+ let(:argv) { ["--foo", "-vds", "a", "b", "cdefg"] }
+
+ it "returns an array of flags" do
+ expect(subject.flags_only).to eq ["--foo"]
+ end
+ end
+
+ describe "#empty?" do
+ let(:argv) { [] }
+
+ it "returns true if it is empty" do
+ expect(subject).to be_empty
+ end
+ end
+
+ describe "#switch?" do
+ let(:argv) { ["-ns", "-i", "--bar", "-a-bad-arg"] }
+
+ it "returns true if the given string is a switch" do
+ %w[n s i].each do |s|
+ expect(subject.switch?(s)).to be true
+ end
+ end
+
+ it "returns false if the given string is not a switch" do
+ %w[b ns bar --bar -n a bad arg].each do |s|
+ expect(subject.switch?(s)).to be false
+ end
+ end
+ end
+
+ describe "#flag?" do
+ let(:argv) { ["--foo", "-bq", "--bar"] }
+
+ it "returns true if the given string is a flag" do
+ expect(subject.flag?("--foo")).to eq true
+ expect(subject.flag?("--bar")).to eq true
+ end
+
+ it "returns true if there is a switch with the same initial character" do
+ expect(subject.flag?("--baz")).to eq true
+ expect(subject.flag?("--qux")).to eq true
+ end
+
+ it "returns false if there is no matching flag" do
+ expect(subject.flag?("--frotz")).to eq false
+ expect(subject.flag?("--debug")).to eq false
+ end
+ end
+
+ describe "#value" do
+ let(:argv) { ["--foo=", "--bar=ab"] }
+
+ it "returns the value for a given string" do
+ expect(subject.value("foo")).to eq ""
+ expect(subject.value("bar")).to eq "ab"
+ end
+
+ it "returns nil if there is no matching argument" do
+ expect(subject.value("baz")).to be nil
+ end
+ end
+
+ describe "#values" do
+ let(:argv) { ["--foo=", "--bar=a", "--baz=b,c"] }
+
+ it "returns the value for a given argument" do
+ expect(subject.values("foo")).to eq []
+ expect(subject.values("bar")).to eq ["a"]
+ expect(subject.values("baz")).to eq ["b", "c"]
+ end
+
+ it "returns nil if there is no matching argument" do
+ expect(subject.values("qux")).to be nil
+ end
+ end
+end
diff --git a/Library/Homebrew/test/ARGV_test.rb b/Library/Homebrew/test/ARGV_test.rb
deleted file mode 100644
index 6805e0c62..000000000
--- a/Library/Homebrew/test/ARGV_test.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require "testing_env"
-require "extend/ARGV"
-
-class ArgvExtensionTests < Homebrew::TestCase
- def setup
- @argv = [].extend(HomebrewArgvExtension)
- end
-
- def test_argv_formulae
- @argv.unshift "mxcl"
- assert_raises(FormulaUnavailableError) { @argv.formulae }
- end
-
- def test_argv_casks
- @argv.unshift "mxcl"
- assert_equal [], @argv.casks
- end
-
- def test_argv_kegs
- keg = HOMEBREW_CELLAR + "mxcl/10.0"
- keg.mkpath
- @argv << "mxcl"
- assert_equal 1, @argv.kegs.length
- ensure
- keg.parent.rmtree
- end
-
- def test_argv_named
- @argv << "foo" << "--debug" << "-v"
- assert_equal %w[foo], @argv.named
- end
-
- def test_options_only
- @argv << "--foo" << "-vds" << "a" << "b" << "cdefg"
- assert_equal %w[--foo -vds], @argv.options_only
- end
-
- def test_flags_only
- @argv << "--foo" << "-vds" << "a" << "b" << "cdefg"
- assert_equal %w[--foo], @argv.flags_only
- end
-
- def test_empty_argv
- assert_empty @argv.named
- assert_empty @argv.kegs
- assert_empty @argv.formulae
- assert_empty @argv
- end
-
- def test_switch?
- @argv << "-ns" << "-i" << "--bar" << "-a-bad-arg"
- %w[n s i].each { |s| assert @argv.switch?(s) }
- %w[b ns bar --bar -n a bad arg].each { |s| assert !@argv.switch?(s) }
- end
-
- def test_flag?
- @argv << "--foo" << "-bq" << "--bar"
- assert @argv.flag?("--foo")
- assert @argv.flag?("--bar")
- assert @argv.flag?("--baz")
- assert @argv.flag?("--qux")
- assert !@argv.flag?("--frotz")
- assert !@argv.flag?("--debug")
- end
-
- def test_value
- @argv << "--foo=" << "--bar=ab"
- assert_equal "", @argv.value("foo")
- assert_equal "ab", @argv.value("bar")
- assert_nil @argv.value("baz")
- end
-
- def test_values
- @argv << "--foo=" << "--bar=a" << "--baz=b,c"
- assert_equal [], @argv.values("foo")
- assert_equal ["a"], @argv.values("bar")
- assert_equal ["b", "c"], @argv.values("baz")
- assert_nil @argv.values("qux")
- end
-end
diff --git a/Library/Homebrew/test/ENV_test.rb b/Library/Homebrew/test/ENV_test.rb
index dd6025084..cbfd01e25 100644
--- a/Library/Homebrew/test/ENV_test.rb
+++ b/Library/Homebrew/test/ENV_test.rb
@@ -31,6 +31,7 @@ end
module SharedEnvTests
def setup
+ super
@env = {}.extend(EnvActivation)
end
diff --git a/Library/Homebrew/test/Gemfile b/Library/Homebrew/test/Gemfile
index a7e9eb834..25c8ce7ec 100644
--- a/Library/Homebrew/test/Gemfile
+++ b/Library/Homebrew/test/Gemfile
@@ -1,20 +1,14 @@
source "https://rubygems.org"
-gem "mocha", "~> 1.1"
-gem "minitest", "~> 5.3"
-gem "rake", "~> 10.3"
-gem "parallel_tests", "~> 2.9"
+gem "mocha"
+gem "minitest"
+gem "minitest-reporters"
+gem "parallel_tests"
+gem "rspec"
+gem "rspec-its", require: false
+gem "rspec-wait", require: false
group :coverage do
- # This is SimpleCov v0.12.0 with two fixes merged on top, that finally resolve
- # all issues with parallel tests, uncovered files, and tracked files. Switch
- # back to stable as soon as v0.12.1 or v0.13.0 is released. For details, see:
- # - https://github.com/colszowka/simplecov/pull/513
- # - https://github.com/colszowka/simplecov/pull/520
- gem "simplecov", "0.12.0",
- git: "https://github.com/colszowka/simplecov.git",
- branch: "master",
- ref: "83d8031ddde0927f87ef9327200a98583ca18d77",
- require: false
+ gem "simplecov", require: false
gem "codecov", require: false
end
diff --git a/Library/Homebrew/test/Gemfile.lock b/Library/Homebrew/test/Gemfile.lock
index aa4800f34..fba45d77b 100644
--- a/Library/Homebrew/test/Gemfile.lock
+++ b/Library/Homebrew/test/Gemfile.lock
@@ -1,31 +1,50 @@
-GIT
- remote: https://github.com/colszowka/simplecov.git
- revision: 83d8031ddde0927f87ef9327200a98583ca18d77
- ref: 83d8031ddde0927f87ef9327200a98583ca18d77
- branch: master
- specs:
- simplecov (0.12.0)
- docile (~> 1.1.0)
- json (>= 1.8, < 3)
- simplecov-html (~> 0.10.0)
-
GEM
remote: https://rubygems.org/
specs:
- codecov (0.1.6)
+ ansi (1.5.0)
+ builder (3.2.3)
+ codecov (0.1.9)
json
simplecov
url
+ diff-lcs (1.3)
docile (1.1.5)
- json (2.0.2)
+ json (2.0.3)
metaclass (0.0.4)
- minitest (5.9.1)
+ minitest (5.10.1)
+ minitest-reporters (1.1.14)
+ ansi
+ builder
+ minitest (>= 5.0)
+ ruby-progressbar
mocha (1.2.1)
metaclass (~> 0.0.1)
- parallel (1.9.0)
- parallel_tests (2.10.0)
+ parallel (1.10.0)
+ parallel_tests (2.13.0)
parallel
- rake (10.5.0)
+ rspec (3.5.0)
+ rspec-core (~> 3.5.0)
+ rspec-expectations (~> 3.5.0)
+ rspec-mocks (~> 3.5.0)
+ rspec-core (3.5.4)
+ rspec-support (~> 3.5.0)
+ rspec-expectations (3.5.0)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.5.0)
+ rspec-its (1.2.0)
+ rspec-core (>= 3.0.0)
+ rspec-expectations (>= 3.0.0)
+ rspec-mocks (3.5.0)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.5.0)
+ rspec-support (3.5.0)
+ rspec-wait (0.0.9)
+ rspec (>= 3, < 4)
+ ruby-progressbar (1.8.1)
+ simplecov (0.13.0)
+ docile (~> 1.1.0)
+ json (>= 1.8, < 3)
+ simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
url (0.3.2)
@@ -34,11 +53,14 @@ PLATFORMS
DEPENDENCIES
codecov
- minitest (~> 5.3)
- mocha (~> 1.1)
- parallel_tests (~> 2.9)
- rake (~> 10.3)
- simplecov (= 0.12.0)!
+ minitest
+ minitest-reporters
+ mocha
+ parallel_tests
+ rspec
+ rspec-its
+ rspec-wait
+ simplecov
BUNDLED WITH
- 1.13.6
+ 1.14.3
diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb
index dace4dc2b..b1ccb1e10 100644
--- a/Library/Homebrew/test/audit_test.rb
+++ b/Library/Homebrew/test/audit_test.rb
@@ -6,13 +6,10 @@ require "dev-cmd/audit"
class FormulaTextTests < Homebrew::TestCase
def setup
+ super
@dir = mktmpdir
end
- def teardown
- FileUtils.rm_rf @dir
- end
-
def formula_text(name, body = nil, options = {})
path = Pathname.new "#{@dir}/#{name}.rb"
path.open("w") do |f|
@@ -58,13 +55,10 @@ end
class FormulaAuditorTests < Homebrew::TestCase
def setup
+ super
@dir = mktmpdir
end
- def teardown
- FileUtils.rm_rf @dir
- end
-
def formula_auditor(name, text, options = {})
path = Pathname.new "#{@dir}/#{name}.rb"
path.open("w") do |f|
@@ -249,7 +243,7 @@ class FormulaAuditorTests < Homebrew::TestCase
needs_compat
require "compat/formula_specialties"
- ARGV.stubs(:homebrew_developer?).returns false
+ ENV.delete("HOMEBREW_DEVELOPER")
fa = shutup do
formula_auditor "foo", <<-EOS.undent
class Foo < GithubGistFormula
@@ -266,7 +260,7 @@ class FormulaAuditorTests < Homebrew::TestCase
needs_compat
require "compat/formula_specialties"
- ARGV.stubs(:homebrew_developer?).returns false
+ ENV.delete("HOMEBREW_DEVELOPER")
fa = formula_auditor "foo", <<-EOS.undent
class Foo < ScriptFileFormula
url "http://example.com/foo-1.0.tgz"
@@ -281,7 +275,7 @@ class FormulaAuditorTests < Homebrew::TestCase
needs_compat
require "compat/formula_specialties"
- ARGV.stubs(:homebrew_developer?).returns false
+ ENV.delete("HOMEBREW_DEVELOPER")
fa = formula_auditor "foo", <<-EOS.undent
class Foo < AmazonWebServicesFormula
url "http://example.com/foo-1.0.tgz"
@@ -367,13 +361,10 @@ class FormulaAuditorTests < Homebrew::TestCase
end
EOS
- original_value = ENV["HOMEBREW_NO_GITHUB_API"]
ENV["HOMEBREW_NO_GITHUB_API"] = "1"
fa.audit_github_repository
assert_equal [], fa.problems
- ensure
- ENV["HOMEBREW_NO_GITHUB_API"] = original_value
end
def test_audit_caveats
@@ -440,6 +431,9 @@ class FormulaAuditorTests < Homebrew::TestCase
"corge" => "http://savannah.nongnu.org/corge",
"grault" => "http://grault.github.io/",
"garply" => "http://www.gnome.org/garply",
+ "sf1" => "http://foo.sourceforge.net/",
+ "sf2" => "http://foo.sourceforge.net",
+ "sf3" => "http://foo.sf.net/",
"waldo" => "http://www.gnu.org/waldo",
}
@@ -464,6 +458,8 @@ class FormulaAuditorTests < Homebrew::TestCase
end
elsif homepage =~ %r{https:\/\/code\.google\.com}
assert_match "#{homepage} should end with a slash", fa.problems.first
+ elsif homepage =~ /foo\.(sf|sourceforge)\.net/
+ assert_match "#{homepage} should be `https://foo.sourceforge.io/`", fa.problems.first
else
assert_match "Please use https:// for #{homepage}", fa.problems.first
end
diff --git a/Library/Homebrew/test/bash_spec.rb b/Library/Homebrew/test/bash_spec.rb
new file mode 100644
index 000000000..1b0f15066
--- /dev/null
+++ b/Library/Homebrew/test/bash_spec.rb
@@ -0,0 +1,52 @@
+require "open3"
+
+RSpec::Matchers.define :have_valid_bash_syntax do
+ match do |file|
+ stdout, stderr, status = Open3.capture3("/bin/bash", "-n", file)
+
+ @actual = [file, stderr]
+
+ stdout.empty? && status.success?
+ end
+
+ failure_message do |(file, stderr)|
+ "expected that #{file} is a valid Bash file:\n#{stderr}"
+ end
+end
+
+describe "Bash" do
+ context "brew" do
+ subject { HOMEBREW_LIBRARY_PATH.parent.parent/"bin/brew" }
+ it { is_expected.to have_valid_bash_syntax }
+ end
+
+ context "every `.sh` file" do
+ it "has valid bash syntax" do
+ Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/**/*.sh").each do |path|
+ relative_path = path.relative_path_from(HOMEBREW_LIBRARY_PATH)
+ next if relative_path.to_s.start_with?("shims/", "test/", "vendor/")
+
+ expect(path).to have_valid_bash_syntax
+ end
+ end
+ end
+
+ context "Bash completion" do
+ subject { HOMEBREW_LIBRARY_PATH.parent.parent/"completions/bash/brew" }
+ it { is_expected.to have_valid_bash_syntax }
+ end
+
+ context "every shim script" do
+ it "has valid bash syntax" do
+ # These have no file extension, but can be identified by their shebang.
+ (HOMEBREW_LIBRARY_PATH/"shims").find do |path|
+ next if path.directory?
+ next if path.symlink?
+ next unless path.executable?
+ next unless path.read(12) == "#!/bin/bash\n"
+
+ expect(path).to have_valid_bash_syntax
+ end
+ end
+ end
+end
diff --git a/Library/Homebrew/test/bash_test.rb b/Library/Homebrew/test/bash_test.rb
deleted file mode 100644
index 671ab5ec8..000000000
--- a/Library/Homebrew/test/bash_test.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require "testing_env"
-
-class BashTests < Homebrew::TestCase
- def assert_valid_bash_syntax(file)
- return unless file.exist?
- output = Utils.popen_read("/bin/bash -n #{file} 2>&1")
- assert $?.success?, output
- end
-
- def test_bin_brew
- assert_valid_bash_syntax HOMEBREW_LIBRARY_PATH.parent.parent/"bin/brew"
- end
-
- def test_bash_code
- Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/**/*.sh").each do |pn|
- pn_relative = pn.relative_path_from(HOMEBREW_LIBRARY_PATH)
- next if pn_relative.to_s.start_with?("shims/", "test/", "vendor/")
- assert_valid_bash_syntax pn
- end
- end
-
- def test_bash_completion
- script = HOMEBREW_LIBRARY_PATH.parent.parent/"completions/bash/brew"
- assert_valid_bash_syntax script
- end
-
- def test_bash_shims
- # These have no file extension, but can be identified by their shebang.
- (HOMEBREW_LIBRARY_PATH/"shims").find do |pn|
- next if pn.directory? || pn.symlink?
- next unless pn.executable? && pn.read(12) == "#!/bin/bash\n"
- assert_valid_bash_syntax pn
- end
- end
-end
diff --git a/Library/Homebrew/test/blacklist_spec.rb b/Library/Homebrew/test/blacklist_spec.rb
new file mode 100644
index 000000000..89d254893
--- /dev/null
+++ b/Library/Homebrew/test/blacklist_spec.rb
@@ -0,0 +1,111 @@
+require "blacklist"
+
+RSpec::Matchers.define :be_blacklisted do
+ match do |actual|
+ blacklisted?(actual)
+ end
+end
+
+describe "Blacklist" do
+ context "rubygems" do
+ %w[gem rubygem rubygems].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "latex" do
+ %w[latex tex tex-live texlive TexLive].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "pip" do
+ subject { "pip" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "pil" do
+ subject { "pil" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "macruby" do
+ subject { "MacRuby" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "lzma" do
+ %w[lzma liblzma].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "gtest" do
+ %w[gtest googletest google-test].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "gmock" do
+ %w[gmock googlemock google-mock].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "sshpass" do
+ subject { "sshpass" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "gsutil" do
+ subject { "gsutil" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "clojure" do
+ subject { "clojure" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "osmium" do
+ %w[osmium Osmium].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "gfortran" do
+ subject { "gfortran" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "play" do
+ subject { "play" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "haskell_platform" do
+ subject { "haskell-platform" }
+
+ it { is_expected.to be_blacklisted }
+ end
+end
diff --git a/Library/Homebrew/test/blacklist_test.rb b/Library/Homebrew/test/blacklist_test.rb
deleted file mode 100644
index 585a35484..000000000
--- a/Library/Homebrew/test/blacklist_test.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-require "testing_env"
-require "blacklist"
-
-class BlacklistTests < Homebrew::TestCase
- def assert_blacklisted(s)
- assert blacklisted?(s), "'#{s}' should be blacklisted"
- end
-
- def test_rubygems
- %w[gem rubygem rubygems].each { |s| assert_blacklisted s }
- end
-
- def test_latex
- %w[latex tex tex-live texlive TexLive].each { |s| assert_blacklisted s }
- end
-
- def test_pip
- assert_blacklisted "pip"
- end
-
- def test_pil
- assert_blacklisted "pil"
- end
-
- def test_macruby
- assert_blacklisted "MacRuby"
- end
-
- def test_lzma
- %w[lzma liblzma].each { |s| assert_blacklisted s }
- end
-
- def test_gtest
- %w[gtest googletest google-test].each { |s| assert_blacklisted s }
- end
-
- def test_gmock
- %w[gmock googlemock google-mock].each { |s| assert_blacklisted s }
- end
-
- def test_sshpass
- assert_blacklisted "sshpass"
- end
-
- def test_gsutil
- assert_blacklisted "gsutil"
- end
-
- def test_clojure
- assert_blacklisted "clojure"
- end
-
- def test_osmium
- %w[osmium Osmium].each { |s| assert_blacklisted s }
- end
-
- def test_gfortran
- assert_blacklisted "gfortran"
- end
-
- def test_play
- assert_blacklisted "play"
- end
-
- def test_haskell_platform
- assert_blacklisted "haskell-platform"
- end
-end
diff --git a/Library/Homebrew/test/bottle_collector_test.rb b/Library/Homebrew/test/bottle_collector_test.rb
index d75e29ec8..5879da92c 100644
--- a/Library/Homebrew/test/bottle_collector_test.rb
+++ b/Library/Homebrew/test/bottle_collector_test.rb
@@ -3,6 +3,7 @@ require "utils/bottles"
class BottleCollectorTests < Homebrew::TestCase
def setup
+ super
@collector = Utils::Bottles::Collector.new
end
diff --git a/Library/Homebrew/test/bottle_hooks_test.rb b/Library/Homebrew/test/bottle_hooks_test.rb
index 3535d80ef..fd890192f 100644
--- a/Library/Homebrew/test/bottle_hooks_test.rb
+++ b/Library/Homebrew/test/bottle_hooks_test.rb
@@ -17,6 +17,7 @@ class BottleHookTests < Homebrew::TestCase
end
def setup
+ super
@fi = FormulaInstaller.new FormulaDouble.new
end
@@ -43,5 +44,6 @@ class BottleHookTests < Homebrew::TestCase
def teardown
Homebrew::Hooks::Bottles.reset_hooks
+ super
end
end
diff --git a/Library/Homebrew/test/bottle_test.rb b/Library/Homebrew/test/bottle_test.rb
index c10746e09..7981ccf79 100644
--- a/Library/Homebrew/test/bottle_test.rb
+++ b/Library/Homebrew/test/bottle_test.rb
@@ -14,7 +14,7 @@ class IntegrationCommandTestBottle < IntegrationCommandTestCase
FileUtils.ln_s "not-exist", "symlink"
end
assert_match(/testball-0\.1.*\.bottle\.tar\.gz/,
- cmd_output("bottle", "--no-rebuild", "testball"))
+ cmd("bottle", "--no-rebuild", "testball"))
ensure
FileUtils.rm_f Dir["testball-0.1*.bottle.tar.gz"]
end
diff --git a/Library/Homebrew/test/build_environment_test.rb b/Library/Homebrew/test/build_environment_test.rb
index 73a1c95f7..54b9cb2b1 100644
--- a/Library/Homebrew/test/build_environment_test.rb
+++ b/Library/Homebrew/test/build_environment_test.rb
@@ -3,6 +3,7 @@ require "build_environment"
class BuildEnvironmentTests < Homebrew::TestCase
def setup
+ super
@env = BuildEnvironment.new
end
diff --git a/Library/Homebrew/test/build_options_test.rb b/Library/Homebrew/test/build_options_test.rb
index e460d25cc..05e7ccd94 100644
--- a/Library/Homebrew/test/build_options_test.rb
+++ b/Library/Homebrew/test/build_options_test.rb
@@ -4,6 +4,7 @@ require "options"
class BuildOptionsTests < Homebrew::TestCase
def setup
+ super
args = Options.create(%w[--with-foo --with-bar --without-qux])
opts = Options.create(%w[--with-foo --with-bar --without-baz --without-qux])
@build = BuildOptions.new(args, opts)
diff --git a/Library/Homebrew/test/caveats_test.rb b/Library/Homebrew/test/caveats_test.rb
index 9eaac5792..3a582b907 100644
--- a/Library/Homebrew/test/caveats_test.rb
+++ b/Library/Homebrew/test/caveats_test.rb
@@ -4,6 +4,7 @@ require "caveats"
class CaveatsTests < Homebrew::TestCase
def setup
+ super
@f = formula { url "foo-1.0" }
@c = Caveats.new @f
end
diff --git a/Library/Homebrew/test/checksum_verification_test.rb b/Library/Homebrew/test/checksum_verification_test.rb
index 9017b528d..4c674edd2 100644
--- a/Library/Homebrew/test/checksum_verification_test.rb
+++ b/Library/Homebrew/test/checksum_verification_test.rb
@@ -17,10 +17,6 @@ class ChecksumVerificationTests < Homebrew::TestCase
end
end
- def teardown
- @_f.clear_cache
- end
-
def test_good_sha256
formula do
sha256 TESTBALL_SHA256
diff --git a/Library/Homebrew/test/cleaner_test.rb b/Library/Homebrew/test/cleaner_test.rb
index ac108421c..05a91b90b 100644
--- a/Library/Homebrew/test/cleaner_test.rb
+++ b/Library/Homebrew/test/cleaner_test.rb
@@ -6,14 +6,11 @@ class CleanerTests < Homebrew::TestCase
include FileUtils
def setup
+ super
@f = formula("cleaner_test") { url "foo-1.0" }
@f.prefix.mkpath
end
- def teardown
- @f.rack.rmtree if @f.rack.exist?
- end
-
def test_clean_file
@f.bin.mkpath
@f.lib.mkpath
diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb
index bb8e1cdc6..e6fc31dfe 100644
--- a/Library/Homebrew/test/cleanup_test.rb
+++ b/Library/Homebrew/test/cleanup_test.rb
@@ -14,14 +14,14 @@ end
class CleanupTests < Homebrew::TestCase
def setup
+ super
@ds_store = Pathname.new "#{HOMEBREW_PREFIX}/Library/.DS_Store"
FileUtils.touch @ds_store
end
def teardown
FileUtils.rm_f @ds_store
- ARGV.delete "--dry-run"
- ARGV.delete "--prune=all"
+ super
end
def test_cleanup
@@ -36,28 +36,40 @@ class CleanupTests < Homebrew::TestCase
end
def test_cleanup_formula
- f1 = Class.new(Testball) { version "0.1" }.new
- f2 = Class.new(Testball) { version "0.2" }.new
- f3 = Class.new(Testball) { version "0.3" }.new
+ f1 = Class.new(Testball) do
+ version "1.0"
+ end.new
+ f2 = Class.new(Testball) do
+ version "0.2"
+ version_scheme 1
+ end.new
+ f3 = Class.new(Testball) do
+ version "0.3"
+ version_scheme 1
+ end.new
+ f4 = Class.new(Testball) do
+ version "0.1"
+ version_scheme 2
+ end.new
shutup do
- f1.brew { f1.install }
- f2.brew { f2.install }
- f3.brew { f3.install }
+ [f1, f2, f3, f4].each do |f|
+ f.brew { f.install }
+ Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
+ end
end
assert_predicate f1, :installed?
assert_predicate f2, :installed?
assert_predicate f3, :installed?
+ assert_predicate f4, :installed?
shutup { Homebrew::Cleanup.cleanup_formula f3 }
refute_predicate f1, :installed?
refute_predicate f2, :installed?
assert_predicate f3, :installed?
- ensure
- [f1, f2, f3].each(&:clear_cache)
- f3.rack.rmtree
+ assert_predicate f4, :installed?
end
def test_cleanup_logs
diff --git a/Library/Homebrew/test/commands_test.rb b/Library/Homebrew/test/commands_test.rb
index d44d2da0e..5f5dc9586 100644
--- a/Library/Homebrew/test/commands_test.rb
+++ b/Library/Homebrew/test/commands_test.rb
@@ -13,6 +13,7 @@ end
class CommandsTests < Homebrew::TestCase
def setup
+ super
@cmds = [
# internal commands
HOMEBREW_LIBRARY_PATH/"cmd/rbcmd.rb",
@@ -28,6 +29,7 @@ class CommandsTests < Homebrew::TestCase
def teardown
@cmds.each(&:unlink)
+ super
end
def test_internal_commands
@@ -45,8 +47,6 @@ class CommandsTests < Homebrew::TestCase
end
def test_external_commands
- env = ENV.to_hash
-
mktmpdir do |dir|
%w[brew-t1 brew-t2.rb brew-t3.py].each do |file|
path = "#{dir}/#{file}"
@@ -65,8 +65,6 @@ class CommandsTests < Homebrew::TestCase
"Executable files with a non Ruby extension shoudn't be included"
refute cmds.include?("t4"), "Non-executable files shouldn't be included"
end
- ensure
- ENV.replace(env)
end
def test_internal_command_path
diff --git a/Library/Homebrew/test/compiler_selector_test.rb b/Library/Homebrew/test/compiler_selector_test.rb
index b1591bdbe..aa1a6f97e 100644
--- a/Library/Homebrew/test/compiler_selector_test.rb
+++ b/Library/Homebrew/test/compiler_selector_test.rb
@@ -31,6 +31,7 @@ class CompilerSelectorTests < Homebrew::TestCase
end
def setup
+ super
@f = Double.new
@cc = :clang
@versions = CompilerVersions.new
diff --git a/Library/Homebrew/test/dependencies_test.rb b/Library/Homebrew/test/dependencies_test.rb
index db3b78226..c5444fcbc 100644
--- a/Library/Homebrew/test/dependencies_test.rb
+++ b/Library/Homebrew/test/dependencies_test.rb
@@ -5,6 +5,7 @@ require "requirements"
class DependenciesTests < Homebrew::TestCase
def setup
+ super
@deps = Dependencies.new
end
@@ -89,6 +90,7 @@ end
class RequirementsTests < Homebrew::TestCase
def setup
+ super
@reqs = Requirements.new
end
diff --git a/Library/Homebrew/test/dependency_collector_test.rb b/Library/Homebrew/test/dependency_collector_test.rb
index 1c7f70118..c63d04637 100644
--- a/Library/Homebrew/test/dependency_collector_test.rb
+++ b/Library/Homebrew/test/dependency_collector_test.rb
@@ -11,11 +11,13 @@ class DependencyCollectorTests < Homebrew::TestCase
end
def setup
+ super
@d = DependencyCollector.new
end
def teardown
DependencyCollector.clear_cache
+ super
end
def test_dependency_creation
diff --git a/Library/Homebrew/test/dependency_expansion_test.rb b/Library/Homebrew/test/dependency_expansion_test.rb
index 9d6de35e2..de743ce03 100644
--- a/Library/Homebrew/test/dependency_expansion_test.rb
+++ b/Library/Homebrew/test/dependency_expansion_test.rb
@@ -9,6 +9,7 @@ class DependencyExpansionTests < Homebrew::TestCase
end
def setup
+ super
@foo = build_dep(:foo)
@bar = build_dep(:bar)
@baz = build_dep(:baz)
diff --git a/Library/Homebrew/test/dependency_test.rb b/Library/Homebrew/test/dependency_test.rb
index 65255995e..404f26d79 100644
--- a/Library/Homebrew/test/dependency_test.rb
+++ b/Library/Homebrew/test/dependency_test.rb
@@ -3,6 +3,7 @@ require "dependency"
class DependableTests < Homebrew::TestCase
def setup
+ super
@tags = ["foo", "bar", :build]
@dep = Struct.new(:tags).new(@tags).extend(Dependable)
end
@@ -118,6 +119,11 @@ class DependencyTests < Homebrew::TestCase
end
class TapDependencyTests < Homebrew::TestCase
+ def test_tap
+ dep = TapDependency.new("foo/bar/dog")
+ assert_equal Tap.new("foo", "bar"), dep.tap
+ end
+
def test_option_names
dep = TapDependency.new("foo/bar/dog")
assert_equal %w[dog], dep.option_names
diff --git a/Library/Homebrew/test/descriptions_test.rb b/Library/Homebrew/test/descriptions_test.rb
index de38fdbd1..baeeb7b19 100644
--- a/Library/Homebrew/test/descriptions_test.rb
+++ b/Library/Homebrew/test/descriptions_test.rb
@@ -3,6 +3,8 @@ require "descriptions"
class DescriptionsTest < Homebrew::TestCase
def setup
+ super
+
@descriptions_hash = {}
@descriptions = Descriptions.new(@descriptions_hash)
@@ -12,6 +14,7 @@ class DescriptionsTest < Homebrew::TestCase
def teardown
$stdout = @old_stdout
+ super
end
def test_single_core_formula
diff --git a/Library/Homebrew/test/diagnostic_test.rb b/Library/Homebrew/test/diagnostic_test.rb
index c9bb524b0..7a1fb25f7 100644
--- a/Library/Homebrew/test/diagnostic_test.rb
+++ b/Library/Homebrew/test/diagnostic_test.rb
@@ -5,14 +5,10 @@ require "diagnostic"
class DiagnosticChecksTest < Homebrew::TestCase
def setup
- @env = ENV.to_hash
+ super
@checks = Homebrew::Diagnostic::Checks.new
end
- def teardown
- ENV.replace(@env)
- end
-
def test_inject_file_list
assert_equal "foo:\n",
@checks.inject_file_list([], "foo:\n")
@@ -103,8 +99,6 @@ class DiagnosticChecksTest < Homebrew::TestCase
assert_match "/usr/bin occurs before #{HOMEBREW_PREFIX}/bin",
@checks.check_user_path_1
- ensure
- bin.rmtree
end
def test_check_user_path_bin
diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb
index 2b64abbf9..40236b420 100644
--- a/Library/Homebrew/test/download_strategies_test.rb
+++ b/Library/Homebrew/test/download_strategies_test.rb
@@ -15,6 +15,7 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase
include FileUtils
def setup
+ super
@name = "foo"
@resource = ResourceDouble.new
@strategy = AbstractDownloadStrategy.new(@name, @resource)
@@ -63,6 +64,7 @@ end
class GitHubPrivateRepositoryDownloadStrategyTests < Homebrew::TestCase
def setup
+ super
resource = ResourceDouble.new("https://github.com/owner/repo/archive/1.1.5.tar.gz")
ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token"
GitHub.stubs(:repository).returns {}
@@ -87,6 +89,7 @@ end
class GitHubPrivateRepositoryReleaseDownloadStrategyTests < Homebrew::TestCase
def setup
+ super
resource = ResourceDouble.new("https://github.com/owner/repo/releases/download/tag/foo_v0.1.0_darwin_amd64.tar.gz")
ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token"
GitHub.stubs(:repository).returns {}
@@ -138,6 +141,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase
include FileUtils
def setup
+ super
resource = ResourceDouble.new("https://github.com/homebrew/foo")
@commit_id = 1
@strategy = GitDownloadStrategy.new("baz", resource)
@@ -145,10 +149,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase
mkpath @cached_location
end
- def teardown
- rmtree @cached_location
- end
-
def git_commit_all
shutup do
system "git", "add", "--all"
@@ -157,28 +157,14 @@ class GitDownloadStrategyTests < Homebrew::TestCase
end
end
- def using_git_env
- initial_env = ENV.to_hash
- %w[AUTHOR COMMITTER].each do |role|
- ENV["GIT_#{role}_NAME"] = "brew tests"
- ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost"
- ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100"
- end
- yield
- ensure
- ENV.replace(initial_env)
- end
-
def setup_git_repo
- using_git_env do
- @cached_location.cd do
- shutup do
- system "git", "init"
- system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
- end
- touch "README"
- git_commit_all
+ @cached_location.cd do
+ shutup do
+ system "git", "init"
+ system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
end
+ touch "README"
+ git_commit_all
end
end
@@ -192,18 +178,16 @@ class GitDownloadStrategyTests < Homebrew::TestCase
def test_source_modified_time
setup_git_repo
- assert_equal 1_242_860_651, @strategy.source_modified_time.to_i
+ assert_equal 1_485_115_153, @strategy.source_modified_time.to_i
end
def test_last_commit
setup_git_repo
- using_git_env do
- @cached_location.cd do
- touch "LICENSE"
- git_commit_all
- end
+ @cached_location.cd do
+ touch "LICENSE"
+ git_commit_all
end
- assert_equal "c50c79b", @strategy.last_commit
+ assert_equal "f68266e", @strategy.last_commit
end
def test_fetch_last_commit
@@ -214,21 +198,19 @@ class GitDownloadStrategyTests < Homebrew::TestCase
resource.instance_variable_set(:@version, Version.create("HEAD"))
@strategy = GitDownloadStrategy.new("baz", resource)
- using_git_env do
- remote_repo.cd do
- shutup do
- system "git", "init"
- system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
- end
- touch "README"
- git_commit_all
- touch "LICENSE"
- git_commit_all
+ remote_repo.cd do
+ shutup do
+ system "git", "init"
+ system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo"
end
+ touch "README"
+ git_commit_all
+ touch "LICENSE"
+ git_commit_all
end
@strategy.shutup!
- assert_equal "c50c79b", @strategy.fetch_last_commit
+ assert_equal "f68266e", @strategy.fetch_last_commit
ensure
remote_repo.rmtree if remote_repo.directory?
end
@@ -236,6 +218,7 @@ end
class DownloadStrategyDetectorTests < Homebrew::TestCase
def setup
+ super
@d = DownloadStrategyDetector.new
end
diff --git a/Library/Homebrew/test/emoji_test.rb b/Library/Homebrew/test/emoji_test.rb
new file mode 100644
index 000000000..ea68db8f6
--- /dev/null
+++ b/Library/Homebrew/test/emoji_test.rb
@@ -0,0 +1,11 @@
+require "testing_env"
+require "emoji"
+
+class EmojiTest < Homebrew::TestCase
+ def test_install_badge
+ assert_equal "🍺", Emoji.install_badge
+
+ ENV["HOMEBREW_INSTALL_BADGE"] = "foo"
+ assert_equal "foo", Emoji.install_badge
+ end
+end
diff --git a/Library/Homebrew/test/exceptions_test.rb b/Library/Homebrew/test/exceptions_test.rb
index 689531c6e..e9fedef04 100644
--- a/Library/Homebrew/test/exceptions_test.rb
+++ b/Library/Homebrew/test/exceptions_test.rb
@@ -56,6 +56,11 @@ class ExceptionsTest < Homebrew::TestCase
FormulaClassUnavailableError.new("foo", "foo.rb", "Foo", list).to_s
end
+ def test_formula_unreadable_error
+ formula_error = LoadError.new("bar")
+ assert_equal "foo: bar", FormulaUnreadableError.new("foo", formula_error).to_s
+ end
+
def test_tap_unavailable_error
assert_equal "No available tap foo.\n", TapUnavailableError.new("foo").to_s
end
diff --git a/Library/Homebrew/test/formula_installer_test.rb b/Library/Homebrew/test/formula_installer_test.rb
index 652548bd7..c99b2de74 100644
--- a/Library/Homebrew/test/formula_installer_test.rb
+++ b/Library/Homebrew/test/formula_installer_test.rb
@@ -84,13 +84,10 @@ class InstallTests < Homebrew::TestCase
cc_arg = "--cc=clang"
ARGV << cc_arg
- begin
- temporary_install(TestballBottle.new) do |f|
- tab = Tab.for_formula(f)
- assert_equal "clang", tab.compiler
- end
- ensure
- ARGV.delete_if { |x| x == cc_arg }
+
+ temporary_install(TestballBottle.new) do |f|
+ tab = Tab.for_formula(f)
+ assert_equal "clang", tab.compiler
end
end
end
@@ -128,11 +125,7 @@ class FormulaInstallerTests < Homebrew::TestCase
fi = FormulaInstaller.new(dependent)
assert_raises(CannotInstallFormulaError) { fi.check_install_sanity }
ensure
- dependency.unpin
dependency_keg.unlink
- dependency_keg.uninstall
- dependency.clear_cache
- dep_path.unlink
Formulary::FORMULAE.delete(dep_path)
end
end
diff --git a/Library/Homebrew/test/formula_lock_test.rb b/Library/Homebrew/test/formula_lock_test.rb
index 80ee9dd25..13244555d 100644
--- a/Library/Homebrew/test/formula_lock_test.rb
+++ b/Library/Homebrew/test/formula_lock_test.rb
@@ -3,13 +3,14 @@ require "formula_lock"
class FormulaLockTests < Homebrew::TestCase
def setup
+ super
@lock = FormulaLock.new("foo")
@lock.lock
end
def teardown
@lock.unlock
- HOMEBREW_LOCK_DIR.children.each(&:unlink)
+ super
end
def test_locking_file_with_existing_lock_raises_error
diff --git a/Library/Homebrew/test/formula_pin_test.rb b/Library/Homebrew/test/formula_pin_test.rb
index 297d7703e..7e3c7efa0 100644
--- a/Library/Homebrew/test/formula_pin_test.rb
+++ b/Library/Homebrew/test/formula_pin_test.rb
@@ -21,6 +21,7 @@ class FormulaPinTests < Homebrew::TestCase
end
def setup
+ super
@f = FormulaDouble.new
@pin = FormulaPin.new(@f)
@f.rack.mkpath
@@ -47,8 +48,4 @@ class FormulaPinTests < Homebrew::TestCase
refute_predicate @pin, :pinned?
refute_predicate HOMEBREW_PINNED_KEGS, :directory?
end
-
- def teardown
- @f.rack.rmtree
- end
end
diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb
index 81022d220..f7b06b079 100644
--- a/Library/Homebrew/test/formula_test.rb
+++ b/Library/Homebrew/test/formula_test.rb
@@ -176,8 +176,6 @@ class FormulaTests < Homebrew::TestCase
prefix.mkpath
FileUtils.touch prefix+Tab::FILENAME
assert_predicate f, :any_version_installed?
- ensure
- f.rack.rmtree
end
def test_migration_needed
@@ -203,9 +201,6 @@ class FormulaTests < Homebrew::TestCase
newname_prefix.mkpath
refute_predicate f, :migration_needed?
- ensure
- oldname_prefix.parent.rmtree
- newname_prefix.parent.rmtree
end
def test_installed?
@@ -240,8 +235,6 @@ class FormulaTests < Homebrew::TestCase
prefix = HOMEBREW_CELLAR+f.name+f.head.version
prefix.mkpath
assert_equal prefix, f.installed_prefix
- ensure
- f.rack.rmtree
end
def test_installed_prefix_devel_installed
@@ -255,8 +248,6 @@ class FormulaTests < Homebrew::TestCase
prefix = HOMEBREW_CELLAR+f.name+f.devel.version
prefix.mkpath
assert_equal prefix, f.installed_prefix
- ensure
- f.rack.rmtree
end
def test_installed_prefix_stable_installed
@@ -270,8 +261,6 @@ class FormulaTests < Homebrew::TestCase
prefix = HOMEBREW_CELLAR+f.name+f.version
prefix.mkpath
assert_equal prefix, f.installed_prefix
- ensure
- f.rack.rmtree
end
def test_installed_prefix_outdated_stable_head_installed
@@ -289,8 +278,6 @@ class FormulaTests < Homebrew::TestCase
tab.write
assert_equal HOMEBREW_CELLAR/"#{f.name}/#{f.version}", f.installed_prefix
- ensure
- f.rack.rmtree
end
def test_installed_prefix_outdated_devel_head_installed
@@ -311,8 +298,6 @@ class FormulaTests < Homebrew::TestCase
tab.write
assert_equal HOMEBREW_CELLAR/"#{f.name}/#{f.version}", f.installed_prefix
- ensure
- f.rack.rmtree
end
def test_installed_prefix_head
@@ -358,8 +343,6 @@ class FormulaTests < Homebrew::TestCase
prefix = HOMEBREW_CELLAR/"#{f.name}/HEAD-222222_2"
assert_equal prefix, f.latest_head_prefix
- ensure
- f.rack.rmtree
end
def test_equality
@@ -543,8 +526,6 @@ class FormulaTests < Homebrew::TestCase
end
def test_update_head_version
- initial_env = ENV.to_hash
-
f = formula do
head "foo", using: :git
end
@@ -552,12 +533,6 @@ class FormulaTests < Homebrew::TestCase
cached_location = f.head.downloader.cached_location
cached_location.mkpath
- %w[AUTHOR COMMITTER].each do |role|
- ENV["GIT_#{role}_NAME"] = "brew tests"
- ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost"
- ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100"
- end
-
cached_location.cd do
FileUtils.touch "LICENSE"
shutup do
@@ -569,9 +544,6 @@ class FormulaTests < Homebrew::TestCase
f.update_head_version
assert_equal Version.create("HEAD-5658946"), f.head.version
- ensure
- ENV.replace(initial_env)
- cached_location.rmtree
end
def test_legacy_options
@@ -689,6 +661,44 @@ class FormulaTests < Homebrew::TestCase
assert_equal %w[foo/bar/f1 baz/qux/f2], f3.runtime_dependencies.map(&:name)
end
+ def test_requirements
+ f1 = formula("f1") do
+ url "f1-1"
+
+ depends_on :python
+ depends_on x11: :recommended
+ depends_on xcode: ["1.0", :optional]
+ end
+ stub_formula_loader f1
+
+ python = PythonRequirement.new
+ x11 = X11Requirement.new("x11", [:recommended])
+ xcode = XcodeRequirement.new(["1.0", :optional])
+
+ # Default block should filter out deps that aren't being used
+ assert_equal Set[python, x11], Set.new(f1.recursive_requirements)
+
+ f1.build = BuildOptions.new(["--with-xcode", "--without-x11"], f1.options)
+ assert_equal Set[python, xcode], Set.new(f1.recursive_requirements)
+ f1.build = f1.stable.build
+
+ f2 = formula("f2") do
+ url "f2-1"
+ depends_on "f1"
+ end
+
+ assert_equal Set[python, x11], Set.new(f2.recursive_requirements)
+
+ # Empty block should allow all requirements
+ assert_equal Set[python, x11, xcode], Set.new(f2.recursive_requirements {})
+
+ # Requirements can be pruned
+ requirements = f2.recursive_requirements do |_dependent, requirement|
+ Requirement.prune if requirement.is_a?(PythonRequirement)
+ end
+ assert_equal Set[x11, xcode], Set.new(requirements)
+ end
+
def test_to_hash
f1 = formula("foo") do
url "foo-1.0"
@@ -717,25 +727,36 @@ class FormulaTests < Homebrew::TestCase
end
def test_eligible_kegs_for_cleanup
- f1 = Class.new(Testball) { version "0.1" }.new
- f2 = Class.new(Testball) { version "0.2" }.new
- f3 = Class.new(Testball) { version "0.3" }.new
+ f1 = Class.new(Testball) do
+ version "1.0"
+ end.new
+ f2 = Class.new(Testball) do
+ version "0.2"
+ version_scheme 1
+ end.new
+ f3 = Class.new(Testball) do
+ version "0.3"
+ version_scheme 1
+ end.new
+ f4 = Class.new(Testball) do
+ version "0.1"
+ version_scheme 2
+ end.new
shutup do
- f1.brew { f1.install }
- f2.brew { f2.install }
- f3.brew { f3.install }
+ [f1, f2, f3, f4].each do |f|
+ f.brew { f.install }
+ Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
+ end
end
assert_predicate f1, :installed?
assert_predicate f2, :installed?
assert_predicate f3, :installed?
+ assert_predicate f4, :installed?
- assert_equal f3.installed_kegs.sort_by(&:version)[0..1],
+ assert_equal [f2, f1].map { |f| Keg.new(f.prefix) },
f3.eligible_kegs_for_cleanup.sort_by(&:version)
- ensure
- [f1, f2, f3].each(&:clear_cache)
- f3.rack.rmtree
end
def test_eligible_kegs_for_cleanup_keg_pinned
@@ -757,10 +778,6 @@ class FormulaTests < Homebrew::TestCase
assert_predicate f3, :installed?
assert_equal [Keg.new(f2.prefix)], shutup { f3.eligible_kegs_for_cleanup }
- ensure
- f1.unpin
- [f1, f2, f3].each(&:clear_cache)
- f3.rack.rmtree
end
def test_eligible_kegs_for_cleanup_head_installed
@@ -783,8 +800,6 @@ class FormulaTests < Homebrew::TestCase
eligible_kegs = f.installed_kegs - [Keg.new(f.prefix("HEAD-111111_1"))]
assert_equal eligible_kegs, f.eligible_kegs_for_cleanup
- ensure
- f.rack.rmtree
end
def test_pour_bottle
@@ -836,6 +851,8 @@ class AliasChangeTests < Homebrew::TestCase
end
def setup
+ super
+
alias_name = "bar"
@alias_path = "#{CoreTap.instance.alias_dir}/#{alias_name}"
@@ -904,6 +921,8 @@ class OutdatedVersionsTests < Homebrew::TestCase
attr_reader :f, :old_formula, :new_formula
def setup
+ super
+
@f = formula do
url "foo"
version "1.20"
@@ -919,11 +938,6 @@ class OutdatedVersionsTests < Homebrew::TestCase
@old_alias_target_prefix = HOMEBREW_CELLAR/"#{old_formula.name}/1.0"
end
- def teardown
- formulae = [@f, @old_formula, @new_formula]
- formulae.map(&:rack).select(&:exist?).each(&:rmtree)
- end
-
def alias_path
"#{@f.tap.alias_dir}/bar"
end
@@ -1088,13 +1102,12 @@ class OutdatedVersionsTests < Homebrew::TestCase
outdated_stable_prefix = HOMEBREW_CELLAR.join("testball/1.0")
head_prefix_a = HOMEBREW_CELLAR.join("testball/HEAD")
head_prefix_b = HOMEBREW_CELLAR.join("testball/HEAD-aaaaaaa_1")
- head_prefix_c = HOMEBREW_CELLAR.join("testball/HEAD-5658946")
+ head_prefix_c = HOMEBREW_CELLAR.join("testball/HEAD-18a7103")
setup_tab_for_prefix(outdated_stable_prefix)
tab_a = setup_tab_for_prefix(head_prefix_a, versions: { "stable" => "1.0" })
setup_tab_for_prefix(head_prefix_b)
- initial_env = ENV.to_hash
testball_repo = HOMEBREW_PREFIX.join("testball_repo")
testball_repo.mkdir
@@ -1104,12 +1117,6 @@ class OutdatedVersionsTests < Homebrew::TestCase
head "file://#{testball_repo}", using: :git
end
- %w[AUTHOR COMMITTER].each do |role|
- ENV["GIT_#{role}_NAME"] = "brew tests"
- ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost"
- ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100"
- end
-
testball_repo.cd do
FileUtils.touch "LICENSE"
shutup do
@@ -1134,13 +1141,7 @@ class OutdatedVersionsTests < Homebrew::TestCase
reset_outdated_kegs
assert_predicate f.outdated_kegs(fetch_head: true), :empty?
ensure
- ENV.replace(initial_env)
testball_repo.rmtree if testball_repo.exist?
- outdated_stable_prefix.rmtree if outdated_stable_prefix.exist?
- head_prefix_b.rmtree if head_prefix.exist?
- head_prefix_c.rmtree if head_prefix_c.exist?
- FileUtils.rm_rf HOMEBREW_CACHE/"testball--git"
- FileUtils.rm_rf HOMEBREW_CELLAR/"testball"
end
def test_outdated_kegs_version_scheme_changed
@@ -1154,8 +1155,6 @@ class OutdatedVersionsTests < Homebrew::TestCase
setup_tab_for_prefix(prefix, versions: { "stable" => "0.1" })
refute_predicate f.outdated_kegs, :empty?
- ensure
- prefix.rmtree
end
def test_outdated_kegs_mixed_version_schemes
@@ -1183,8 +1182,6 @@ class OutdatedVersionsTests < Homebrew::TestCase
prefix_d = HOMEBREW_CELLAR.join("testball/20141011")
setup_tab_for_prefix(prefix_d, versions: { "stable" => "20141009", "version_scheme" => 3 })
assert_predicate f.outdated_kegs, :empty?
- ensure
- f.rack.rmtree
end
def test_outdated_kegs_head_with_version_scheme
@@ -1204,7 +1201,5 @@ class OutdatedVersionsTests < Homebrew::TestCase
setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0", "version_scheme" => 2 })
assert_predicate f.outdated_kegs, :empty?
- ensure
- head_prefix.rmtree
end
end
diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb
index 3d88c8407..ea7ecf8d0 100644
--- a/Library/Homebrew/test/formulary_test.rb
+++ b/Library/Homebrew/test/formulary_test.rb
@@ -16,6 +16,7 @@ end
class FormularyFactoryTest < Homebrew::TestCase
def setup
+ super
@name = "testball_bottle"
@path = CoreTap.new.formula_dir/"#{@name}.rb"
@bottle_dir = Pathname.new("#{TEST_FIXTURE_DIR}/bottles")
@@ -39,10 +40,6 @@ class FormularyFactoryTest < Homebrew::TestCase
EOS
end
- def teardown
- @path.unlink
- end
-
def test_factory
assert_kind_of Formula, Formulary.factory(@name)
end
@@ -61,8 +58,6 @@ class FormularyFactoryTest < Homebrew::TestCase
path.write "class Wrong#{Formulary.class_s(name)} < Formula\nend\n"
assert_raises(FormulaClassUnavailableError) { Formulary.factory(name) }
- ensure
- path.unlink
end
def test_factory_from_path
@@ -90,8 +85,6 @@ class FormularyFactoryTest < Homebrew::TestCase
result = Formulary.factory("foo")
assert_kind_of Formula, result
assert_equal alias_path.to_s, result.alias_path
- ensure
- alias_dir.rmtree
end
def test_factory_from_rack_and_from_keg
@@ -107,9 +100,6 @@ class FormularyFactoryTest < Homebrew::TestCase
assert_kind_of Tab, f.build
ensure
keg.unlink
- keg.uninstall
- formula.clear_cache
- formula.bottle.clear_cache
end
def test_load_from_contents
@@ -121,13 +111,12 @@ class FormularyFactoryTest < Homebrew::TestCase
(HOMEBREW_CELLAR/@name).mkpath
assert_equal HOMEBREW_CELLAR/@name, Formulary.to_rack(@name)
assert_raises(TapFormulaUnavailableError) { Formulary.to_rack("a/b/#{@name}") }
- ensure
- FileUtils.rm_rf HOMEBREW_CELLAR/@name
end
end
class FormularyTapFactoryTest < Homebrew::TestCase
def setup
+ super
@name = "foo"
@tap = Tap.new "homebrew", "foo"
@path = @tap.path/"#{@name}.rb"
@@ -139,10 +128,6 @@ class FormularyTapFactoryTest < Homebrew::TestCase
@path.write @code
end
- def teardown
- @tap.path.rmtree
- end
-
def test_factory_tap_formula
assert_kind_of Formula, Formulary.factory(@name)
end
@@ -173,6 +158,7 @@ end
class FormularyTapPriorityTest < Homebrew::TestCase
def setup
+ super
@name = "foo"
@core_path = CoreTap.new.formula_dir/"#{@name}.rb"
@tap = Tap.new "homebrew", "foo"
@@ -186,11 +172,6 @@ class FormularyTapPriorityTest < Homebrew::TestCase
@tap_path.write code
end
- def teardown
- @core_path.unlink
- @tap.path.rmtree
- end
-
def test_find_with_priority_core_formula
formula = Formulary.find_with_priority(@name)
assert_kind_of Formula, formula
diff --git a/Library/Homebrew/test/gpg2_requirement_test.rb b/Library/Homebrew/test/gpg2_requirement_test.rb
index fa7fc9ea4..3297c2851 100644
--- a/Library/Homebrew/test/gpg2_requirement_test.rb
+++ b/Library/Homebrew/test/gpg2_requirement_test.rb
@@ -4,6 +4,7 @@ require "fileutils"
class GPG2RequirementTests < Homebrew::TestCase
def setup
+ super
@dir = Pathname.new(mktmpdir)
(@dir/"bin/gpg").write <<-EOS.undent
#!/bin/bash
@@ -14,11 +15,11 @@ class GPG2RequirementTests < Homebrew::TestCase
def teardown
FileUtils.rm_rf @dir
+ super
end
def test_satisfied
- with_environment("PATH" => @dir/"bin") do
- assert_predicate GPG2Requirement.new, :satisfied?
- end
+ ENV["PATH"] = @dir/"bin"
+ assert_predicate GPG2Requirement.new, :satisfied?
end
end
diff --git a/Library/Homebrew/test/gpg_test.rb b/Library/Homebrew/test/gpg_test.rb
index 0374bdab4..ea4372549 100644
--- a/Library/Homebrew/test/gpg_test.rb
+++ b/Library/Homebrew/test/gpg_test.rb
@@ -3,18 +3,16 @@ require "gpg"
class GpgTest < Homebrew::TestCase
def setup
+ super
skip "GPG Unavailable" unless Gpg.available?
@dir = Pathname.new(mktmpdir)
end
def test_create_test_key
Dir.chdir(@dir) do
- with_environment("HOME" => @dir) do
- shutup { Gpg.create_test_key(@dir) }
- assert_predicate @dir/".gnupg/secring.gpg", :exist?
- end
+ ENV["HOME"] = @dir
+ shutup { Gpg.create_test_key(@dir) }
+ assert_predicate @dir/".gnupg/secring.gpg", :exist?
end
- ensure
- @dir.rmtree
end
end
diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb
index e047c0030..da6c1863f 100644
--- a/Library/Homebrew/test/install_test.rb
+++ b/Library/Homebrew/test/install_test.rb
@@ -73,13 +73,6 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase
end
def test_install_head_installed
- initial_env = ENV.to_hash
- %w[AUTHOR COMMITTER].each do |role|
- ENV["GIT_#{role}_NAME"] = "brew tests"
- ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost"
- ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100"
- end
-
repo_path = HOMEBREW_CACHE.join("repo")
repo_path.join("bin").mkpath
@@ -105,15 +98,11 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase
# Ignore dependencies, because we'll try to resolve requirements in build.rb
# and there will be the git requirement, but we cannot instantiate git
# formula since we only have testball1 formula.
- assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-2ccdf4f", cmd("install", "testball1", "--HEAD", "--ignore-dependencies")
- assert_match "testball1-HEAD-2ccdf4f already installed",
+ assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689", cmd("install", "testball1", "--HEAD", "--ignore-dependencies")
+ assert_match "testball1-HEAD-d5eb689 already installed",
cmd("install", "testball1", "--HEAD", "--ignore-dependencies")
- assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-2ccdf4f", cmd("unlink", "testball1")
+ assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689", cmd("unlink", "testball1")
assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1")
-
- ensure
- ENV.replace(initial_env)
- repo_path.rmtree
end
def test_install_with_invalid_option
diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb
index 40b47b5e9..bd4232038 100644
--- a/Library/Homebrew/test/keg_test.rb
+++ b/Library/Homebrew/test/keg_test.rb
@@ -20,6 +20,8 @@ class LinkTestCase < Homebrew::TestCase
end
def setup
+ super
+
@keg = setup_test_keg("foo", "1.0")
@dst = HOMEBREW_PREFIX.join("bin", "helloworld")
@nonexistent = Pathname.new("/some/nonexistent/path")
@@ -34,15 +36,10 @@ class LinkTestCase < Homebrew::TestCase
end
def teardown
- @kegs.each do |keg|
- keg.unlink
- keg.uninstall
- end
-
+ @kegs.each(&:unlink)
$stdout = @old_stdout
-
- rmtree HOMEBREW_PREFIX/"bin"
rmtree HOMEBREW_PREFIX/"lib"
+ super
end
end
@@ -301,8 +298,6 @@ class LinkTests < LinkTestCase
assert_equal 2, lib.children.length
ensure
a.unlink
- a.uninstall
- b.uninstall
end
def test_removes_broken_symlinks_that_conflict_with_directories
@@ -318,7 +313,6 @@ class LinkTests < LinkTestCase
keg.link
ensure
keg.unlink
- keg.uninstall
end
end
@@ -430,9 +424,6 @@ class InstalledDependantsTests < LinkTestCase
result = Keg.find_some_installed_dependents([renamed_keg])
assert_equal [[renamed_keg], ["bar"]], result
- ensure
- # Move it back to where it was so it'll be cleaned up.
- (HOMEBREW_CELLAR/"foo-old").rename(HOMEBREW_CELLAR/"foo")
end
def test_empty_dependencies_in_tab
diff --git a/Library/Homebrew/test/language_python_test.rb b/Library/Homebrew/test/language_python_test.rb
index d1e3867f7..aa0a7d51d 100644
--- a/Library/Homebrew/test/language_python_test.rb
+++ b/Library/Homebrew/test/language_python_test.rb
@@ -4,6 +4,7 @@ require "resource"
class LanguagePythonTests < Homebrew::TestCase
def setup
+ super
@dir = Pathname.new(mktmpdir)
resource = stub("resource", stage: true)
formula_bin = @dir/"formula_bin"
@@ -14,10 +15,6 @@ class LanguagePythonTests < Homebrew::TestCase
@venv = Language::Python::Virtualenv::Virtualenv.new(@formula, @dir, "python")
end
- def teardown
- FileUtils.rm_rf @dir
- end
-
def test_virtualenv_creation
@formula.expects(:resource).with("homebrew-virtualenv").returns(
mock("resource", stage: true)
diff --git a/Library/Homebrew/test/migrator_test.rb b/Library/Homebrew/test/migrator_test.rb
index 8a2b6ad63..012ea12bb 100644
--- a/Library/Homebrew/test/migrator_test.rb
+++ b/Library/Homebrew/test/migrator_test.rb
@@ -10,6 +10,7 @@ end
class MigratorErrorsTests < Homebrew::TestCase
def setup
+ super
@new_f = Testball.new("newname")
@new_f.oldname = "oldname"
@old_f = Testball.new("oldname")
@@ -31,8 +32,6 @@ class MigratorErrorsTests < Homebrew::TestCase
tab.source["tap"] = "homebrew/core"
tab.write
assert_raises(Migrator::MigratorDifferentTapsError) { Migrator.new(@new_f) }
- ensure
- keg.parent.rmtree
end
end
@@ -40,6 +39,8 @@ class MigratorTests < Homebrew::TestCase
include FileUtils
def setup
+ super
+
@new_f = Testball.new("newname")
@new_f.oldname = "oldname"
@@ -69,30 +70,16 @@ class MigratorTests < Homebrew::TestCase
end
def teardown
- @old_pin.unlink if @old_pin.symlink?
-
- if @old_keg_record.parent.symlink?
- @old_keg_record.parent.unlink
- elsif @old_keg_record.directory?
+ if !@old_keg_record.parent.symlink? && @old_keg_record.directory?
@keg.unlink
- @keg.uninstall
end
if @new_keg_record.directory?
new_keg = Keg.new(@new_keg_record)
new_keg.unlink
- new_keg.uninstall
end
- @old_keg_record.parent.rmtree if @old_keg_record.parent.directory?
- @new_keg_record.parent.rmtree if @new_keg_record.parent.directory?
-
- rmtree HOMEBREW_PREFIX/"bin"
- rmtree HOMEBREW_PREFIX/"opt" if (HOMEBREW_PREFIX/"opt").directory?
- # What to do with pin?
- @new_f.unpin
-
- HOMEBREW_LOCK_DIR.children.each(&:unlink)
+ super
end
def test_move_cellar
diff --git a/Library/Homebrew/test/options_test.rb b/Library/Homebrew/test/options_test.rb
index e7189a604..09ea14180 100644
--- a/Library/Homebrew/test/options_test.rb
+++ b/Library/Homebrew/test/options_test.rb
@@ -9,12 +9,13 @@ class IntegrationCommandTestOptions < IntegrationCommandTestCase
EOS
assert_equal "--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support",
- cmd_output("options", "testball").chomp
+ cmd("options", "testball").chomp
end
end
class OptionTests < Homebrew::TestCase
def setup
+ super
@option = Option.new("foo")
end
@@ -43,6 +44,7 @@ end
class DeprecatedOptionTests < Homebrew::TestCase
def setup
+ super
@deprecated_option = DeprecatedOption.new("foo", "bar")
end
@@ -68,6 +70,7 @@ end
class OptionsTests < Homebrew::TestCase
def setup
+ super
@options = Options.new
end
diff --git a/Library/Homebrew/test/os/mac/bottle_collector_test.rb b/Library/Homebrew/test/os/mac/bottle_collector_test.rb
index 2f88050ae..e9ae9b753 100644
--- a/Library/Homebrew/test/os/mac/bottle_collector_test.rb
+++ b/Library/Homebrew/test/os/mac/bottle_collector_test.rb
@@ -3,6 +3,7 @@ require "utils/bottles"
class OSMacBottleCollectorTests < Homebrew::TestCase
def setup
+ super
@collector = Utils::Bottles::Collector.new
end
diff --git a/Library/Homebrew/test/os/mac/dependency_collector_test.rb b/Library/Homebrew/test/os/mac/dependency_collector_test.rb
index 4fdf3ebe4..1033df9ab 100644
--- a/Library/Homebrew/test/os/mac/dependency_collector_test.rb
+++ b/Library/Homebrew/test/os/mac/dependency_collector_test.rb
@@ -7,11 +7,13 @@ class OSMacDependencyCollectorTests < Homebrew::TestCase
end
def setup
+ super
@d = DependencyCollector.new
end
def teardown
DependencyCollector.clear_cache
+ super
end
def test_tar_needs_xz_dependency
diff --git a/Library/Homebrew/test/os/mac/diagnostic_test.rb b/Library/Homebrew/test/os/mac/diagnostic_test.rb
index 655aa1d46..704235b01 100644
--- a/Library/Homebrew/test/os/mac/diagnostic_test.rb
+++ b/Library/Homebrew/test/os/mac/diagnostic_test.rb
@@ -5,14 +5,10 @@ require "diagnostic"
class OSMacDiagnosticChecksTest < Homebrew::TestCase
def setup
- @env = ENV.to_hash
+ super
@checks = Homebrew::Diagnostic::Checks.new
end
- def teardown
- ENV.replace(@env)
- end
-
def test_check_for_other_package_managers
MacOS.stubs(:macports_or_fink).returns ["fink"]
assert_match "You have MacPorts or Fink installed:",
@@ -20,7 +16,7 @@ class OSMacDiagnosticChecksTest < Homebrew::TestCase
end
def test_check_for_unsupported_macos
- ARGV.stubs(:homebrew_developer?).returns false
+ ENV.delete("HOMEBREW_DEVELOPER")
OS::Mac.stubs(:prerelease?).returns true
assert_match "We do not provide support for this pre-release version.",
@checks.check_for_unsupported_macos
diff --git a/Library/Homebrew/test/os/mac/keg_test.rb b/Library/Homebrew/test/os/mac/keg_test.rb
index e79cbc921..d1103415d 100644
--- a/Library/Homebrew/test/os/mac/keg_test.rb
+++ b/Library/Homebrew/test/os/mac/keg_test.rb
@@ -6,6 +6,8 @@ class OSMacLinkTests < Homebrew::TestCase
include FileUtils
def setup
+ super
+
keg = HOMEBREW_CELLAR.join("foo", "1.0")
keg.join("bin").mkpath
@@ -28,12 +30,12 @@ class OSMacLinkTests < Homebrew::TestCase
def teardown
@keg.unlink
- @keg.uninstall
$stdout = @old_stdout
- rmtree HOMEBREW_PREFIX/"bin"
rmtree HOMEBREW_PREFIX/"lib"
+
+ super
end
def test_mach_o_files_skips_hardlinks
@@ -48,7 +50,6 @@ class OSMacLinkTests < Homebrew::TestCase
assert_equal 1, keg.mach_o_files.size
ensure
keg.unlink
- keg.uninstall
end
def test_mach_o_files_isnt_confused_by_symlinks
@@ -64,6 +65,5 @@ class OSMacLinkTests < Homebrew::TestCase
assert_equal 1, keg.mach_o_files.size
ensure
keg.unlink
- keg.uninstall
end
end
diff --git a/Library/Homebrew/test/os/mac/mach_test.rb b/Library/Homebrew/test/os/mac/mach_test.rb
index a42f7316b..ed0424be6 100644
--- a/Library/Homebrew/test/os/mac/mach_test.rb
+++ b/Library/Homebrew/test/os/mac/mach_test.rb
@@ -109,6 +109,7 @@ end
class ArchitectureListExtensionTests < MachOPathnameTests
def setup
+ super
@archs = [:i386, :x86_64, :ppc7400, :ppc64].extend(ArchitectureListExtension)
end
@@ -157,11 +158,13 @@ class TextExecutableTests < Homebrew::TestCase
attr_reader :pn
def setup
+ super
@pn = HOMEBREW_PREFIX.join("an_executable")
end
def teardown
HOMEBREW_PREFIX.join("an_executable").unlink
+ super
end
def test_simple_shebang
diff --git a/Library/Homebrew/test/os/mac/version_test.rb b/Library/Homebrew/test/os/mac/version_test.rb
index f702c7097..ba4217691 100644
--- a/Library/Homebrew/test/os/mac/version_test.rb
+++ b/Library/Homebrew/test/os/mac/version_test.rb
@@ -4,6 +4,7 @@ require "os/mac/version"
class OSMacVersionTests < Homebrew::TestCase
def setup
+ super
@v = MacOS::Version.new("10.7")
end
diff --git a/Library/Homebrew/test/patch_test.rb b/Library/Homebrew/test/patch_test.rb
index 62624720e..f5a61398a 100644
--- a/Library/Homebrew/test/patch_test.rb
+++ b/Library/Homebrew/test/patch_test.rb
@@ -111,6 +111,7 @@ end
class ExternalPatchTests < Homebrew::TestCase
def setup
+ super
@p = ExternalPatch.new(:p1) { url "file:///my.patch" }
end
diff --git a/Library/Homebrew/test/patching_test.rb b/Library/Homebrew/test/patching_test.rb
index ac14c8e1e..3dacc0818 100644
--- a/Library/Homebrew/test/patching_test.rb
+++ b/Library/Homebrew/test/patching_test.rb
@@ -20,11 +20,6 @@ class PatchingTests < Homebrew::TestCase
end
end
- def teardown
- @_f.clear_cache
- @_f.patchlist.each { |p| p.clear_cache if p.external? }
- end
-
def assert_patched(formula)
shutup do
formula.brew do
diff --git a/Library/Homebrew/test/pathname_test.rb b/Library/Homebrew/test/pathname_test.rb
index 2f6360719..b48a26fbd 100644
--- a/Library/Homebrew/test/pathname_test.rb
+++ b/Library/Homebrew/test/pathname_test.rb
@@ -7,16 +7,12 @@ module PathnameTestExtension
include FileUtils
def setup
+ super
@src = Pathname.new(mktmpdir)
@dst = Pathname.new(mktmpdir)
@file = @src/"foo"
@dir = @src/"bar"
end
-
- def teardown
- rmtree(@src)
- rmtree(@dst)
- end
end
class PathnameTests < Homebrew::TestCase
diff --git a/Library/Homebrew/test/reinstall_test.rb b/Library/Homebrew/test/reinstall_test.rb
index 613c06188..2906983c3 100644
--- a/Library/Homebrew/test/reinstall_test.rb
+++ b/Library/Homebrew/test/reinstall_test.rb
@@ -12,4 +12,13 @@ class IntegrationCommandTestReinstall < IntegrationCommandTestCase
cmd("reinstall", "testball")
assert foo_dir.exist?
end
+
+ def test_reinstall_with_invalid_option
+ setup_test_formula "testball"
+
+ cmd("install", "testball", "--with-foo")
+
+ assert_match "testball: this formula has no --with-fo option so it will be ignored!",
+ cmd("reinstall", "testball", "--with-fo")
+ end
end
diff --git a/Library/Homebrew/test/resource_test.rb b/Library/Homebrew/test/resource_test.rb
index c1b526cb2..d982a7c33 100644
--- a/Library/Homebrew/test/resource_test.rb
+++ b/Library/Homebrew/test/resource_test.rb
@@ -3,6 +3,7 @@ require "resource"
class ResourceTests < Homebrew::TestCase
def setup
+ super
@resource = Resource.new("test")
end
diff --git a/Library/Homebrew/test/sandbox_test.rb b/Library/Homebrew/test/sandbox_test.rb
index 2a062cb10..a633defce 100644
--- a/Library/Homebrew/test/sandbox_test.rb
+++ b/Library/Homebrew/test/sandbox_test.rb
@@ -3,26 +3,23 @@ require "sandbox"
class SandboxTest < Homebrew::TestCase
def setup
+ super
skip "sandbox not implemented" unless Sandbox.available?
@sandbox = Sandbox.new
@dir = Pathname.new(mktmpdir)
@file = @dir/"foo"
end
- def teardown
- @dir.rmtree
- end
-
def test_formula?
f = formula { url "foo-1.0" }
f2 = formula { url "bar-1.0" }
f2.stubs(:tap).returns(Tap.fetch("test/tap"))
- ARGV.stubs(:sandbox?).returns true
+ ENV["HOMEBREW_SANDBOX"] = "1"
assert Sandbox.formula?(f),
"Formulae should be sandboxed if --sandbox was passed."
- ARGV.stubs(:sandbox?).returns false
+ ENV.delete("HOMEBREW_SANDBOX")
assert Sandbox.formula?(f),
"Formulae should be sandboxed if in a sandboxed tap."
refute Sandbox.formula?(f2),
@@ -30,7 +27,7 @@ class SandboxTest < Homebrew::TestCase
end
def test_test?
- ARGV.stubs(:no_sandbox?).returns false
+ ENV.delete("HOMEBREW_NO_SANDBOX")
assert Sandbox.test?,
"Tests should be sandboxed unless --no-sandbox was passed."
end
@@ -50,7 +47,7 @@ class SandboxTest < Homebrew::TestCase
def test_complains_on_failure
Utils.expects(popen_read: "foo")
- ARGV.stubs(verbose?: true)
+ ENV["HOMEBREW_VERBOSE"] = "1"
out, _err = capture_io do
assert_raises(ErrorDuringExecution) { @sandbox.exec "false" }
end
@@ -64,7 +61,7 @@ class SandboxTest < Homebrew::TestCase
bar
EOS
Utils.expects(popen_read: with_bogus_error)
- ARGV.stubs(verbose?: true)
+ ENV["HOMEBREW_VERBOSE"] = "1"
out, _err = capture_io do
assert_raises(ErrorDuringExecution) { @sandbox.exec "false" }
end
diff --git a/Library/Homebrew/test/shell_test.rb b/Library/Homebrew/test/shell_test.rb
index 877acb5c8..a04ab8331 100644
--- a/Library/Homebrew/test/shell_test.rb
+++ b/Library/Homebrew/test/shell_test.rb
@@ -14,9 +14,9 @@ class ShellSmokeTest < Homebrew::TestCase
end
def test_path_to_shell_failure
- assert_equal nil, Utils::Shell.path_to_shell("")
- assert_equal nil, Utils::Shell.path_to_shell("@@@@@@")
- assert_equal nil, Utils::Shell.path_to_shell("invalid_shell-4.2")
+ assert_nil Utils::Shell.path_to_shell("")
+ assert_nil Utils::Shell.path_to_shell("@@@@@@")
+ assert_nil Utils::Shell.path_to_shell("invalid_shell-4.2")
end
def test_sh_quote
@@ -37,7 +37,6 @@ class ShellSmokeTest < Homebrew::TestCase
end
def prepend_path_shell(shell, path, fragment)
- original_shell = ENV["SHELL"]
ENV["SHELL"] = shell
prepend_message = Utils::Shell.prepend_path_in_shell_profile(path)
@@ -45,8 +44,6 @@ class ShellSmokeTest < Homebrew::TestCase
prepend_message.start_with?(fragment),
"#{shell}: expected #{prepend_message} to match #{fragment}"
)
-
- ENV["SHELL"] = original_shell
end
def test_prepend_path_in_shell_profile
diff --git a/Library/Homebrew/test/software_spec_test.rb b/Library/Homebrew/test/software_spec_test.rb
index d9226f8c3..026265a4a 100644
--- a/Library/Homebrew/test/software_spec_test.rb
+++ b/Library/Homebrew/test/software_spec_test.rb
@@ -3,6 +3,7 @@ require "software_spec"
class SoftwareSpecTests < Homebrew::TestCase
def setup
+ super
@spec = SoftwareSpec.new
end
@@ -136,6 +137,7 @@ end
class HeadSoftwareSpecTests < Homebrew::TestCase
def setup
+ super
@spec = HeadSoftwareSpec.new
end
@@ -150,6 +152,7 @@ end
class BottleSpecificationTests < Homebrew::TestCase
def setup
+ super
@spec = BottleSpecification.new
end
diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb
new file mode 100644
index 000000000..7762b385c
--- /dev/null
+++ b/Library/Homebrew/test/spec_helper.rb
@@ -0,0 +1,77 @@
+require "find"
+require "pathname"
+require "rspec/its"
+require "rspec/wait"
+require "set"
+
+if ENV["HOMEBREW_TESTS_COVERAGE"]
+ require "simplecov"
+end
+
+$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew"))
+$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib"))
+
+require "global"
+require "tap"
+
+require "test/support/helper/shutup"
+
+TEST_DIRECTORIES = [
+ CoreTap.instance.path/"Formula",
+ HOMEBREW_CACHE,
+ HOMEBREW_CACHE_FORMULA,
+ HOMEBREW_CELLAR,
+ HOMEBREW_LOCK_DIR,
+ HOMEBREW_LOGS,
+ HOMEBREW_TEMP,
+].freeze
+
+RSpec.configure do |config|
+ config.order = :random
+ config.include(Test::Helper::Shutup)
+ config.around(:each) do |example|
+ begin
+ TEST_DIRECTORIES.each(&:mkpath)
+
+ @__files_before_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") }
+
+ @__argv = ARGV.dup
+ @__env = ENV.to_hash # dup doesn't work on ENV
+
+ example.run
+ ensure
+ ARGV.replace(@__argv)
+ ENV.replace(@__env)
+
+ Tab.clear_cache
+
+ FileUtils.rm_rf [
+ TEST_DIRECTORIES.map(&:children),
+ HOMEBREW_LINKED_KEGS,
+ HOMEBREW_PINNED_KEGS,
+ HOMEBREW_PREFIX/".git",
+ HOMEBREW_PREFIX/"bin",
+ HOMEBREW_PREFIX/"share",
+ HOMEBREW_PREFIX/"opt",
+ HOMEBREW_PREFIX/"Caskroom",
+ HOMEBREW_LIBRARY/"Taps/caskroom",
+ HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle",
+ HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo",
+ HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services",
+ HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow",
+ HOMEBREW_REPOSITORY/".git",
+ CoreTap.instance.path/".git",
+ CoreTap.instance.alias_dir,
+ CoreTap.instance.path/"formula_renames.json",
+ ]
+
+ files_after_test = Find.find(TEST_TMPDIR).map { |f| f.sub(TEST_TMPDIR, "") }
+
+ diff = Set.new(@__files_before_test).difference(Set.new(files_after_test))
+ expect(diff).to be_empty, <<-EOS.undent
+ file leak detected:
+ #{diff.map { |f| " #{f}" }.join("\n")}
+ EOS
+ end
+ end
+end
diff --git a/Library/Homebrew/test/stdlib_test.rb b/Library/Homebrew/test/stdlib_test.rb
index 3babfd58a..f193ae71e 100644
--- a/Library/Homebrew/test/stdlib_test.rb
+++ b/Library/Homebrew/test/stdlib_test.rb
@@ -4,6 +4,7 @@ require "cxxstdlib"
class CxxStdlibTests < Homebrew::TestCase
def setup
+ super
@clang = CxxStdlib.create(:libstdcxx, :clang)
@gcc = CxxStdlib.create(:libstdcxx, :gcc)
@gcc40 = CxxStdlib.create(:libstdcxx, :gcc_4_0)
diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-checkpoint-sha256-for-empty-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb
index f40f244f2..4e74d728d 100644
--- a/Library/Homebrew/cask/spec/support/Casks/appcast-checkpoint-sha256-for-empty-string.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-checkpoint-sha256-for-empty-string.rb
@@ -1,4 +1,4 @@
-test_cask 'appcast-checkpoint-sha256-for-empty-string' do
+cask 'appcast-checkpoint-sha256-for-empty-string' do
appcast 'http://localhost/appcast.xml',
checkpoint: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
end
diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-invalid-checkpoint.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb
index e182c2389..8b6934148 100644
--- a/Library/Homebrew/cask/spec/support/Casks/appcast-invalid-checkpoint.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-invalid-checkpoint.rb
@@ -1,4 +1,4 @@
-test_cask 'appcast-invalid-checkpoint' do
+cask 'appcast-invalid-checkpoint' do
appcast 'http://localhost/appcast.xml',
checkpoint: 'not a valid shasum'
end
diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-missing-checkpoint.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb
index 5ab2c0665..fefdbcb3a 100644
--- a/Library/Homebrew/cask/spec/support/Casks/appcast-missing-checkpoint.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-missing-checkpoint.rb
@@ -1,3 +1,3 @@
-test_cask 'appcast-missing-checkpoint' do
+cask 'appcast-missing-checkpoint' do
appcast 'http://localhost/appcast.xml'
end
diff --git a/Library/Homebrew/cask/spec/support/Casks/appcast-valid-checkpoint.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb
index 96d7edbba..84c9ca512 100644
--- a/Library/Homebrew/cask/spec/support/Casks/appcast-valid-checkpoint.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appcast-valid-checkpoint.rb
@@ -1,4 +1,4 @@
-test_cask 'appcast-valid-checkpoint' do
+cask 'appcast-valid-checkpoint' do
appcast 'http://localhost/appcast.xml',
checkpoint: 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2'
end
diff --git a/Library/Homebrew/cask/test/support/Casks/appdir-interpolation.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb
index fdc09ef5a..e4b3e79e6 100644
--- a/Library/Homebrew/cask/test/support/Casks/appdir-interpolation.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/appdir-interpolation.rb
@@ -1,4 +1,4 @@
-test_cask 'appdir-interpolation' do
+cask 'appdir-interpolation' do
version '2.61'
sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68'
diff --git a/Library/Homebrew/cask/test/support/Casks/auto-updates.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb
index 0fcdb991a..1cada2561 100644
--- a/Library/Homebrew/cask/test/support/Casks/auto-updates.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/auto-updates.rb
@@ -1,4 +1,4 @@
-test_cask 'auto-updates' do
+cask 'auto-updates' do
version '2.61'
sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68'
diff --git a/Library/Homebrew/cask/test/support/Casks/bad-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb
index 79e5f24c9..254ee59fd 100644
--- a/Library/Homebrew/cask/test/support/Casks/bad-checksum.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/bad-checksum.rb
@@ -1,4 +1,4 @@
-test_cask 'bad-checksum' do
+cask 'bad-checksum' do
version '1.2.3'
sha256 'badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb'
diff --git a/Library/Homebrew/cask/test/support/Casks/basic-cask.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb
index d3aaa283e..ff1d90003 100644
--- a/Library/Homebrew/cask/test/support/Casks/basic-cask.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/basic-cask.rb
@@ -1,4 +1,4 @@
-test_cask 'basic-cask' do
+cask 'basic-cask' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/spec/support/Casks/booby-trap.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/booby-trap.rb
index 21bd97952..21bd97952 100644
--- a/Library/Homebrew/cask/spec/support/Casks/booby-trap.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/booby-trap.rb
diff --git a/Library/Homebrew/cask/test/support/Casks/container-7z.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb
index 7dd01eee4..5b043a75e 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-7z.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-7z.rb
@@ -1,4 +1,4 @@
-test_cask 'container-7z' do
+cask 'container-7z' do
version '1.2.3'
sha256 '3f9542ace85ed5f88549e2d0ea82210f8ddc87e0defbb78469d3aed719b3c964'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-air.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb
index c310e0a6f..5aaf3d53e 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-air.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-air.rb
@@ -1,4 +1,4 @@
-test_cask 'container-air' do
+cask 'container-air' do
version '0.1'
sha256 '554472e163f8a028629b12b468e29acda9f16b223dff74fcd218bba73cc2365a'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-bzip2.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb
index 9d9bdff98..60f834b7f 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-bzip2.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-bzip2.rb
@@ -1,4 +1,4 @@
-test_cask 'container-bzip2' do
+cask 'container-bzip2' do
version '1.2.3'
sha256 'eaf67b3a62cb9275f96e45d05c70b94bef9ef1dae344083e93eda6b0b388a61c'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-cab.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb
index ebc7a544e..e57131567 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-cab.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-cab.rb
@@ -1,4 +1,4 @@
-test_cask 'container-cab' do
+cask 'container-cab' do
version '1.2.3'
sha256 'c267f5cebb14814c8e612a8b7d2bda02aec913f869509b6f1d3883427c0f552b'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-dmg.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb
index d63596f42..e9974b5d2 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-dmg.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-dmg.rb
@@ -1,4 +1,4 @@
-test_cask 'container-dmg' do
+cask 'container-dmg' do
version '1.2.3'
sha256 '74d89d4fa5cef175cf43666ce11fefa3741aa1522114042ac75e656be37141a1'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-gzip.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb
index c2ab00384..0bfc4108f 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-gzip.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-gzip.rb
@@ -1,4 +1,4 @@
-test_cask 'container-gzip' do
+cask 'container-gzip' do
version '1.2.3'
sha256 'fa4ebb5246583c4b6e62e1df4e3b71b4e38a1d7d91c025665827195d36214b20'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-lzma.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb
index d5f708523..92d2c253e 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-lzma.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-lzma.rb
@@ -1,4 +1,4 @@
-test_cask 'container-lzma' do
+cask 'container-lzma' do
version '1.2.3'
sha256 '9d7edb32d02ab9bd9749a5bde8756595ea4cfcb1da02ca11c30fb591d4c1ed85'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-pkg.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb
index 959caaa08..2ff4cca1e 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-pkg.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-pkg.rb
@@ -1,4 +1,4 @@
-test_cask 'container-pkg' do
+cask 'container-pkg' do
version '1.2.3'
sha256 '611c50c8a2a2098951d2cd0fd54787ed81b92cd97b4b08bd7cba17f1e1d8e40b'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-rar.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb
index 7186577a2..33ea670d1 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-rar.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-rar.rb
@@ -1,4 +1,4 @@
-test_cask 'container-rar' do
+cask 'container-rar' do
version '1.2.3'
sha256 '419af7864c0e1f125515c49b08bd22e0f7de39f5285897c440fe03c714871763'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-sit.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb
index 3a0faad97..5715795a7 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-sit.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-sit.rb
@@ -1,4 +1,4 @@
-test_cask 'container-sit' do
+cask 'container-sit' do
version '1.2.3'
sha256 '0d21a64dce625044345c8ecca888e5439feaf254dac7f884917028a744f93cf3'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-tar-gz.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb
index 58e1d82fd..e32931c89 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-tar-gz.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-tar-gz.rb
@@ -1,4 +1,4 @@
-test_cask 'container-tar-gz' do
+cask 'container-tar-gz' do
version '1.2.3'
sha256 'fab685fabf73d5a9382581ce8698fce9408f5feaa49fa10d9bc6c510493300f5'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-xar.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb
index 35e01d0a8..82a751d5d 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-xar.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xar.rb
@@ -1,4 +1,4 @@
-test_cask 'container-xar' do
+cask 'container-xar' do
version '1.2.3'
sha256 '5bb8e09a6fc630ebeaf266b1fd2d15e2ae7d32d7e4da6668a8093426fa1ba509'
diff --git a/Library/Homebrew/cask/test/support/Casks/container-xz.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb
index b27e908ae..3f844af04 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-xz.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/container-xz.rb
@@ -1,4 +1,4 @@
-test_cask 'container-xz' do
+cask 'container-xz' do
version '1.2.3'
sha256 '839263f474edde1d54a9101606e6f0dc9d963acc93f6dcc5af8d10ebc3187c02'
diff --git a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-absolute-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb
index 475fb055f..a1844a9c9 100644
--- a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-absolute-target.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-absolute-target.rb
@@ -1,3 +1,3 @@
-test_cask 'generic-artifact-absolute-target' do
+cask 'generic-artifact-absolute-target' do
artifact 'Caffeine.app', target: "#{Hbc.appdir}/Caffeine.app"
end
diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb
new file mode 100644
index 000000000..a3e65caab
--- /dev/null
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-no-target.rb
@@ -0,0 +1,3 @@
+cask 'generic-artifact-no-target' do
+ artifact 'Caffeine.app'
+end
diff --git a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-relative-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb
index f97441751..eb521e35a 100644
--- a/Library/Homebrew/cask/spec/support/Casks/generic-artifact-relative-target.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/generic-artifact-relative-target.rb
@@ -1,3 +1,3 @@
-test_cask 'generic-artifact-relative-target' do
+cask 'generic-artifact-relative-target' do
artifact 'Caffeine.app', target: 'Caffeine.app'
end
diff --git a/Library/Homebrew/cask/spec/support/Casks/invalid-sha256.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb
index aac00f495..2804da7c3 100644
--- a/Library/Homebrew/cask/spec/support/Casks/invalid-sha256.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid-sha256.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-sha256' do
+cask 'invalid-sha256' do
version '1.2.3'
sha256 'not a valid shasum'
end
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-multiple.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb
index db2621074..37634f619 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-multiple.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-multiple.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-appcast-multiple' do
+cask 'invalid-appcast-multiple' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb
index b4c11b1be..7b51ffb53 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-appcast-url.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-appcast-url.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-appcast-url' do
+cask 'invalid-appcast-url' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-conflicts-with-key.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb
index d39d124b0..b066139ce 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-conflicts-with-key.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-conflicts-with-key.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-conflicts-with-key' do
+cask 'invalid-conflicts-with-key' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-arch-value.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb
index b0c919a9b..b21912a6e 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-arch-value.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-arch-value.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-depends-on-arch-value' do
+cask 'invalid-depends-on-arch-value' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-key.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb
index 05304e806..24a912893 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-key.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-key.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-depends-on-key' do
+cask 'invalid-depends-on-key' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-bad-release.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb
index 183dd5d91..723ceacbb 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-bad-release.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-depends-on-macos-bad-release' do
+cask 'invalid-depends-on-macos-bad-release' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb
index b1f763d76..689e24b67 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-depends-on-macos-conflicting-forms' do
+cask 'invalid-depends-on-macos-conflicting-forms' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-x11-value.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb
index eefd3ac40..5c3faec35 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-depends-on-x11-value.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-depends-on-x11-value.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-depends-on-x11-value' do
+cask 'invalid-depends-on-x11-value' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-conflicting-keys.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb
index bf14d372b..baf124b7a 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-conflicting-keys.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-conflicting-keys.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-gpg-conflicting-keys' do
+cask 'invalid-gpg-conflicting-keys' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-id.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb
index 626e02a47..386593b06 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-id.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-id.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-gpg-key-id' do
+cask 'invalid-gpg-key-id' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb
index 77d41ed6b..4108380d2 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-key-url.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-key-url.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-gpg-key-url' do
+cask 'invalid-gpg-key-url' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-missing-key.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb
index 460bcd532..3375801c9 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-missing-key.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-missing-key.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-gpg-missing-key' do
+cask 'invalid-gpg-missing-key' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-multiple-stanzas.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb
index 8abc89486..b420f74d5 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-multiple-stanzas.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-gpg-multiple-stanzas' do
+cask 'invalid-gpg-multiple-stanzas' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-parameter.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb
index f1abc9225..40f6a9dae 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-parameter.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-parameter.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-gpg-parameter' do
+cask 'invalid-gpg-parameter' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-signature-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb
index 1b9e7362f..43cc27b08 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-signature-url.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-signature-url.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-gpg-signature-url' do
+cask 'invalid-gpg-signature-url' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-type.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb
index 266047617..a369ef875 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-gpg-type.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-gpg-type.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-gpg-type' do
+cask 'invalid-gpg-type' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb
index a8159c979..c8c613767 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-format.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-format.rb
@@ -1,4 +1,4 @@
-test_cask => 'invalid-header-format' do
+cask => 'invalid-header-format' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb
new file mode 100644
index 000000000..af15a13ef
--- /dev/null
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-token-mismatch.rb
@@ -0,0 +1,9 @@
+cask 'invalid-header-token-mismatch-this-text-does-not-belong' do
+ version '1.2.3'
+ sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
+
+ url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
+ homepage 'http://example.com/local-caffeine'
+
+ app 'Caffeine.app'
+end
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb
index 47851c0e0..7e37e61df 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-header-version.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-header-version.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-header-version' do
+cask 'invalid-header-version' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-stage-only-conflict.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb
index 84510ac24..5a0ccadf6 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-stage-only-conflict.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-stage-only-conflict.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-stage-only-conflict' do
+cask 'invalid-stage-only-conflict' do
version '2.61'
sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-homepage.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb
index d4e5ff4a9..5170a9c0f 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-homepage.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-homepage.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-two-homepage' do
+cask 'invalid-two-homepage' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb
index 49e470788..f548400a4 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-url.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-url.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-two-url' do
+cask 'invalid-two-url' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb
index c9fe37772..fbffa8a1e 100644
--- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-two-version.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-version.rb
@@ -1,4 +1,4 @@
-test_cask 'invalid-two-version' do
+cask 'invalid-two-version' do
version '1.2.3'
version '2.0'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/local-caffeine.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb
index 2be9b4397..934d22463 100644
--- a/Library/Homebrew/cask/test/support/Casks/local-caffeine.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/local-caffeine.rb
@@ -1,4 +1,4 @@
-test_cask 'local-caffeine' do
+cask 'local-caffeine' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/local-transmission.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb
index f5244d0a5..6709ac12e 100644
--- a/Library/Homebrew/cask/test/support/Casks/local-transmission.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb
@@ -1,4 +1,4 @@
-test_cask 'local-transmission' do
+cask 'local-transmission' do
version '2.61'
sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68'
diff --git a/Library/Homebrew/cask/test/support/Casks/missing-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb
index 5e1886a57..907b1375f 100644
--- a/Library/Homebrew/cask/test/support/Casks/missing-checksum.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-checksum.rb
@@ -1,4 +1,4 @@
-test_cask 'missing-checksum' do
+cask 'missing-checksum' do
version '1.2.3'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-homepage.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb
index ff924541d..cf06d6c33 100644
--- a/Library/Homebrew/cask/spec/support/Casks/missing-homepage.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-homepage.rb
@@ -1,4 +1,4 @@
-test_cask 'missing-homepage' do
+cask 'missing-homepage' do
version '1.2.3'
url 'http://localhost/something.dmg'
diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-name.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb
index a5265b379..0801f4abb 100644
--- a/Library/Homebrew/cask/spec/support/Casks/missing-name.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-name.rb
@@ -1,4 +1,4 @@
-test_cask 'missing-name' do
+cask 'missing-name' do
version '1.2.3'
url 'http://localhost/something.dmg'
diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-sha256.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb
index 7f8027907..e6e6d9d20 100644
--- a/Library/Homebrew/cask/spec/support/Casks/missing-sha256.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-sha256.rb
@@ -1,4 +1,4 @@
-test_cask 'missing-sha256' do
+cask 'missing-sha256' do
version '1.2.3'
url 'http://localhost/something.dmg'
diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb
index 1b3e76b9c..0bfaec332 100644
--- a/Library/Homebrew/cask/spec/support/Casks/missing-url.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-url.rb
@@ -1,4 +1,4 @@
-test_cask 'missing-url' do
+cask 'missing-url' do
version '1.2.3'
homepage 'http://example.com'
diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb
index da2160bce..88e13d8bb 100644
--- a/Library/Homebrew/cask/spec/support/Casks/missing-version.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/missing-version.rb
@@ -1,4 +1,4 @@
-test_cask 'missing-version' do
+cask 'missing-version' do
url 'http://localhost/something.dmg'
homepage 'http://example.com'
end
diff --git a/Library/Homebrew/cask/test/support/Casks/naked-executable.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb
index 619c7a5fb..2f4e30dc1 100644
--- a/Library/Homebrew/cask/test/support/Casks/naked-executable.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/naked-executable.rb
@@ -1,4 +1,4 @@
-test_cask 'naked-executable' do
+cask 'naked-executable' do
version '1.2.3'
sha256 '306c6ca7407560340797866e077e053627ad409277d1b9da58106fce4cf717cb'
diff --git a/Library/Homebrew/cask/test/support/Casks/nested-app.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb
index 526c7414a..6061f7bff 100644
--- a/Library/Homebrew/cask/test/support/Casks/nested-app.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/nested-app.rb
@@ -1,4 +1,4 @@
-test_cask 'nested-app' do
+cask 'nested-app' do
version '1.2.3'
sha256 '1866dfa833b123bb8fe7fa7185ebf24d28d300d0643d75798bc23730af734216'
diff --git a/Library/Homebrew/cask/test/support/Casks/no-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb
index d9ba354f5..1e06c6168 100644
--- a/Library/Homebrew/cask/test/support/Casks/no-checksum.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/no-checksum.rb
@@ -1,4 +1,4 @@
-test_cask 'no-checksum' do
+cask 'no-checksum' do
version '1.2.3'
sha256 :no_check
diff --git a/Library/Homebrew/cask/test/support/Casks/no-dsl-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb
index ee557b1e4..3bafa171d 100644
--- a/Library/Homebrew/cask/test/support/Casks/no-dsl-version.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/no-dsl-version.rb
@@ -1,4 +1,4 @@
-test_cask 'no-dsl-version' do
+cask 'no-dsl-version' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/spec/support/Casks/osdn-correct-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb
index da6ff0fcd..7e60fc179 100644
--- a/Library/Homebrew/cask/spec/support/Casks/osdn-correct-url-format.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-correct-url-format.rb
@@ -1,4 +1,4 @@
-test_cask 'osdn-correct-url-format' do
+cask 'osdn-correct-url-format' do
version '1.2.3'
url 'http://user.dl.osdn.jp/something/id/Something-1.2.3.dmg'
diff --git a/Library/Homebrew/cask/spec/support/Casks/osdn-incorrect-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb
index 8400159a1..68b4ecd4c 100644
--- a/Library/Homebrew/cask/spec/support/Casks/osdn-incorrect-url-format.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/osdn-incorrect-url-format.rb
@@ -1,4 +1,4 @@
-test_cask 'osdn-incorrect-url-format' do
+cask 'osdn-incorrect-url-format' do
version '1.2.3'
url 'http://osdn.jp/projects/something/files/Something-1.2.3.dmg/download'
diff --git a/Library/Homebrew/cask/spec/support/Casks/sha256-for-empty-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb
index b97764071..0bf3ee9b5 100644
--- a/Library/Homebrew/cask/spec/support/Casks/sha256-for-empty-string.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sha256-for-empty-string.rb
@@ -1,4 +1,4 @@
-test_cask 'sha256-for-empty-string' do
+cask 'sha256-for-empty-string' do
version '1.2.3'
sha256 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
end
diff --git a/Library/Homebrew/cask/spec/support/Casks/sourceforge-correct-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb
index 41ef73500..439eb8998 100644
--- a/Library/Homebrew/cask/spec/support/Casks/sourceforge-correct-url-format.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-correct-url-format.rb
@@ -1,4 +1,4 @@
-test_cask 'sourceforge-correct-url-format' do
+cask 'sourceforge-correct-url-format' do
version '1.2.3'
url 'https://downloads.sourceforge.net/something/Something-1.2.3.dmg'
diff --git a/Library/Homebrew/cask/spec/support/Casks/sourceforge-incorrect-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb
index 27b5490b7..39ac52414 100644
--- a/Library/Homebrew/cask/spec/support/Casks/sourceforge-incorrect-url-format.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-incorrect-url-format.rb
@@ -1,4 +1,4 @@
-test_cask 'sourceforge-incorrect-url-format' do
+cask 'sourceforge-incorrect-url-format' do
version '1.2.3'
url 'http://sourceforge.net/projects/something/files/Something-1.2.3.dmg/download'
diff --git a/Library/Homebrew/cask/spec/support/Casks/sourceforge-version-latest-correct-url-format.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb
index d9546c5e1..07b068f70 100644
--- a/Library/Homebrew/cask/spec/support/Casks/sourceforge-version-latest-correct-url-format.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-version-latest-correct-url-format.rb
@@ -1,4 +1,4 @@
-test_cask 'sourceforge-version-latest-correct-url-format' do
+cask 'sourceforge-version-latest-correct-url-format' do
version :latest
url 'https://sourceforge.net/projects/something/files/latest/download'
diff --git a/Library/Homebrew/cask/test/support/Casks/stage-only.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb
index b52b5d3d2..941e2084f 100644
--- a/Library/Homebrew/cask/test/support/Casks/stage-only.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/stage-only.rb
@@ -1,4 +1,4 @@
-test_cask 'stage-only' do
+cask 'stage-only' do
version '2.61'
sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68'
diff --git a/Library/Homebrew/cask/test/support/Casks/test-opera-mail.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb
index afc8387c7..3e2c76e67 100644
--- a/Library/Homebrew/cask/test/support/Casks/test-opera-mail.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera-mail.rb
@@ -1,4 +1,4 @@
-test_cask 'test-opera-mail' do
+cask 'test-opera-mail' do
version '1.0'
sha256 'afd192e308f8ea8ddb3d426fd6663d97078570417ee78b8e1fa15f515ae3d677'
diff --git a/Library/Homebrew/cask/test/support/Casks/test-opera.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb
index ec32828f7..7ca0157d9 100644
--- a/Library/Homebrew/cask/test/support/Casks/test-opera.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/test-opera.rb
@@ -1,4 +1,4 @@
-test_cask 'test-opera' do
+cask 'test-opera' do
version '19.0.1326.47'
sha256 '7b91f20ab754f7b3fef8dc346e0393917e11676b74c8f577408841619f76040a'
diff --git a/Library/Homebrew/cask/spec/support/Casks/version-latest-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb
index 3b4723f45..6bd090c28 100644
--- a/Library/Homebrew/cask/spec/support/Casks/version-latest-string.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-string.rb
@@ -1,4 +1,4 @@
-test_cask 'version-latest-string' do
+cask 'version-latest-string' do
version 'latest'
sha256 :no_check
end
diff --git a/Library/Homebrew/cask/spec/support/Casks/version-latest-with-checksum.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb
index 884ddff90..040cfc76e 100644
--- a/Library/Homebrew/cask/spec/support/Casks/version-latest-with-checksum.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/version-latest-with-checksum.rb
@@ -1,4 +1,4 @@
-test_cask 'version-latest-with-checksum' do
+cask 'version-latest-with-checksum' do
version :latest
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
end
diff --git a/Library/Homebrew/cask/test/support/Casks/with-accessibility-access.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb
index 1aa7bc8f7..4c1c9897a 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-accessibility-access.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb
@@ -1,4 +1,4 @@
-test_cask 'with-accessibility-access' do
+cask 'with-accessibility-access' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-alt-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb
index b75ff320c..7a6d75a9c 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-alt-target.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-alt-target.rb
@@ -1,4 +1,4 @@
-test_cask 'with-alt-target' do
+cask 'with-alt-target' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-appcast.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb
index f99f7a93c..fc57e5e65 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-appcast.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-appcast.rb
@@ -1,4 +1,4 @@
-test_cask 'with-appcast' do
+cask 'with-appcast' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/spec/support/Casks/with-binary.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb
index d8cede7aa..38be2e772 100644
--- a/Library/Homebrew/cask/spec/support/Casks/with-binary.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-binary.rb
@@ -1,4 +1,4 @@
-test_cask 'with-binary' do
+cask 'with-binary' do
version '1.2.3'
sha256 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-caveats.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb
index 30d3a49b3..d5d90114a 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-caveats.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-caveats.rb
@@ -1,4 +1,4 @@
-test_cask 'with-caveats' do
+cask 'with-caveats' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-choices.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb
index 1871efab3..640a3bbb3 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-choices.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-choices.rb
@@ -1,4 +1,4 @@
-test_cask 'with-choices' do
+cask 'with-choices' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-conditional-caveats.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb
index d8a3836b8..e3c666834 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-conditional-caveats.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conditional-caveats.rb
@@ -1,4 +1,4 @@
-test_cask 'with-conditional-caveats' do
+cask 'with-conditional-caveats' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-conflicts-with.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb
index a20d932ba..ab3631743 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-conflicts-with.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-conflicts-with.rb
@@ -1,4 +1,4 @@
-test_cask 'with-conflicts-with' do
+cask 'with-conflicts-with' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb
index e0c4e3fa7..9fe0d043b 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-arch.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-arch' do
+cask 'with-depends-on-arch' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic-helper.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb
index 327fc4000..3a90295e5 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic-helper.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic-helper.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-cask-cyclic-helper' do
+cask 'with-depends-on-cask-cyclic-helper' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb
index f74d860bf..776351568 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-cyclic.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-cyclic.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-cask-cyclic' do
+cask 'with-depends-on-cask-cyclic' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-multiple.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb
index bb69b7506..74e1c2747 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask-multiple.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask-multiple.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-cask-multiple' do
+cask 'with-depends-on-cask-multiple' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb
index 05a180560..52daec865 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-cask.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-cask.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-cask' do
+cask 'with-depends-on-cask' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula-multiple.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb
index c99d2dee1..07d7bb86a 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula-multiple.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula-multiple.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-formula-multiple' do
+cask 'with-depends-on-formula-multiple' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb
index b0339e68c..ac980f890 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-formula.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-formula.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-formula' do
+cask 'with-depends-on-formula' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-array.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb
index cae16704c..7fb1a9016 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-array.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-array.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-macos-array' do
+cask 'with-depends-on-macos-array' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-comparison.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb
index 7f14dd84f..1483bcf74 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-comparison.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-comparison.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-macos-comparison' do
+cask 'with-depends-on-macos-comparison' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-failure.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb
index ecefff362..483d75814 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-failure.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-macos-failure' do
+cask 'with-depends-on-macos-failure' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-string.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb
index 6e370d46a..887771fe2 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-string.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-string.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-macos-string' do
+cask 'with-depends-on-macos-string' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-symbol.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb
index 7f11b6e64..e5aa05d23 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-macos-symbol.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-symbol.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-macos-symbol' do
+cask 'with-depends-on-macos-symbol' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11-false.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb
index fc84f2daa..d5107edc5 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11-false.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11-false.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-x11-false' do
+cask 'with-depends-on-x11-false' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb
index b1a7bad2b..bcb781637 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-x11.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-x11.rb
@@ -1,4 +1,4 @@
-test_cask 'with-depends-on-x11' do
+cask 'with-depends-on-x11' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-dsl-version.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb
index c16343c4b..15f0319c5 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-dsl-version.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-dsl-version.rb
@@ -1,4 +1,4 @@
-test_cask :v1 => 'with-dsl-version' do
+cask :v1 => 'with-dsl-version' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/spec/support/Casks/with-embedded-binary.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb
index 107c6cbe2..5987bbfe6 100644
--- a/Library/Homebrew/cask/spec/support/Casks/with-embedded-binary.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-embedded-binary.rb
@@ -1,4 +1,4 @@
-test_cask 'with-embedded-binary' do
+cask 'with-embedded-binary' do
version '1.2.3'
sha256 'fe052d3e77d92676775fd916ddb8942e72a565b844ea7f6d055474c99bb4e47b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact-no-target.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb
index a7d347fb5..f7f1ddc22 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact-no-target.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact-no-target.rb
@@ -1,4 +1,4 @@
-test_cask 'with-generic-artifact-no-target' do
+cask 'with-generic-artifact-no-target' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb
index e718b994b..d6ce0ce8d 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-generic-artifact.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-generic-artifact.rb
@@ -1,4 +1,4 @@
-test_cask 'with-generic-artifact' do
+cask 'with-generic-artifact' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-gpg-key-url.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb
index 6aa735e1f..fc0c9ddfc 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-gpg-key-url.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg-key-url.rb
@@ -1,4 +1,4 @@
-test_cask 'with-gpg-key-url' do
+cask 'with-gpg-key-url' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-gpg.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb
index 1f7042515..e07546b94 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-gpg.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-gpg.rb
@@ -1,4 +1,4 @@
-test_cask 'with-gpg' do
+cask 'with-gpg' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-installable.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb
index d1105b50e..b0ad0c626 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-installable.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb
@@ -1,4 +1,4 @@
-test_cask 'with-installable' do
+cask 'with-installable' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-installer-manual.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb
index 92e2e09df..a857b6900 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-installer-manual.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-manual.rb
@@ -1,4 +1,4 @@
-test_cask 'with-installer-manual' do
+cask 'with-installer-manual' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-installer-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb
index 5e98eab48..b32d131e0 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-installer-script.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installer-script.rb
@@ -1,4 +1,4 @@
-test_cask 'with-installer-script' do
+cask 'with-installer-script' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-macosx-dir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb
index 837627119..505e9f5a7 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-macosx-dir.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-macosx-dir.rb
@@ -1,4 +1,4 @@
-test_cask 'with-macosx-dir' do
+cask 'with-macosx-dir' do
version '1.2.3'
sha256 '5633c3a0f2e572cbf021507dec78c50998b398c343232bdfc7e26221d0a5db4d'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-pkgutil-zap.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb
index 8bb42c447..d86d47126 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-pkgutil-zap.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-pkgutil-zap.rb
@@ -1,4 +1,4 @@
-test_cask 'with-pkgutil-zap' do
+cask 'with-pkgutil-zap' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-suite.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb
index c36151d52..88158e10d 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-suite.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-suite.rb
@@ -1,4 +1,4 @@
-test_cask 'with-suite' do
+cask 'with-suite' do
version '1.2.3'
sha256 'd95dcc12d4e5be0bc3cb9793c4b7e7f69a25f0b3c7418494b0c883957e6eeae4'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-two-apps-correct.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb
index 8eb68d88a..3963d7790 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-two-apps-correct.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-correct.rb
@@ -1,4 +1,4 @@
-test_cask 'with-two-apps-correct' do
+cask 'with-two-apps-correct' do
version '1.2.3'
sha256 '3178fbfd1ea5d87a2a0662a4eb599ebc9a03888e73f37538d9f3f6ee69d2368e'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-two-apps-incorrect.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb
index 6bd316dfe..c3ca473bd 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-two-apps-incorrect.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-incorrect.rb
@@ -1,4 +1,4 @@
-test_cask 'with-two-apps-incorrect' do
+cask 'with-two-apps-incorrect' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-two-apps-subdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb
index 202423691..879e6e4ce 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-two-apps-subdir.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-two-apps-subdir.rb
@@ -1,4 +1,4 @@
-test_cask 'with-two-apps-subdir' do
+cask 'with-two-apps-subdir' do
version '1.2.3'
sha256 'd687c22a21c02bd8f07da9302c8292b93a04df9a929e3f04d09aea6c76f75c65'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-delete.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb
index 203f18405..cba51f18f 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-delete.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-delete' do
+cask 'with-uninstall-delete' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-early-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb
index a26abab1c..a9cec5b97 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-early-script.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-early-script.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-early-script' do
+cask 'with-uninstall-early-script' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-kext.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb
index fa54c7e1f..9b27a1f36 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-kext.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-kext.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-kext' do
+cask 'with-uninstall-kext' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-launchctl.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb
index 51ad45a09..e5aa2b2d7 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-launchctl.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-launchctl.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-launchctl' do
+cask 'with-uninstall-launchctl' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-login-item.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb
index 26dca6f1a..46f1f9704 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-login-item.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-login-item.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-login-item' do
+cask 'with-uninstall-login-item' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-pkgutil.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb
index db77a460b..00157322d 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-pkgutil.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-pkgutil.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-pkgutil' do
+cask 'with-uninstall-pkgutil' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-quit.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb
index 19337b18a..7f9515578 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-quit.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-quit.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-quit' do
+cask 'with-uninstall-quit' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-rmdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb
index 88142ea71..252d81994 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-rmdir.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-rmdir.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-rmdir' do
+cask 'with-uninstall-rmdir' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb
index d2e0d6167..3e2dd0bb9 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-script.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-script' do
+cask 'with-uninstall-script' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-signal.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb
index cc32b888a..850055c3c 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-signal.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-signal.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-signal' do
+cask 'with-uninstall-signal' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-uninstall-trash.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb
index 4fe58a19a..171780bb7 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-uninstall-trash.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb
@@ -1,4 +1,4 @@
-test_cask 'with-uninstall-trash' do
+cask 'with-uninstall-trash' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-delete.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb
index c76a9acb0..a0ab83fc2 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-delete.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-delete' do
+cask 'with-zap-delete' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-early-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb
index d35c1809e..9375d2cc7 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-early-script.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-early-script.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-early-script' do
+cask 'with-zap-early-script' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-kext.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb
index 463fe8133..e9c29f619 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-kext.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-kext.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-kext' do
+cask 'with-zap-kext' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-launchctl.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb
index aab285672..6d17ccfb0 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-launchctl.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-launchctl.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-launchctl' do
+cask 'with-zap-launchctl' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-login-item.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb
index d7ba9a65b..2715892ef 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-login-item.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-login-item.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-login-item' do
+cask 'with-zap-login-item' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-pkgutil.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb
index 17a667000..c7f08b76d 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-pkgutil.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-pkgutil.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-pkgutil' do
+cask 'with-zap-pkgutil' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-quit.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb
index 21f824ae9..4e4ab3a85 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-quit.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-quit.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-quit' do
+cask 'with-zap-quit' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-rmdir.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb
index eac02ad0e..02139b3b0 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-rmdir.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-rmdir.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-rmdir' do
+cask 'with-zap-rmdir' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-script.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb
index f8646a267..5e033301a 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-script.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-script.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-script' do
+cask 'with-zap-script' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-signal.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb
index 5accd8337..47870cf05 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-signal.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-signal.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-signal' do
+cask 'with-zap-signal' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap-trash.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb
index aef4e0eab..8f4e91d67 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap-trash.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap-trash' do
+cask 'with-zap-trash' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/cask/test/support/Casks/with-zap.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb
index 056c90671..275516fba 100644
--- a/Library/Homebrew/cask/test/support/Casks/with-zap.rb
+++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap.rb
@@ -1,4 +1,4 @@
-test_cask 'with-zap' do
+cask 'with-zap' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb
deleted file mode 100644
index 904a1d4c7..000000000
--- a/Library/Homebrew/test/support/helper/env.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module Test
- module Helper
- module Env
- def with_environment(partial_env)
- old = ENV.to_hash
- ENV.update partial_env
- begin
- yield
- ensure
- ENV.replace old
- end
- end
- end
- end
-end
diff --git a/Library/Homebrew/test/support/helper/fs_leak_logger.rb b/Library/Homebrew/test/support/helper/fs_leak_logger.rb
index 774ccda04..3fbb148fa 100644
--- a/Library/Homebrew/test/support/helper/fs_leak_logger.rb
+++ b/Library/Homebrew/test/support/helper/fs_leak_logger.rb
@@ -9,13 +9,13 @@ module Test
klass.make_my_diffs_pretty!
end
- def before_setup
+ def setup
@__files_before_test = []
Find.find(TEST_TMPDIR) { |f| @__files_before_test << f.sub(TEST_TMPDIR, "") }
super
end
- def after_teardown
+ def teardown
super
files_after_test = []
Find.find(TEST_TMPDIR) { |f| files_after_test << f.sub(TEST_TMPDIR, "") }
diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb
index b79fdd6e0..45e73757a 100644
--- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb
+++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb
@@ -3,43 +3,16 @@ require "fileutils"
require "pathname"
require "formula"
require "test/support/helper/test_case"
+require "open3"
class IntegrationCommandTestCase < Homebrew::TestCase
def setup
+ super
@cmd_id_index = 0 # Assign unique IDs to invocations of `cmd_output`.
(HOMEBREW_PREFIX/"bin").mkpath
FileUtils.touch HOMEBREW_PREFIX/"bin/brew"
end
- def teardown
- coretap = CoreTap.new
- paths_to_delete = [
- HOMEBREW_LINKED_KEGS,
- HOMEBREW_PINNED_KEGS,
- HOMEBREW_CELLAR.children,
- HOMEBREW_CACHE.children,
- HOMEBREW_LOCK_DIR.children,
- HOMEBREW_LOGS.children,
- HOMEBREW_TEMP.children,
- HOMEBREW_PREFIX/".git",
- HOMEBREW_PREFIX/"bin",
- HOMEBREW_PREFIX/"share",
- HOMEBREW_PREFIX/"opt",
- HOMEBREW_PREFIX/"Caskroom",
- HOMEBREW_LIBRARY/"Taps/caskroom",
- HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle",
- HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo",
- HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services",
- HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow",
- HOMEBREW_REPOSITORY/".git",
- coretap.path/".git",
- coretap.alias_dir,
- coretap.formula_dir.children,
- coretap.path/"formula_renames.json",
- ].flatten
- FileUtils.rm_rf paths_to_delete
- end
-
def needs_test_cmd_taps
return if ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"]
skip "HOMEBREW_TEST_OFFICIAL_CMD_TAPS is not set"
@@ -56,66 +29,46 @@ class IntegrationCommandTestCase < Homebrew::TestCase
end
def cmd_output(*args)
- # 1.8-compatible way of writing def cmd_output(*args, **env)
env = args.last.is_a?(Hash) ? args.pop : {}
- cmd_args = %W[
- -W0
- -I#{HOMEBREW_LIBRARY_PATH}/test/support/lib
- -I#{HOMEBREW_LIBRARY_PATH}
- -rconfig
+
+ env.merge!(
+ "HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew",
+ "HOMEBREW_INTEGRATION_TEST" => cmd_id_from_args(args),
+ "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
+ "HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"]
+ )
+
+ ruby_args = [
+ "-W0",
+ "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib",
+ "-I", HOMEBREW_LIBRARY_PATH.to_s,
+ "-rconfig"
]
- if ENV["HOMEBREW_TESTS_COVERAGE"]
- # This is needed only because we currently use a patched version of
- # simplecov, and gems installed through git are not available without
- # requiring bundler/setup first. See also the comment in test/Gemfile.
- # Remove this line when we'll switch back to a stable simplecov release.
- cmd_args << "-rbundler/setup"
- cmd_args << "-rsimplecov"
- end
- cmd_args << "-rtest/support/helper/integration_mocks"
- cmd_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s
- cmd_args += args
- developer = ENV["HOMEBREW_DEVELOPER"]
- Bundler.with_original_env do
- ENV["HOMEBREW_BREW_FILE"] = HOMEBREW_PREFIX/"bin/brew"
- ENV["HOMEBREW_INTEGRATION_TEST"] = cmd_id_from_args(args)
- ENV["HOMEBREW_TEST_TMPDIR"] = TEST_TMPDIR
- ENV["HOMEBREW_DEVELOPER"] = developer
- env.each_pair do |k, v|
- ENV[k] = v
- end
+ ruby_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
+ ruby_args << "-rtest/support/helper/integration_mocks"
+ ruby_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s
- read, write = IO.pipe
- begin
- pid = fork do
- read.close
- $stdout.reopen(write)
- $stderr.reopen(write)
- write.close
- exec RUBY_PATH, *cmd_args
- end
- write.close
- read.read.chomp
- ensure
- Process.wait(pid)
- read.close
- end
+ Bundler.with_original_env do
+ output, status = Open3.capture2e(env, RUBY_PATH, *ruby_args, *args)
+ [output.chomp, status]
end
end
def cmd(*args)
- output = cmd_output(*args)
- status = $?.exitstatus
- puts "\n'brew #{args.join " "}' output: #{output}" if status.nonzero?
- assert_equal 0, status
+ output, status = cmd_output(*args)
+ assert status.success?, <<-EOS.undent
+ `brew #{args.join " "}` exited with non-zero status!
+ #{output}
+ EOS
output
end
def cmd_fail(*args)
- output = cmd_output(*args)
- status = $?.exitstatus
- $stderr.puts "\n'brew #{args.join " "}'" if status.zero?
- refute_equal 0, status
+ output, status = cmd_output(*args)
+ refute status.success?, <<-EOS.undent
+ `brew #{args.join " "}` exited with zero status!
+ #{output}
+ EOS
output
end
diff --git a/Library/Homebrew/test/support/helper/lifecycle_enforcer.rb b/Library/Homebrew/test/support/helper/lifecycle_enforcer.rb
new file mode 100644
index 000000000..413f8b11e
--- /dev/null
+++ b/Library/Homebrew/test/support/helper/lifecycle_enforcer.rb
@@ -0,0 +1,22 @@
+module Test
+ module Helper
+ module LifecycleEnforcer
+ def setup
+ @__setup_called = true
+ super
+ end
+
+ def teardown
+ @__teardown_called = true
+ super
+ end
+
+ def after_teardown
+ assert @__setup_called, "Expected setup to call `super` but didn't"
+ assert @__teardown_called, "Expected teardown to call `super` but didn't"
+
+ super
+ end
+ end
+ end
+end
diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb
index 60c91e7bb..568beb947 100644
--- a/Library/Homebrew/test/support/helper/test_case.rb
+++ b/Library/Homebrew/test/support/helper/test_case.rb
@@ -1,16 +1,66 @@
+require "formulary"
+require "tap"
+
module Homebrew
class TestCase < ::Minitest::Test
- require "test/support/helper/env"
require "test/support/helper/fs_leak_logger"
+ require "test/support/helper/lifecycle_enforcer"
require "test/support/helper/shutup"
require "test/support/helper/version_assertions"
- include Test::Helper::Env
include Test::Helper::FSLeakLogger
+ include Test::Helper::LifecycleEnforcer
include Test::Helper::Shutup
include Test::Helper::VersionAssertions
- TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
- TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
+ TEST_DIRECTORIES = [
+ CoreTap.instance.path/"Formula",
+ HOMEBREW_CACHE,
+ HOMEBREW_CACHE_FORMULA,
+ HOMEBREW_CELLAR,
+ HOMEBREW_LOCK_DIR,
+ HOMEBREW_LOGS,
+ HOMEBREW_TEMP,
+ ].freeze
+
+ def setup
+ # These directories need to be created before
+ # `FSLeakLogger` is called with `super`.
+ TEST_DIRECTORIES.each(&:mkpath)
+
+ super
+
+ @__argv = ARGV.dup
+ @__env = ENV.to_hash # dup doesn't work on ENV
+ end
+
+ def teardown
+ ARGV.replace(@__argv)
+ ENV.replace(@__env)
+
+ Tab.clear_cache
+
+ FileUtils.rm_rf [
+ TEST_DIRECTORIES.map(&:children),
+ HOMEBREW_LINKED_KEGS,
+ HOMEBREW_PINNED_KEGS,
+ HOMEBREW_PREFIX/".git",
+ HOMEBREW_PREFIX/"bin",
+ HOMEBREW_PREFIX/"share",
+ HOMEBREW_PREFIX/"opt",
+ HOMEBREW_PREFIX/"Caskroom",
+ HOMEBREW_LIBRARY/"Taps/caskroom",
+ HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle",
+ HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo",
+ HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services",
+ HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow",
+ HOMEBREW_REPOSITORY/".git",
+ CoreTap.instance.path/".git",
+ CoreTap.instance.alias_dir,
+ CoreTap.instance.path/"formula_renames.json",
+ ]
+
+ super
+ end
def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, alias_path: nil, &block)
@_f = Class.new(Formula, &block).new(name, path, spec, alias_path: alias_path)
diff --git a/Library/Homebrew/test/support/lib/config.rb b/Library/Homebrew/test/support/lib/config.rb
index f6fdb4ecb..fb5c210fe 100644
--- a/Library/Homebrew/test/support/lib/config.rb
+++ b/Library/Homebrew/test/support/lib/config.rb
@@ -38,3 +38,6 @@ TESTBALL_SHA256 = "91e3f7930c98d7ccfb288e115ed52d06b0e5bc16fec7dce8bdda865300270
TESTBALL_PATCHES_SHA256 = "799c2d551ac5c3a5759bea7796631a7906a6a24435b52261a317133a0bfb34d9".freeze
PATCH_A_SHA256 = "83404f4936d3257e65f176c4ffb5a5b8d6edd644a21c8d8dcc73e22a6d28fcfa".freeze
PATCH_B_SHA256 = "57958271bb802a59452d0816e0670d16c8b70bdf6530bcf6f78726489ad89b90".freeze
+
+TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
+TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb
index f9824ba2a..99c95a3f0 100644
--- a/Library/Homebrew/test/tab_test.rb
+++ b/Library/Homebrew/test/tab_test.rb
@@ -4,30 +4,36 @@ require "formula"
class TabTests < Homebrew::TestCase
def setup
+ super
+
+ @time = Time.now.to_i
@used = Options.create(%w[--with-foo --without-bar])
@unused = Options.create(%w[--with-baz --without-qux])
- @tab = Tab.new("used_options" => @used.as_flags,
- "unused_options" => @unused.as_flags,
- "built_as_bottle" => false,
- "poured_from_bottle" => true,
- "changed_files" => [],
- "time" => nil,
- "source_modified_time" => 0,
- "HEAD" => TEST_SHA1,
- "compiler" => "clang",
- "stdlib" => "libcxx",
- "runtime_dependencies" => [],
- "source" => {
- "tap" => "homebrew/core",
- "path" => nil,
- "spec" => "stable",
- "versions" => {
- "stable" => "0.10",
- "devel" => "0.14",
- "head" => "HEAD-1111111",
- },
- })
+ @tab = Tab.new(
+ "homebrew_version" => HOMEBREW_VERSION,
+ "used_options" => @used.as_flags,
+ "unused_options" => @unused.as_flags,
+ "built_as_bottle" => false,
+ "poured_from_bottle" => true,
+ "changed_files" => [],
+ "time" => @time,
+ "source_modified_time" => 0,
+ "HEAD" => TEST_SHA1,
+ "compiler" => "clang",
+ "stdlib" => "libcxx",
+ "runtime_dependencies" => [],
+ "source" => {
+ "tap" => CoreTap.instance.to_s,
+ "path" => CoreTap.instance.path.to_s,
+ "spec" => "stable",
+ "versions" => {
+ "stable" => "0.10",
+ "devel" => "0.14",
+ "head" => "HEAD-1111111",
+ },
+ }
+ )
end
def test_defaults
@@ -122,7 +128,7 @@ class TabTests < Homebrew::TestCase
def test_other_attributes
assert_equal TEST_SHA1, @tab.HEAD
assert_equal "homebrew/core", @tab.tap.name
- assert_nil @tab.time
+ assert_equal @time, @tab.time
refute_predicate @tab, :built_as_bottle
assert_predicate @tab, :poured_from_bottle
end
@@ -260,16 +266,13 @@ end
class TabLoadingTests < Homebrew::TestCase
def setup
+ super
@f = formula { url "foo-1.0" }
@f.prefix.mkpath
@path = @f.prefix.join(Tab::FILENAME)
@path.write TEST_FIXTURE_DIR.join("receipt.json").read
end
- def teardown
- @f.rack.rmtree
- end
-
def test_for_keg
tab = Tab.for_keg(@f.prefix)
assert_equal @path, tab.tabfile
diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb
index 7114cdf22..578326cea 100644
--- a/Library/Homebrew/test/tap_test.rb
+++ b/Library/Homebrew/test/tap_test.rb
@@ -34,6 +34,7 @@ class TapTest < Homebrew::TestCase
include FileUtils
def setup
+ super
@path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
@path.mkpath
@tap = Tap.new("Homebrew", "foo")
@@ -65,13 +66,6 @@ class TapTest < Homebrew::TestCase
end
def setup_git_repo
- env = ENV.to_hash
- %w[AUTHOR COMMITTER].each do |role|
- ENV["GIT_#{role}_NAME"] = "brew tests"
- ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost"
- ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100"
- end
-
@path.cd do
shutup do
system "git", "init"
@@ -80,12 +74,6 @@ class TapTest < Homebrew::TestCase
system "git", "commit", "-m", "init"
end
end
- ensure
- ENV.replace(env)
- end
-
- def teardown
- @path.rmtree
end
def test_fetch
@@ -171,8 +159,6 @@ class TapTest < Homebrew::TestCase
end
end
refute_predicate services_tap, :private?
- ensure
- services_tap.path.rmtree if services_tap
end
def test_remote_not_git_repo
@@ -189,10 +175,10 @@ class TapTest < Homebrew::TestCase
touch @path/"README"
setup_git_repo
- assert_equal "e1893a6bd191ba895c71b652ff8376a6114c7fa7", @tap.git_head
- assert_equal "e189", @tap.git_short_head
- assert_match "years ago", @tap.git_last_commit
- assert_equal "2009-05-21", @tap.git_last_commit_date
+ assert_equal "0453e16c8e3fac73104da50927a86221ca0740c2", @tap.git_head
+ assert_equal "0453", @tap.git_short_head
+ assert_match(/\A\d+ .+ ago\Z/, @tap.git_last_commit)
+ assert_equal "2017-01-22", @tap.git_last_commit_date
end
def test_private_remote
@@ -256,8 +242,6 @@ class TapTest < Homebrew::TestCase
refute_predicate tap, :installed?
refute_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :exist?
refute_predicate HOMEBREW_PREFIX/"share/man/man1", :exist?
- ensure
- (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
end
def test_pin_and_unpin
@@ -285,6 +269,7 @@ class CoreTapTest < Homebrew::TestCase
include FileUtils
def setup
+ super
@repo = CoreTap.new
end
@@ -322,8 +307,5 @@ class CoreTapTest < Homebrew::TestCase
assert_equal ["bar"], @repo.aliases
assert_equal @repo.alias_table, "bar" => "foo"
assert_equal @repo.alias_reverse_table, "foo" => ["bar"]
- ensure
- @formula_file.unlink
- @repo.alias_dir.rmtree
end
end
diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb
index e2ba2e4e4..999fa1013 100644
--- a/Library/Homebrew/test/testing_env.rb
+++ b/Library/Homebrew/test/testing_env.rb
@@ -1,21 +1,18 @@
-$:.unshift File.expand_path("../..", __FILE__)
-$:.unshift File.expand_path("../support/lib", __FILE__)
-
-require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
-require "global"
-require "formulary"
-
-# Test environment setup
-(HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-core/Formula").mkpath
-%w[cache formula_cache locks cellar logs temp].each { |d| HOMEBREW_PREFIX.parent.join(d).mkpath }
-
begin
require "minitest/autorun"
- require "parallel_tests/test/runtime_logger"
+ require "minitest/reporters"
+ Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true)
require "mocha/setup"
+ require "parallel_tests/test/runtime_logger"
+ require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
rescue LoadError
- abort "Run `bundle install` or install the mocha and minitest gems before running the tests"
+ abort "Run `bundle install` before running the tests."
end
+$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew"))
+$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib"))
+
+require "global"
+
require "test/support/helper/test_case"
require "test/support/helper/integration_command_test_case"
diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb
index 597e77e40..2f8bf4fff 100644
--- a/Library/Homebrew/test/uninstall_test.rb
+++ b/Library/Homebrew/test/uninstall_test.rb
@@ -3,6 +3,8 @@ require "cmd/uninstall"
class UninstallTests < Homebrew::TestCase
def setup
+ super
+
@dependency = formula("dependency") { url "f-1" }
@dependent = formula("dependent") do
url "f-1"
@@ -28,10 +30,7 @@ class UninstallTests < Homebrew::TestCase
def teardown
Homebrew.failed = false
- [@dependency, @dependent].each do |f|
- f.installed_kegs.each(&:remove_opt_record)
- f.rack.rmtree
- end
+ super
end
def handle_unsatisfied_dependents
@@ -59,8 +58,6 @@ class UninstallTests < Homebrew::TestCase
assert_empty handle_unsatisfied_dependents
refute_predicate Homebrew, :failed?
end
- ensure
- ARGV.delete("--ignore-dependencies")
end
end
diff --git a/Library/Homebrew/test/update_report_test.rb b/Library/Homebrew/test/update_report_test.rb
index 6b6cec6ce..32c3e36d0 100644
--- a/Library/Homebrew/test/update_report_test.rb
+++ b/Library/Homebrew/test/update_report_test.rb
@@ -24,6 +24,7 @@ class ReportTests < Homebrew::TestCase
end
def setup
+ super
@tap = CoreTap.new
@reporter = ReporterMock.new(@tap)
@hub = ReporterHub.new
diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb
index d7c25683d..1f2fb7b55 100644
--- a/Library/Homebrew/test/utils_test.rb
+++ b/Library/Homebrew/test/utils_test.rb
@@ -5,13 +5,12 @@ require "utils/shell"
class UtilTests < Homebrew::TestCase
def setup
+ super
@dir = Pathname.new(mktmpdir)
- @env = ENV.to_hash
end
- def teardown
- @dir.rmtree
- ENV.replace @env
+ def esc(code)
+ /(\e\[\d+m)*\e\[#{code}m/
end
def test_ofail
@@ -27,11 +26,29 @@ class UtilTests < Homebrew::TestCase
end
def test_pretty_installed
+ $stdout.stubs(:tty?).returns true
+ ENV.delete("HOMEBREW_NO_EMOJI")
+ tty_with_emoji_output = /\A#{esc 1}foo #{esc 32}✔#{esc 0}\Z/
+ assert_match tty_with_emoji_output, pretty_installed("foo")
+
+ ENV["HOMEBREW_NO_EMOJI"] = "1"
+ tty_no_emoji_output = /\A#{esc 1}foo \(installed\)#{esc 0}\Z/
+ assert_match tty_no_emoji_output, pretty_installed("foo")
+
$stdout.stubs(:tty?).returns false
assert_equal "foo", pretty_installed("foo")
end
def test_pretty_uninstalled
+ $stdout.stubs(:tty?).returns true
+ ENV.delete("HOMEBREW_NO_EMOJI")
+ tty_with_emoji_output = /\A#{esc 1}foo #{esc 31}✘#{esc 0}\Z/
+ assert_match tty_with_emoji_output, pretty_uninstalled("foo")
+
+ ENV["HOMEBREW_NO_EMOJI"] = "1"
+ tty_no_emoji_output = /\A#{esc 1}foo \(uninstalled\)#{esc 0}\Z/
+ assert_match tty_no_emoji_output, pretty_uninstalled("foo")
+
$stdout.stubs(:tty?).returns false
assert_equal "foo", pretty_uninstalled("foo")
end
@@ -212,7 +229,7 @@ class UtilTests < Homebrew::TestCase
end
def test_odeprecated
- ARGV.stubs(:homebrew_developer?).returns false
+ ENV.delete("HOMEBREW_DEVELOPER")
e = assert_raises(MethodDeprecatedError) do
odeprecated("method", "replacement",
caller: ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"],
diff --git a/Library/Homebrew/test/versions_test.rb b/Library/Homebrew/test/versions_test.rb
index a6e922178..b6814b1d1 100644
--- a/Library/Homebrew/test/versions_test.rb
+++ b/Library/Homebrew/test/versions_test.rb
@@ -185,8 +185,6 @@ class VersionParsingTests < Homebrew::TestCase
d = HOMEBREW_CELLAR/"foo-0.1.9"
d.mkpath
assert_equal version("0.1.9"), d.version
- ensure
- d.unlink
end
def test_no_version
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 614d50eea..70d2787d9 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -106,7 +106,7 @@ def pretty_installed(f)
if !$stdout.tty?
f.to_s
elsif Emoji.enabled?
- "#{Tty.bold}#{f} #{Formatter.success(Emoji.tick)}#{Tty.reset}"
+ "#{Tty.bold}#{f} #{Formatter.success("✔")}#{Tty.reset}"
else
Formatter.success("#{Tty.bold}#{f} (installed)#{Tty.reset}")
end
@@ -116,7 +116,7 @@ def pretty_uninstalled(f)
if !$stdout.tty?
f.to_s
elsif Emoji.enabled?
- "#{Tty.bold}#{f} #{Formatter.error(Emoji.cross)}#{Tty.reset}"
+ "#{Tty.bold}#{f} #{Formatter.error("✘")}#{Tty.reset}"
else
Formatter.error("#{Tty.bold}#{f} (uninstalled)#{Tty.reset}")
end
diff --git a/README.md b/README.md
index 940b49878..4ee9b1292 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ cd "$(brew --repo)" && git fetch && git reset --hard origin/master && brew updat
3. Or use `brew search --desc <keyword>` to browse packages from the command line.
## More Documentation
-`brew help`, `man brew` or check [our documentation](https://brew.sh/brew/).
+`brew help`, `man brew` or check [our documentation](http://docs.brew.sh/).
## Troubleshooting
First, please run `brew update` and `brew doctor`.
@@ -61,15 +61,19 @@ Please consider a regular donation through Patreon:
[![Donate with Patreon](https://img.shields.io/badge/patreon-donate-green.svg)](https://www.patreon.com/homebrew)
## Sponsors
-Our CI infrastructure was paid for by [our Kickstarter supporters](http://docs.brew.sh/Kickstarter-Supporters.html).
+Our Xserve ESXi boxes for CI are hosted by [MacStadium](https://www.macstadium.com).
-Our CI infrastructure is hosted by [The Positive Internet Company](http://www.positive-internet.com).
+[![Powered by MacStadium](https://cloud.githubusercontent.com/assets/125011/22776032/097557ac-eea6-11e6-8ba8-eff22dfd58f1.png)](https://www.macstadium.com)
-Our bottles (binary packages) are hosted by Bintray.
+Our Mac Minis for CI were paid for by [our Kickstarter supporters](http://docs.brew.sh/Kickstarter-Supporters.html).
+
+Our Mac Minis for CI are hosted by [The Positive Internet Company](http://www.positive-internet.com).
+
+Our bottles (binary packages) are hosted by [Bintray](https://bintray.com/homebrew).
[![Downloads by Bintray](https://bintray.com/docs/images/downloads_by_bintray_96.png)](https://bintray.com/homebrew)
-Secure password storage and syncing provided by [1Password for Teams](https://1password.com/teams/) by AgileBits
+Secure password storage and syncing provided by [1Password for Teams](https://1password.com/teams/) by [AgileBits](https://agilebits.com)
[![AgileBits](https://da36klfizjv29.cloudfront.net/assets/branding/agilebits-fcca96e9b8e815c5c48c6b3e98156cb5.png)](https://agilebits.com)
diff --git a/completions/zsh/_brew b/completions/zsh/_brew
index 2d8e1b42b..9f7b8ebe5 100644
--- a/completions/zsh/_brew
+++ b/completions/zsh/_brew
@@ -678,7 +678,7 @@ _brew_test_bot() {
}
# brew tests [-v] [--coverage] [--generic] [--no-compat]
-# [--only=test_script/test_method] [--seed seed] [--trace] [--online]
+# [--only=test_script:test_method] [--seed seed] [--trace] [--online]
# [--official-cmd-taps]:
_brew_tests() {
_arguments \
diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md
index bb3ad33dc..c87424c7e 100644
--- a/docs/Formula-Cookbook.md
+++ b/docs/Formula-Cookbook.md
@@ -359,6 +359,7 @@ Now, please [open a pull request](http://docs.brew.sh/How-To-Open-a-Homebrew-Pul
* Keep merge commits out of the pull request
# Convenience Tools
+
## Messaging
Three commands are provided for displaying informational messages to the user:
@@ -783,6 +784,8 @@ The symlinks created by `install_symlink` are guaranteed to be relative. `ln_s`
For example, Ruby 1.9’s gems should be installed to `var/lib/ruby/` so that gems don’t need to be reinstalled when upgrading Ruby. You can usually do this with symlink trickery, or *better* a configure option.
+Another example would be configuration files that should not be overwritten on package upgrades. If after installation you find that to-be-persisted configuration files are not copied but instead *symlinked* into `/usr/local/etc/` from the Cellar, this can often be rectified by passing an appropriate argument to the package’s configure script. That argument will vary depending on a given package’s configure script and/or Makefile, but one example might be: `--sysconfdir=#{etc}`
+
### launchd plist files
Homebrew provides two Formula methods for launchd plist files. [`plist_name`](http://www.rubydoc.info/github/Homebrew/brew/master/Formula#plist_name-instance_method) will return e.g. `homebrew.mxcl.<formula>` and [`plist_path`](http://www.rubydoc.info/github/Homebrew/brew/master/Formula#plist_path-instance_method) will return e.g. `/usr/local/Cellar/foo/0.1/homebrew.mxcl.foo.plist`.
diff --git a/docs/Versions.md b/docs/Versions.md
index 9e679db7d..bd3ef8a5f 100644
--- a/docs/Versions.md
+++ b/docs/Versions.md
@@ -11,6 +11,6 @@ Versioned formulae we include must meet the following standards:
* Versioned formulae should differ in major/minor (not patch) versions from the current stable release. This is because patch versions indicate bug or security updates and we want to ensure you apply security updates.
* Formulae that depend on versioned formulae must not depend on the same formulae at two different versions twice in their recursive dependencies. For example, if you depend on `openssl@1.0` and `foo`, and `foo` depends on `openssl` then you must instead use `openssl`.
-* Versioned formulae should strive to be linked at the same time as their non-versioned counterpart (without patching). If this is not possible, favour either `conflicts_with` or `keg_only` depending on whether users expect to have multiple versions installed at once or not.
+* Versioned formulae should only be linkable at the same time as their non-versioned counterpart if the upstream project provides support for e.g. suffixed binaries. If this is not possible, use `keg_only :versioned_formula` to allow users to have multiple versions installed at once.
You should create your own [tap](https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md) for formulae you or your organisation wishes to control the versioning of or those that do not meet the above standards.
diff --git a/docs/brew.1.html b/docs/brew.1.html
index 2e89a1933..3b2c3d5bb 100644
--- a/docs/brew.1.html
+++ b/docs/brew.1.html
@@ -398,7 +398,7 @@ source. This is useful for creating patches for the software.</p></dd>
<code>pin</code>.</p></dd>
<dt><code>untap</code> <var>tap</var></dt><dd><p>Remove a tapped repository.</p></dd>
<dt><code>update</code> [<code>--merge</code>] [<code>--force</code>]</dt><dd><p>Fetch the newest version of Homebrew and all formulae from GitHub using
-<code>git</code>(1).</p>
+<code>git</code>(1) and perform any necessary migrations.</p>
<p>If <code>--merge</code> is specified then <code>git merge</code> is used to include updates
(rather than <code>git rebase</code>).</p>
@@ -613,7 +613,7 @@ launched with access to IRB or a shell inside the temporary test directory.</p>
not deleted.</p>
<p>Example: <code>brew install jruby &amp;&amp; brew test jruby</code></p></dd>
-<dt><code>tests</code> [<code>-v</code>] [<code>--coverage</code>] [<code>--generic</code>] [<code>--no-compat</code>] [<code>--only=</code><test_script/test_method>] [<code>--seed</code> <var>seed</var>] [<code>--trace</code>] [<code>--online</code>] [<code>--official-cmd-taps</code>]</dt><dd><p>Run Homebrew's unit and integration tests.</p></dd>
+<dt><code>tests</code> [<code>-v</code>] [<code>--coverage</code>] [<code>--generic</code>] [<code>--no-compat</code>] [<code>--only=</code>&lt;test_script:test_method>] [<code>--seed</code> <var>seed</var>] [<code>--trace</code>] [<code>--online</code>] [<code>--official-cmd-taps</code>]</dt><dd><p>Run Homebrew's unit and integration tests.</p></dd>
<dt><code>update-test</code> [<code>--commit=&lt;commit></code>] [<code>--before=&lt;date></code>] [<code>--keep-tmp</code>]</dt><dd><p>Runs a test of <code>brew update</code> with a new repository clone.</p>
<p>If no arguments are passed, use <code>origin/master</code> as the start commit.</p>
diff --git a/manpages/brew-cask.1 b/manpages/brew-cask.1
index 05ec581c0..a30c9eb56 100644
--- a/manpages/brew-cask.1
+++ b/manpages/brew-cask.1
@@ -105,6 +105,19 @@ If the Cask definition contains a \fBzap\fR stanza, performs additional \fBzap\f
.
.IP "" 0
.
+.SH "INTERNAL COMMANDS"
+.
+.TP
+\fB_appcast_checkpoint\fR [\-\-calculate] [ \fItoken\fR \.\.\. | \fIURL\fR \.\.\. ]
+Given a \fBtoken\fR, returns the current appcast checkpoint, or calculates the appcast checkpoint if the \fB\-\-calculate\fR flag is specified\.
+.
+.br
+Given a \fBURL\fR, calculates the appcast checkpoint for it\.
+.
+.TP
+\fB_stanza\fR \fIstanza_name\fR [ \-\-table | \-\-yaml | \-\-inspect | \-\-quiet ] [ \fIcask_token\fR \.\.\. ]
+Given a \fBstanza_name\fR and a \fBcask_token\fR, returns the current stanza for a given Cask\. If no \fBcask_token\fR is given, then data for all Casks is returned\.
+.
.SH "OPTIONS"
To make these options persistent, see the ENVIRONMENT section, below\.
.
diff --git a/manpages/brew.1 b/manpages/brew.1
index fe14ef3f8..45f3ec406 100644
--- a/manpages/brew.1
+++ b/manpages/brew.1
@@ -542,7 +542,7 @@ Remove a tapped repository\.
.
.TP
\fBupdate\fR [\fB\-\-merge\fR] [\fB\-\-force\fR]
-Fetch the newest version of Homebrew and all formulae from GitHub using \fBgit\fR(1)\.
+Fetch the newest version of Homebrew and all formulae from GitHub using \fBgit\fR(1) and perform any necessary migrations\.
.
.IP
If \fB\-\-merge\fR is specified then \fBgit merge\fR is used to include updates (rather than \fBgit rebase\fR)\.
@@ -804,7 +804,7 @@ If \fB\-\-keep\-tmp\fR is passed, the temporary files created for the test are n
Example: \fBbrew install jruby && brew test jruby\fR
.
.TP
-\fBtests\fR [\fB\-v\fR] [\fB\-\-coverage\fR] [\fB\-\-generic\fR] [\fB\-\-no\-compat\fR] [\fB\-\-only=\fR<test_script/test_method>] [\fB\-\-seed\fR \fIseed\fR] [\fB\-\-trace\fR] [\fB\-\-online\fR] [\fB\-\-official\-cmd\-taps\fR]
+\fBtests\fR [\fB\-v\fR] [\fB\-\-coverage\fR] [\fB\-\-generic\fR] [\fB\-\-no\-compat\fR] [\fB\-\-only=\fR<test_script:test_method>] [\fB\-\-seed\fR \fIseed\fR] [\fB\-\-trace\fR] [\fB\-\-online\fR] [\fB\-\-official\-cmd\-taps\fR]
Run Homebrew\'s unit and integration tests\.
.
.TP