From cd677cf3aed7a0aed91c0f3428091d0fe52c60e9 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 26 Sep 2016 19:55:50 +0200 Subject: [PATCH 1/2] Speed up `parallel_tests` by splitting integration tests. --- .../Homebrew/test/integration_cmds_tests.rb | 194 ++++ .../Homebrew/test/test_integration_cmds.rb | 899 ------------------ .../test/test_integration_cmds_analytics.rb | 26 + .../test/test_integration_cmds_bottle.rb | 21 + .../test/test_integration_cmds_bundle.rb | 22 + .../test/test_integration_cmds_cache.rb | 8 + .../test_integration_cmds_cache_formula.rb | 8 + .../test/test_integration_cmds_cask.rb | 10 + .../test/test_integration_cmds_cat.rb | 8 + .../test/test_integration_cmds_cellar.rb | 8 + .../test_integration_cmds_cellar_formula.rb | 8 + .../test/test_integration_cmds_cleanup.rb | 8 + .../test/test_integration_cmds_command.rb | 11 + .../test/test_integration_cmds_commands.rb | 8 + .../test/test_integration_cmds_config.rb | 8 + .../test/test_integration_cmds_create.rb | 12 + .../test_integration_cmds_custom_command.rb | 16 + .../test/test_integration_cmds_deps.rb | 16 + .../test/test_integration_cmds_desc.rb | 17 + .../test/test_integration_cmds_doctor.rb | 8 + .../test/test_integration_cmds_edit.rb | 11 + .../test/test_integration_cmds_env.rb | 8 + .../test/test_integration_cmds_env_bash.rb | 8 + .../test/test_integration_cmds_env_csh.rb | 8 + .../test/test_integration_cmds_env_fish.rb | 8 + .../test/test_integration_cmds_env_plain.rb | 8 + .../test/test_integration_cmds_fetch.rb | 11 + .../test/test_integration_cmds_help.rb | 21 + .../test/test_integration_cmds_home.rb | 12 + .../test/test_integration_cmds_info.rb | 10 + .../test/test_integration_cmds_install.rb | 24 + .../test/test_integration_cmds_irb.rb | 19 + .../test/test_integration_cmds_leaves.rb | 15 + .../test/test_integration_cmds_link.rb | 23 + .../test/test_integration_cmds_linkapps.rb | 15 + .../test/test_integration_cmds_list.rb | 13 + .../test/test_integration_cmds_log.rb | 13 + .../test/test_integration_cmds_log_formula.rb | 27 + .../test/test_integration_cmds_migrate.rb | 18 + .../test/test_integration_cmds_missing.rb | 11 + .../test/test_integration_cmds_options.rb | 12 + .../test/test_integration_cmds_outdated.rb | 10 + .../test/test_integration_cmds_pin_unpin.rb | 18 + .../test/test_integration_cmds_prefix.rb | 8 + .../test_integration_cmds_prefix_formula.rb | 8 + .../test/test_integration_cmds_prune.rb | 21 + .../test/test_integration_cmds_pull.rb | 27 + .../test_integration_cmds_pull_offline.rb | 10 + .../test/test_integration_cmds_readall.rb | 12 + .../test/test_integration_cmds_reinstall.rb | 15 + .../test_integration_cmds_reinstall_pinned.rb | 15 + .../test/test_integration_cmds_repository.rb | 10 + .../test/test_integration_cmds_search.rb | 30 + .../test/test_integration_cmds_services.rb | 11 + .../Homebrew/test/test_integration_cmds_sh.rb | 8 + .../test/test_integration_cmds_switch.rb | 20 + .../test/test_integration_cmds_tap.rb | 30 + .../test/test_integration_cmds_tap_readme.rb | 10 + .../test_integration_cmds_test_formula.rb | 30 + .../test/test_integration_cmds_uninstall.rb | 8 + .../test/test_integration_cmds_unlink.rb | 10 + .../test/test_integration_cmds_unlinkapps.rb | 19 + .../test/test_integration_cmds_unpack.rb | 13 + .../test/test_integration_cmds_upgrade.rb | 12 + .../test/test_integration_cmds_uses.rb | 16 + .../test/test_integration_cmds_version.rb | 8 + 66 files changed, 1091 insertions(+), 899 deletions(-) create mode 100644 Library/Homebrew/test/integration_cmds_tests.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_analytics.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_bottle.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_bundle.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_cache.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_cache_formula.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_cask.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_cat.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_cellar.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_cellar_formula.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_cleanup.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_command.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_commands.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_config.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_create.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_custom_command.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_deps.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_desc.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_doctor.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_edit.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_env.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_env_bash.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_env_csh.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_env_fish.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_env_plain.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_fetch.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_help.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_home.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_info.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_install.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_irb.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_leaves.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_link.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_linkapps.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_list.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_log.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_log_formula.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_migrate.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_missing.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_options.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_outdated.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_pin_unpin.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_prefix.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_prefix_formula.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_prune.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_pull.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_pull_offline.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_readall.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_reinstall.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_reinstall_pinned.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_repository.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_search.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_services.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_sh.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_switch.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_tap.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_tap_readme.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_test_formula.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_uninstall.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_unlink.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_unlinkapps.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_unpack.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_upgrade.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_uses.rb create mode 100644 Library/Homebrew/test/test_integration_cmds_version.rb diff --git a/Library/Homebrew/test/integration_cmds_tests.rb b/Library/Homebrew/test/integration_cmds_tests.rb new file mode 100644 index 0000000000..a63b343c03 --- /dev/null +++ b/Library/Homebrew/test/integration_cmds_tests.rb @@ -0,0 +1,194 @@ +require "bundler" +require "testing_env" +require "fileutils" +require "pathname" +require "formula" + +class IntegrationCommandTests < Homebrew::TestCase + def setup + @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/"bin", + HOMEBREW_PREFIX/"share", + HOMEBREW_PREFIX/"opt", + 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" + end + + def needs_macos + skip "Not on MacOS" unless OS.mac? + end + + def cmd_id_from_args(args) + args_pretty = args.join(" ").gsub(TEST_TMPDIR, "@TMPDIR@") + test_pretty = "#{self.class.name}\##{name}.#{@cmd_id_index += 1}" + "[#{test_pretty}] brew #{args_pretty}" + 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/lib + -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 << "-rintegration_mocks" + cmd_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s + cmd_args += args + 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.each_pair { |k, v| ENV[k] = v } + + 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 + end + end + + def cmd(*args) + output = cmd_output(*args) + status = $?.exitstatus + puts "\n#{output}" if status.nonzero? + assert_equal 0, status + output + end + + def cmd_fail(*args) + output = cmd_output(*args) + status = $?.exitstatus + $stderr.puts "\n#{output}" if status.zero? + refute_equal 0, status + output + end + + def setup_test_formula(name, content = nil) + formula_path = CoreTap.new.formula_dir/"#{name}.rb" + + case name + when /^testball/ + content = <<-EOS.undent + desc "Some test" + homepage "https://example.com/#{name}" + url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" + sha256 "#{TESTBALL_SHA256}" + + option "with-foo", "Build with foo" + #{content} + + def install + (prefix/"foo"/"test").write("test") if build.with? "foo" + prefix.install Dir["*"] + (buildpath/"test.c").write \ + "#include \\nint main(){return printf(\\"test\\");}" + bin.mkpath + system ENV.cc, "test.c", "-o", bin/"test" + end + + # something here + EOS + when "foo" + content = <<-EOS.undent + url "https://example.com/#{name}-1.0" + EOS + when "bar" + content = <<-EOS.undent + url "https://example.com/#{name}-1.0" + depends_on "foo" + EOS + end + + formula_path.write <<-EOS.undent + class #{Formulary.class_s(name)} < Formula + #{content} + end + EOS + + formula_path + end + + def setup_remote_tap(name) + tap = Tap.fetch name + tap.install(full_clone: false, quiet: true) unless tap.installed? + tap + end + + def install_and_rename_coretap_formula(old_name, new_name) + core_tap = CoreTap.new + core_tap.path.cd do + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", + "#{old_name.capitalize} has not yet been renamed" + end + end + + cmd("install", old_name) + (core_tap.path/"Formula/#{old_name}.rb").unlink + formula_renames = core_tap.path/"formula_renames.json" + formula_renames.write Utils::JSON.dump(old_name => new_name) + + core_tap.path.cd do + shutup do + system "git", "add", "--all" + system "git", "commit", "-m", + "#{old_name.capitalize} has been renamed to #{new_name.capitalize}" + end + end + end + + def testball + "#{File.expand_path("..", __FILE__)}/testball.rb" + end +end diff --git a/Library/Homebrew/test/test_integration_cmds.rb b/Library/Homebrew/test/test_integration_cmds.rb deleted file mode 100644 index 35ad04e7a6..0000000000 --- a/Library/Homebrew/test/test_integration_cmds.rb +++ /dev/null @@ -1,899 +0,0 @@ -require "bundler" -require "testing_env" -require "fileutils" -require "pathname" -require "formula" - -class IntegrationCommandTests < Homebrew::TestCase - def setup - @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/"bin", - HOMEBREW_PREFIX/"share", - HOMEBREW_PREFIX/"opt", - 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" - end - - def needs_macos - skip "Not on MacOS" unless OS.mac? - end - - def cmd_id_from_args(args) - args_pretty = args.join(" ").gsub(TEST_TMPDIR, "@TMPDIR@") - test_pretty = "#{self.class.name}\##{name}.#{@cmd_id_index += 1}" - "[#{test_pretty}] brew #{args_pretty}" - 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/lib - -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 << "-rintegration_mocks" - cmd_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s - cmd_args += args - 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.each_pair { |k, v| ENV[k] = v } - - 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 - end - end - - def cmd(*args) - output = cmd_output(*args) - status = $?.exitstatus - puts "\n#{output}" if status.nonzero? - assert_equal 0, status - output - end - - def cmd_fail(*args) - output = cmd_output(*args) - status = $?.exitstatus - $stderr.puts "\n#{output}" if status.zero? - refute_equal 0, status - output - end - - def setup_test_formula(name, content = nil) - formula_path = CoreTap.new.formula_dir/"#{name}.rb" - - case name - when /^testball/ - content = <<-EOS.undent - desc "Some test" - homepage "https://example.com/#{name}" - url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" - sha256 "#{TESTBALL_SHA256}" - - option "with-foo", "Build with foo" - #{content} - - def install - (prefix/"foo"/"test").write("test") if build.with? "foo" - prefix.install Dir["*"] - (buildpath/"test.c").write \ - "#include \\nint main(){return printf(\\"test\\");}" - bin.mkpath - system ENV.cc, "test.c", "-o", bin/"test" - end - - # something here - EOS - when "foo" - content = <<-EOS.undent - url "https://example.com/#{name}-1.0" - EOS - when "bar" - content = <<-EOS.undent - url "https://example.com/#{name}-1.0" - depends_on "foo" - EOS - end - - formula_path.write <<-EOS.undent - class #{Formulary.class_s(name)} < Formula - #{content} - end - EOS - - formula_path - end - - def setup_remote_tap(name) - tap = Tap.fetch name - tap.install(full_clone: false, quiet: true) unless tap.installed? - tap - end - - def install_and_rename_coretap_formula(old_name, new_name) - core_tap = CoreTap.new - core_tap.path.cd do - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", - "#{old_name.capitalize} has not yet been renamed" - end - end - - cmd("install", old_name) - (core_tap.path/"Formula/#{old_name}.rb").unlink - formula_renames = core_tap.path/"formula_renames.json" - formula_renames.write Utils::JSON.dump(old_name => new_name) - - core_tap.path.cd do - shutup do - system "git", "add", "--all" - system "git", "commit", "-m", - "#{old_name.capitalize} has been renamed to #{new_name.capitalize}" - end - end - end - - def testball - "#{File.expand_path("..", __FILE__)}/testball.rb" - end - - def test_prefix - assert_equal HOMEBREW_PREFIX.to_s, - cmd("--prefix") - end - - def test_version - assert_match HOMEBREW_VERSION.to_s, - cmd("--version") - end - - def test_cache - assert_equal HOMEBREW_CACHE.to_s, - cmd("--cache") - end - - def test_cache_formula - assert_match %r{#{HOMEBREW_CACHE}/testball-}, - cmd("--cache", testball) - end - - def test_cellar - assert_equal HOMEBREW_CELLAR.to_s, - cmd("--cellar") - end - - def test_cellar_formula - assert_match "#{HOMEBREW_CELLAR}/testball", - cmd("--cellar", testball) - end - - def test_env - assert_match(/CMAKE_PREFIX_PATH="#{Regexp.escape(HOMEBREW_PREFIX)}[:"]/, - cmd("--env")) - end - - def test_env_bash - assert_match(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/, - cmd("--env", "--shell=bash")) - end - - def test_env_fish - assert_match(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/, - cmd("--env", "--shell=fish")) - end - - def test_env_csh - assert_match(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/, - cmd("--env", "--shell=tcsh")) - end - - def test_env_plain - assert_match(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/, - cmd("--env", "--plain")) - end - - def test_prefix_formula - assert_match "#{HOMEBREW_CELLAR}/testball", - cmd("--prefix", testball) - end - - def test_repository - assert_match HOMEBREW_REPOSITORY.to_s, - cmd("--repository") - assert_match "#{HOMEBREW_LIBRARY}/Taps/foo/homebrew-bar", - cmd("--repository", "foo/bar") - end - - def test_help - assert_match "Example usage:\n", - cmd_fail # Generic help (empty argument list). - assert_match "Unknown command: command-that-does-not-exist", - cmd_fail("help", "command-that-does-not-exist") - assert_match(/^brew cat /, - cmd_fail("cat")) # Missing formula argument triggers help. - - assert_match "Example usage:\n", - cmd("help") # Generic help. - assert_match(/^brew cat /, - cmd("help", "cat")) # Internal command (documented, Ruby). - assert_match(/^brew update /, - cmd("help", "update")) # Internal command (documented, Shell). - assert_match(/^brew update-test /, - cmd("help", "update-test")) # Internal developer command (documented, Ruby). - end - - def test_config - assert_match "HOMEBREW_VERSION: #{HOMEBREW_VERSION}", - cmd("config") - end - - def test_install - setup_test_formula "testball1" - assert_match "Specify `--HEAD`", cmd_fail("install", "testball1", "--head") - assert_match "No head is defined", cmd_fail("install", "testball1", "--HEAD") - assert_match "No devel block", cmd_fail("install", "testball1", "--devel") - assert_match "#{HOMEBREW_CELLAR}/testball1/0.1", cmd("install", "testball1") - assert_match "testball1-0.1 already installed", cmd("install", "testball1") - assert_match "MacRuby is not packaged", cmd_fail("install", "macruby") - assert_match "No available formula", cmd_fail("install", "formula") - assert_match "This similarly named formula was found", - cmd_fail("install", "testball") - - setup_test_formula "testball2" - assert_match "These similarly named formulae were found", - cmd_fail("install", "testball") - - install_and_rename_coretap_formula "testball1", "testball2" - assert_match "testball1 already installed, it's just not migrated", - cmd("install", "testball2") - end - - def test_bottle - cmd("install", "--build-bottle", testball) - assert_match "Formula not from core or any taps", - cmd_fail("bottle", "--no-rebuild", testball) - - setup_test_formula "testball" - - # `brew bottle` should not fail with dead symlink - # https://github.com/Homebrew/legacy-homebrew/issues/49007 - (HOMEBREW_CELLAR/"testball/0.1").cd do - FileUtils.ln_s "not-exist", "symlink" - end - assert_match(/testball-0\.1.*\.bottle\.tar\.gz/, - cmd_output("bottle", "--no-rebuild", "testball")) - ensure - FileUtils.rm_f Dir["testball-0.1*.bottle.tar.gz"] - end - - def test_uninstall - cmd("install", testball) - assert_match "Uninstalling testball", cmd("uninstall", "--force", testball) - end - - def test_cleanup - (HOMEBREW_CACHE/"test").write "test" - assert_match "#{HOMEBREW_CACHE}/test", cmd("cleanup", "--prune=all") - end - - def test_readall - formula_file = setup_test_formula "testball" - alias_file = CoreTap.new.alias_dir/"foobar" - alias_file.parent.mkpath - FileUtils.ln_s formula_file, alias_file - cmd("readall", "--aliases", "--syntax") - cmd("readall", "homebrew/core") - end - - def test_tap - path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" - path.mkpath - path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - FileUtils.touch "readme" - system "git", "add", "--all" - system "git", "commit", "-m", "init" - end - end - - assert_match "homebrew/foo", cmd("tap") - assert_match "homebrew/versions", cmd("tap", "--list-official") - assert_match "2 taps", cmd("tap-info") - assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "homebrew/foo") - assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "--json=v1", "--installed") - assert_match "Pinned homebrew/foo", cmd("tap-pin", "homebrew/foo") - assert_match "homebrew/foo", cmd("tap", "--list-pinned") - assert_match "Unpinned homebrew/foo", cmd("tap-unpin", "homebrew/foo") - assert_match "Tapped", cmd("tap", "homebrew/bar", path/".git") - assert_match "Untapped", cmd("untap", "homebrew/bar") - assert_equal "", cmd("tap", "homebrew/bar", path/".git", "-q", "--full") - assert_match "Untapped", cmd("untap", "homebrew/bar") - end - - def test_missing - setup_test_formula "foo" - setup_test_formula "bar" - - (HOMEBREW_CELLAR/"bar/1.0").mkpath - assert_match "foo", cmd("missing") - end - - def test_doctor - assert_match "This is an integration test", - cmd_fail("doctor", "check_integration_test") - end - - def test_command - assert_equal "#{HOMEBREW_LIBRARY_PATH}/cmd/info.rb", - cmd("command", "info") - - assert_match "Unknown command", - cmd_fail("command", "I-don't-exist") - end - - def test_commands - assert_match "Built-in commands", - cmd("commands") - end - - def test_cat - formula_file = setup_test_formula "testball" - assert_equal formula_file.read.chomp, cmd("cat", "testball") - end - - def test_desc - setup_test_formula "testball" - - assert_equal "testball: Some test", cmd("desc", "testball") - assert_match "Pick one, and only one", cmd_fail("desc", "--search", "--name") - assert_match "You must provide a search term", cmd_fail("desc", "--search") - - desc_cache = HOMEBREW_CACHE/"desc_cache.json" - refute_predicate desc_cache, :exist?, "Cached file should not exist" - - cmd("desc", "--description", "testball") - assert_predicate desc_cache, :exist?, "Cached file should not exist" - end - - def test_edit - (HOMEBREW_REPOSITORY/".git").mkpath - setup_test_formula "testball" - - assert_match "# something here", - cmd("edit", "testball", "HOMEBREW_EDITOR" => "/bin/cat") - end - - def test_sh - assert_match "Your shell has been configured", - cmd("sh", "SHELL" => which("true")) - end - - def test_info - setup_test_formula "testball" - - assert_match "testball: stable 0.1", - cmd("info", "testball") - end - - def test_tap_readme - assert_match "brew install homebrew/foo/", - cmd("tap-readme", "foo", "--verbose") - readme = HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo/README.md" - assert readme.exist?, "The README should be created" - end - - def test_unpack - setup_test_formula "testball" - - mktmpdir do |path| - cmd "unpack", "testball", "--destdir=#{path}" - assert File.directory?("#{path}/testball-0.1"), - "The tarball should be unpacked" - end - end - - def test_options - setup_test_formula "testball", <<-EOS.undent - depends_on "bar" => :recommended - EOS - - assert_equal "--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support", - cmd_output("options", "testball").chomp - end - - def test_outdated - setup_test_formula "testball" - (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath - - assert_equal "testball", cmd("outdated") - end - - def test_upgrade - setup_test_formula "testball" - (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath - - cmd("upgrade") - assert((HOMEBREW_CELLAR/"testball/0.1").directory?, - "The latest version directory should be created") - end - - def test_linkapps - home_dir = Pathname.new(mktmpdir) - (home_dir/"Applications").mkpath - - setup_test_formula "testball" - - source_dir = HOMEBREW_CELLAR/"testball/0.1/TestBall.app" - source_dir.mkpath - assert_match "Linking: #{source_dir}", - cmd("linkapps", "--local", "HOME" => home_dir) - end - - def test_unlinkapps - home_dir = Pathname.new(mktmpdir) - apps_dir = home_dir/"Applications" - apps_dir.mkpath - - setup_test_formula "testball" - - source_app = (HOMEBREW_CELLAR/"testball/0.1/TestBall.app") - source_app.mkpath - - FileUtils.ln_s source_app, "#{apps_dir}/TestBall.app" - - assert_match "Unlinking: #{apps_dir}/TestBall.app", - cmd("unlinkapps", "--local", "HOME" => home_dir) - end - - def test_pin_unpin - setup_test_formula "testball" - (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath - - cmd("pin", "testball") - cmd("upgrade") - refute((HOMEBREW_CELLAR/"testball/0.1").directory?, - "The latest version directory should NOT be created") - - cmd("unpin", "testball") - cmd("upgrade") - assert((HOMEBREW_CELLAR/"testball/0.1").directory?, - "The latest version directory should be created") - end - - def test_reinstall - setup_test_formula "testball" - - cmd("install", "testball", "--with-foo") - foo_dir = HOMEBREW_CELLAR/"testball/0.1/foo" - assert foo_dir.exist? - foo_dir.rmtree - assert_match "Reinstalling testball with --with-foo", - cmd("reinstall", "testball") - assert foo_dir.exist? - end - - def test_reinstall_pinned - setup_test_formula "testball" - - HOMEBREW_CELLAR.join("testball/0.1").mkpath - HOMEBREW_PINNED_KEGS.mkpath - FileUtils.ln_s HOMEBREW_CELLAR.join("testball/0.1"), HOMEBREW_PINNED_KEGS/"testball" - - assert_match "testball is pinned. You must unpin it to reinstall.", cmd("reinstall", "testball") - - HOMEBREW_PINNED_KEGS.rmtree - end - - def test_home - setup_test_formula "testball" - - assert_equal HOMEBREW_WWW, - cmd("home", "HOMEBREW_BROWSER" => "echo") - assert_equal Formula["testball"].homepage, - cmd("home", "testball", "HOMEBREW_BROWSER" => "echo") - end - - def test_list - formulae = %w[bar foo qux] - formulae.each do |f| - (HOMEBREW_CELLAR/"#{f}/1.0/somedir").mkpath - end - - assert_equal formulae.join("\n"), - cmd("list") - end - - def test_create - url = "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" - cmd("create", url, "HOMEBREW_EDITOR" => "/bin/cat") - - formula_file = CoreTap.new.formula_dir/"testball.rb" - assert formula_file.exist?, "The formula source should have been created" - assert_match %(sha256 "#{TESTBALL_SHA256}"), formula_file.read - end - - def test_fetch - setup_test_formula "testball" - - cmd("fetch", "testball") - assert((HOMEBREW_CACHE/"testball-0.1.tbz").exist?, - "The tarball should have been cached") - end - - def test_deps - setup_test_formula "foo" - setup_test_formula "bar" - setup_test_formula "baz", <<-EOS.undent - url "https://example.com/baz-1.0" - depends_on "bar" - EOS - - assert_equal "", cmd("deps", "foo") - assert_equal "foo", cmd("deps", "bar") - assert_equal "bar\nfoo", cmd("deps", "baz") - end - - def test_uses - setup_test_formula "foo" - setup_test_formula "bar" - setup_test_formula "baz", <<-EOS.undent - url "https://example.com/baz-1.0" - depends_on "bar" - EOS - - assert_equal "", cmd("uses", "baz") - assert_equal "baz", cmd("uses", "bar") - assert_equal "bar\nbaz", cmd("uses", "--recursive", "foo") - end - - def test_log - FileUtils.cd HOMEBREW_REPOSITORY do - shutup do - system "git", "init" - system "git", "commit", "--allow-empty", "-m", "This is a test commit" - end - end - assert_match "This is a test commit", cmd("log") - end - - def test_log_formula - core_tap = CoreTap.new - setup_test_formula "testball" - - core_tap.path.cd do - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", "This is a test commit for Testball" - end - end - - core_tap_url = "file://#{core_tap.path}" - shallow_tap = Tap.fetch("homebrew", "shallow") - shutup do - system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path - end - - assert_match "This is a test commit for Testball", - cmd("log", "#{shallow_tap}/testball") - assert_predicate shallow_tap.path/".git/shallow", :exist?, - "A shallow clone should have been created." - end - - def test_leaves - setup_test_formula "foo" - setup_test_formula "bar" - assert_equal "", cmd("leaves") - - (HOMEBREW_CELLAR/"foo/0.1/somedir").mkpath - assert_equal "foo", cmd("leaves") - - (HOMEBREW_CELLAR/"bar/0.1/somedir").mkpath - assert_equal "bar", cmd("leaves") - end - - def test_prune - share = (HOMEBREW_PREFIX/"share") - - (share/"pruneable/directory/here").mkpath - (share/"notpruneable/file").write "I'm here" - FileUtils.ln_s "/i/dont/exist/no/really/i/dont", share/"pruneable_symlink" - - assert_match %r{Would remove \(empty directory\): .*/pruneable/directory/here}, - cmd("prune", "--dry-run") - assert_match "Pruned 1 symbolic links and 3 directories", - cmd("prune") - refute((share/"pruneable").directory?) - assert((share/"notpruneable").directory?) - refute((share/"pruneable_symlink").symlink?) - - assert_match "Nothing pruned", cmd("prune", "--verbose") - end - - def test_custom_command - mktmpdir do |path| - cmd = "int-test-#{rand}" - file = "#{path}/brew-#{cmd}" - - File.open(file, "w") { |f| f.write "#!/bin/sh\necho 'I am #{cmd}'\n" } - FileUtils.chmod 0777, file - - assert_match "I am #{cmd}", - cmd(cmd, "PATH" => "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}") - end - end - - def test_search - setup_test_formula "testball" - desc_cache = HOMEBREW_CACHE/"desc_cache.json" - refute_predicate desc_cache, :exist?, "Cached file should not exist" - - assert_match "testball", cmd("search") - assert_match "testball", cmd("search", "testball") - assert_match "testball", cmd("search", "homebrew/homebrew-core/testball") - assert_match "testball", cmd("search", "--desc", "Some test") - - flags = { - "macports" => "https://www.macports.org/ports.php?by=name&substr=testball", - "fink" => "http://pdb.finkproject.org/pdb/browse.php?summary=testball", - "debian" => "https://packages.debian.org/search?keywords=testball&searchon=names&suite=all§ion=all", - "opensuse" => "https://software.opensuse.org/search?q=testball", - "fedora" => "https://admin.fedoraproject.org/pkgdb/packages/%2Atestball%2A/", - "ubuntu" => "http://packages.ubuntu.com/search?keywords=testball&searchon=names&suite=all§ion=all", - } - - flags.each do |flag, url| - assert_equal url, cmd("search", "--#{flag}", - "testball", "HOMEBREW_BROWSER" => "echo") - end - - assert_predicate desc_cache, :exist?, "Cached file should exist" - end - - def test_bundle - needs_test_cmd_taps - setup_remote_tap("homebrew/bundle") - HOMEBREW_REPOSITORY.cd do - shutup do - system "git", "init" - system "git", "commit", "--allow-empty", "-m", "This is a test commit" - end - end - - mktmpdir do |path| - FileUtils.touch "#{path}/Brewfile" - Dir.chdir path do - assert_equal "The Brewfile's dependencies are satisfied.", - cmd("bundle", "check") - end - end - end - - def test_cask - needs_test_cmd_taps - needs_macos - setup_remote_tap("caskroom/cask") - cmd("cask", "list") - end - - def test_services - needs_test_cmd_taps - needs_macos - setup_remote_tap("homebrew/services") - assert_equal "Warning: No services available to control with `brew services`", - cmd("services", "list") - end - - def test_link - assert_match "This command requires a keg argument", cmd_fail("link") - - setup_test_formula "testball1" - cmd("install", "testball1") - cmd("link", "testball1") - - cmd("unlink", "testball1") - assert_match "Would link", cmd("link", "--dry-run", "testball1") - assert_match "Would remove", - cmd("link", "--dry-run", "--overwrite", "testball1") - assert_match "Linking", cmd("link", "testball1") - - setup_test_formula "testball2", <<-EOS.undent - keg_only "just because" - EOS - cmd("install", "testball2") - assert_match "testball2 is keg-only", cmd("link", "testball2") - end - - def test_unlink - setup_test_formula "testball" - - cmd("install", "testball") - assert_match "Would remove", cmd("unlink", "--dry-run", "testball") - end - - def test_irb - assert_match "'v8'.f # => instance of the v8 formula", - cmd("irb", "--examples") - - setup_test_formula "testball" - - irb_test = HOMEBREW_TEMP/"irb-test.rb" - irb_test.write <<-EOS.undent - "testball".f - :testball.f - exit - EOS - - assert_match "Interactive Homebrew Shell", cmd("irb", irb_test) - end - - def test_pull_offline - assert_match "You meant `git pull --rebase`.", cmd_fail("pull", "--rebase") - assert_match "This command requires at least one argument", cmd_fail("pull") - assert_match "Not a GitHub pull request or commit", - cmd_fail("pull", "0") - end - - def test_pull - skip "Requires network connection" if ENV["HOMEBREW_NO_GITHUB_API"] - - core_tap = CoreTap.new - core_tap.path.cd do - shutup do - system "git", "init" - system "git", "checkout", "-b", "new-branch" - end - end - - assert_match "Testing URLs require `--bottle`!", - cmd_fail("pull", "https://bot.brew.sh/job/Homebrew\%20Testing/1028/") - assert_match "Current branch is new-branch", - cmd_fail("pull", "1") - assert_match "No changed formulae found to bump", - cmd_fail("pull", "--bump", "8") - assert_match "Can only bump one changed formula", - cmd_fail("pull", "--bump", - "https://api.github.com/repos/Homebrew/homebrew-core/pulls/122") - assert_match "Patch failed to apply", - cmd_fail("pull", "https://github.com/Homebrew/homebrew-core/pull/1") - end - - def test_analytics - HOMEBREW_REPOSITORY.cd do - shutup do - system "git", "init" - end - end - - assert_match "Analytics is disabled (by HOMEBREW_NO_ANALYTICS)", - cmd("analytics", "HOMEBREW_NO_ANALYTICS" => "1") - - cmd("analytics", "off") - assert_match "Analytics is disabled", - cmd("analytics", "HOMEBREW_NO_ANALYTICS" => nil) - - cmd("analytics", "on") - assert_match "Analytics is enabled", cmd("analytics", - "HOMEBREW_NO_ANALYTICS" => nil) - - assert_match "Invalid usage", cmd_fail("analytics", "on", "off") - assert_match "Invalid usage", cmd_fail("analytics", "testball") - cmd("analytics", "regenerate-uuid") - end - - def test_migrate - setup_test_formula "testball1" - setup_test_formula "testball2" - assert_match "Invalid usage", cmd_fail("migrate") - assert_match "No available formula with the name \"testball\"", - cmd_fail("migrate", "testball") - assert_match "testball1 doesn't replace any formula", - cmd_fail("migrate", "testball1") - - install_and_rename_coretap_formula "testball1", "testball2" - assert_match "Migrating testball1 to testball2", cmd("migrate", "testball1") - (HOMEBREW_CELLAR/"testball1").unlink - assert_match "Error: No such keg", cmd_fail("migrate", "testball1") - end - - def test_switch - assert_match "Usage: brew switch ", cmd_fail("switch") - assert_match "testball not found", cmd_fail("switch", "testball", "0.1") - - setup_test_formula "testball", <<-EOS.undent - keg_only "just because" - EOS - - cmd("install", "testball") - testball_rack = HOMEBREW_CELLAR/"testball" - FileUtils.cp_r testball_rack/"0.1", testball_rack/"0.2" - - cmd("switch", "testball", "0.2") - assert_match "testball does not have a version \"0.3\"", - cmd_fail("switch", "testball", "0.3") - end - - def test_test_formula - assert_match "This command requires a formula argument", cmd_fail("test") - assert_match "Testing requires the latest version of testball", - cmd_fail("test", testball) - - cmd("install", testball) - assert_match "testball defines no test", cmd_fail("test", testball) - - setup_test_formula "testball_copy", <<-EOS.undent - head "https://github.com/example/testball2.git" - - devel do - url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" - sha256 "#{TESTBALL_SHA256}" - end - - keg_only "just because" - - test do - end - EOS - - cmd("install", "testball_copy") - assert_match "Testing testball_copy", cmd("test", "--HEAD", "testball_copy") - assert_match "Testing testball_copy", cmd("test", "--devel", "testball_copy") - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_analytics.rb b/Library/Homebrew/test/test_integration_cmds_analytics.rb new file mode 100644 index 0000000000..17afe7fe85 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_analytics.rb @@ -0,0 +1,26 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestAnalytics < IntegrationCommandTests + def test_analytics + HOMEBREW_REPOSITORY.cd do + shutup do + system "git", "init" + end + end + + assert_match "Analytics is disabled (by HOMEBREW_NO_ANALYTICS)", + cmd("analytics", "HOMEBREW_NO_ANALYTICS" => "1") + + cmd("analytics", "off") + assert_match "Analytics is disabled", + cmd("analytics", "HOMEBREW_NO_ANALYTICS" => nil) + + cmd("analytics", "on") + assert_match "Analytics is enabled", cmd("analytics", + "HOMEBREW_NO_ANALYTICS" => nil) + + assert_match "Invalid usage", cmd_fail("analytics", "on", "off") + assert_match "Invalid usage", cmd_fail("analytics", "testball") + cmd("analytics", "regenerate-uuid") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_bottle.rb b/Library/Homebrew/test/test_integration_cmds_bottle.rb new file mode 100644 index 0000000000..b6d9de714c --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_bottle.rb @@ -0,0 +1,21 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestBottle < IntegrationCommandTests + def test_bottle + cmd("install", "--build-bottle", testball) + assert_match "Formula not from core or any taps", + cmd_fail("bottle", "--no-rebuild", testball) + + setup_test_formula "testball" + + # `brew bottle` should not fail with dead symlink + # https://github.com/Homebrew/legacy-homebrew/issues/49007 + (HOMEBREW_CELLAR/"testball/0.1").cd do + FileUtils.ln_s "not-exist", "symlink" + end + assert_match(/testball-0\.1.*\.bottle\.tar\.gz/, + cmd_output("bottle", "--no-rebuild", "testball")) + ensure + FileUtils.rm_f Dir["testball-0.1*.bottle.tar.gz"] + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_bundle.rb b/Library/Homebrew/test/test_integration_cmds_bundle.rb new file mode 100644 index 0000000000..726bd4d106 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_bundle.rb @@ -0,0 +1,22 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestBundle < IntegrationCommandTests + def test_bundle + needs_test_cmd_taps + setup_remote_tap("homebrew/bundle") + HOMEBREW_REPOSITORY.cd do + shutup do + system "git", "init" + system "git", "commit", "--allow-empty", "-m", "This is a test commit" + end + end + + mktmpdir do |path| + FileUtils.touch "#{path}/Brewfile" + Dir.chdir path do + assert_equal "The Brewfile's dependencies are satisfied.", + cmd("bundle", "check") + end + end + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_cache.rb b/Library/Homebrew/test/test_integration_cmds_cache.rb new file mode 100644 index 0000000000..716724f4f9 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_cache.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCache < IntegrationCommandTests + def test_cache + assert_equal HOMEBREW_CACHE.to_s, + cmd("--cache") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_cache_formula.rb b/Library/Homebrew/test/test_integration_cmds_cache_formula.rb new file mode 100644 index 0000000000..82c3421b24 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_cache_formula.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCacheFormula < IntegrationCommandTests + def test_cache_formula + assert_match %r{#{HOMEBREW_CACHE}/testball-}, + cmd("--cache", testball) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_cask.rb b/Library/Homebrew/test/test_integration_cmds_cask.rb new file mode 100644 index 0000000000..e97bb868c5 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_cask.rb @@ -0,0 +1,10 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCask < IntegrationCommandTests + def test_cask + needs_test_cmd_taps + needs_macos + setup_remote_tap("caskroom/cask") + cmd("cask", "list") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_cat.rb b/Library/Homebrew/test/test_integration_cmds_cat.rb new file mode 100644 index 0000000000..ad4ef199b6 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_cat.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCat < IntegrationCommandTests + def test_cat + formula_file = setup_test_formula "testball" + assert_equal formula_file.read.chomp, cmd("cat", "testball") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_cellar.rb b/Library/Homebrew/test/test_integration_cmds_cellar.rb new file mode 100644 index 0000000000..3adb8fccad --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_cellar.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCellar < IntegrationCommandTests + def test_cellar + assert_equal HOMEBREW_CELLAR.to_s, + cmd("--cellar") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_cellar_formula.rb b/Library/Homebrew/test/test_integration_cmds_cellar_formula.rb new file mode 100644 index 0000000000..356c79d6d4 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_cellar_formula.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCellarFormula < IntegrationCommandTests + def test_cellar_formula + assert_match "#{HOMEBREW_CELLAR}/testball", + cmd("--cellar", testball) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_cleanup.rb b/Library/Homebrew/test/test_integration_cmds_cleanup.rb new file mode 100644 index 0000000000..fe9ce9952c --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_cleanup.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCleanup < IntegrationCommandTests + def test_cleanup + (HOMEBREW_CACHE/"test").write "test" + assert_match "#{HOMEBREW_CACHE}/test", cmd("cleanup", "--prune=all") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_command.rb b/Library/Homebrew/test/test_integration_cmds_command.rb new file mode 100644 index 0000000000..33cfdc8ed5 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_command.rb @@ -0,0 +1,11 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCommand < IntegrationCommandTests + def test_command + assert_equal "#{HOMEBREW_LIBRARY_PATH}/cmd/info.rb", + cmd("command", "info") + + assert_match "Unknown command", + cmd_fail("command", "I-don't-exist") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_commands.rb b/Library/Homebrew/test/test_integration_cmds_commands.rb new file mode 100644 index 0000000000..47c4e25ca6 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_commands.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCommands < IntegrationCommandTests + def test_commands + assert_match "Built-in commands", + cmd("commands") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_config.rb b/Library/Homebrew/test/test_integration_cmds_config.rb new file mode 100644 index 0000000000..f1cb5cb7e9 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_config.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestConfig < IntegrationCommandTests + def test_config + assert_match "HOMEBREW_VERSION: #{HOMEBREW_VERSION}", + cmd("config") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_create.rb b/Library/Homebrew/test/test_integration_cmds_create.rb new file mode 100644 index 0000000000..20765f9c82 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_create.rb @@ -0,0 +1,12 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCreate < IntegrationCommandTests + def test_create + url = "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" + cmd("create", url, "HOMEBREW_EDITOR" => "/bin/cat") + + formula_file = CoreTap.new.formula_dir/"testball.rb" + assert formula_file.exist?, "The formula source should have been created" + assert_match %(sha256 "#{TESTBALL_SHA256}"), formula_file.read + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_custom_command.rb b/Library/Homebrew/test/test_integration_cmds_custom_command.rb new file mode 100644 index 0000000000..3ea2e6360d --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_custom_command.rb @@ -0,0 +1,16 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestCustomCommand < IntegrationCommandTests + def test_custom_command + mktmpdir do |path| + cmd = "int-test-#{rand}" + file = "#{path}/brew-#{cmd}" + + File.open(file, "w") { |f| f.write "#!/bin/sh\necho 'I am #{cmd}'\n" } + FileUtils.chmod 0777, file + + assert_match "I am #{cmd}", + cmd(cmd, "PATH" => "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}") + end + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_deps.rb b/Library/Homebrew/test/test_integration_cmds_deps.rb new file mode 100644 index 0000000000..10a654b60c --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_deps.rb @@ -0,0 +1,16 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestDeps < IntegrationCommandTests + def test_deps + setup_test_formula "foo" + setup_test_formula "bar" + setup_test_formula "baz", <<-EOS.undent + url "https://example.com/baz-1.0" + depends_on "bar" + EOS + + assert_equal "", cmd("deps", "foo") + assert_equal "foo", cmd("deps", "bar") + assert_equal "bar\nfoo", cmd("deps", "baz") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_desc.rb b/Library/Homebrew/test/test_integration_cmds_desc.rb new file mode 100644 index 0000000000..e93b715782 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_desc.rb @@ -0,0 +1,17 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestDesc < IntegrationCommandTests + def test_desc + setup_test_formula "testball" + + assert_equal "testball: Some test", cmd("desc", "testball") + assert_match "Pick one, and only one", cmd_fail("desc", "--search", "--name") + assert_match "You must provide a search term", cmd_fail("desc", "--search") + + desc_cache = HOMEBREW_CACHE/"desc_cache.json" + refute_predicate desc_cache, :exist?, "Cached file should not exist" + + cmd("desc", "--description", "testball") + assert_predicate desc_cache, :exist?, "Cached file should not exist" + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_doctor.rb b/Library/Homebrew/test/test_integration_cmds_doctor.rb new file mode 100644 index 0000000000..e3edf1b0f5 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_doctor.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestDoctor < IntegrationCommandTests + def test_doctor + assert_match "This is an integration test", + cmd_fail("doctor", "check_integration_test") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_edit.rb b/Library/Homebrew/test/test_integration_cmds_edit.rb new file mode 100644 index 0000000000..b47e0d4f9a --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_edit.rb @@ -0,0 +1,11 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestEdit < IntegrationCommandTests + def test_edit + (HOMEBREW_REPOSITORY/".git").mkpath + setup_test_formula "testball" + + assert_match "# something here", + cmd("edit", "testball", "HOMEBREW_EDITOR" => "/bin/cat") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_env.rb b/Library/Homebrew/test/test_integration_cmds_env.rb new file mode 100644 index 0000000000..9f6fc7cbb4 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_env.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestEnv < IntegrationCommandTests + def test_env + assert_match(/CMAKE_PREFIX_PATH="#{Regexp.escape(HOMEBREW_PREFIX)}[:"]/, + cmd("--env")) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_env_bash.rb b/Library/Homebrew/test/test_integration_cmds_env_bash.rb new file mode 100644 index 0000000000..71f807199f --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_env_bash.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestEnvBash < IntegrationCommandTests + def test_env_bash + assert_match(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/, + cmd("--env", "--shell=bash")) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_env_csh.rb b/Library/Homebrew/test/test_integration_cmds_env_csh.rb new file mode 100644 index 0000000000..19a6ed7d2f --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_env_csh.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestEnvCsh < IntegrationCommandTests + def test_env_csh + assert_match(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/, + cmd("--env", "--shell=tcsh")) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_env_fish.rb b/Library/Homebrew/test/test_integration_cmds_env_fish.rb new file mode 100644 index 0000000000..9c4bf0e16d --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_env_fish.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestEnvFish < IntegrationCommandTests + def test_env_fish + assert_match(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/, + cmd("--env", "--shell=fish")) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_env_plain.rb b/Library/Homebrew/test/test_integration_cmds_env_plain.rb new file mode 100644 index 0000000000..a21ad7f033 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_env_plain.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestEnvPlain < IntegrationCommandTests + def test_env_plain + assert_match(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/, + cmd("--env", "--plain")) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_fetch.rb b/Library/Homebrew/test/test_integration_cmds_fetch.rb new file mode 100644 index 0000000000..9c060a3538 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_fetch.rb @@ -0,0 +1,11 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestFetch < IntegrationCommandTests + def test_fetch + setup_test_formula "testball" + + cmd("fetch", "testball") + assert((HOMEBREW_CACHE/"testball-0.1.tbz").exist?, + "The tarball should have been cached") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_help.rb b/Library/Homebrew/test/test_integration_cmds_help.rb new file mode 100644 index 0000000000..44fd774c97 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_help.rb @@ -0,0 +1,21 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestHelp < IntegrationCommandTests + def test_help + assert_match "Example usage:\n", + cmd_fail # Generic help (empty argument list). + assert_match "Unknown command: command-that-does-not-exist", + cmd_fail("help", "command-that-does-not-exist") + assert_match(/^brew cat /, + cmd_fail("cat")) # Missing formula argument triggers help. + + assert_match "Example usage:\n", + cmd("help") # Generic help. + assert_match(/^brew cat /, + cmd("help", "cat")) # Internal command (documented, Ruby). + assert_match(/^brew update /, + cmd("help", "update")) # Internal command (documented, Shell). + assert_match(/^brew update-test /, + cmd("help", "update-test")) # Internal developer command (documented, Ruby). + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_home.rb b/Library/Homebrew/test/test_integration_cmds_home.rb new file mode 100644 index 0000000000..ef21e85ca1 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_home.rb @@ -0,0 +1,12 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestHome < IntegrationCommandTests + def test_home + setup_test_formula "testball" + + assert_equal HOMEBREW_WWW, + cmd("home", "HOMEBREW_BROWSER" => "echo") + assert_equal Formula["testball"].homepage, + cmd("home", "testball", "HOMEBREW_BROWSER" => "echo") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_info.rb b/Library/Homebrew/test/test_integration_cmds_info.rb new file mode 100644 index 0000000000..acb272d15b --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_info.rb @@ -0,0 +1,10 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestInfo < IntegrationCommandTests + def test_info + setup_test_formula "testball" + + assert_match "testball: stable 0.1", + cmd("info", "testball") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_install.rb b/Library/Homebrew/test/test_integration_cmds_install.rb new file mode 100644 index 0000000000..7ce4a3484d --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_install.rb @@ -0,0 +1,24 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestInstall < IntegrationCommandTests + def test_install + setup_test_formula "testball1" + assert_match "Specify `--HEAD`", cmd_fail("install", "testball1", "--head") + assert_match "No head is defined", cmd_fail("install", "testball1", "--HEAD") + assert_match "No devel block", cmd_fail("install", "testball1", "--devel") + assert_match "#{HOMEBREW_CELLAR}/testball1/0.1", cmd("install", "testball1") + assert_match "testball1-0.1 already installed", cmd("install", "testball1") + assert_match "MacRuby is not packaged", cmd_fail("install", "macruby") + assert_match "No available formula", cmd_fail("install", "formula") + assert_match "This similarly named formula was found", + cmd_fail("install", "testball") + + setup_test_formula "testball2" + assert_match "These similarly named formulae were found", + cmd_fail("install", "testball") + + install_and_rename_coretap_formula "testball1", "testball2" + assert_match "testball1 already installed, it's just not migrated", + cmd("install", "testball2") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_irb.rb b/Library/Homebrew/test/test_integration_cmds_irb.rb new file mode 100644 index 0000000000..338b32fd97 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_irb.rb @@ -0,0 +1,19 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestIrb < IntegrationCommandTests + def test_irb + assert_match "'v8'.f # => instance of the v8 formula", + cmd("irb", "--examples") + + setup_test_formula "testball" + + irb_test = HOMEBREW_TEMP/"irb-test.rb" + irb_test.write <<-EOS.undent + "testball".f + :testball.f + exit + EOS + + assert_match "Interactive Homebrew Shell", cmd("irb", irb_test) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_leaves.rb b/Library/Homebrew/test/test_integration_cmds_leaves.rb new file mode 100644 index 0000000000..2ea7779d69 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_leaves.rb @@ -0,0 +1,15 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestLeaves < IntegrationCommandTests + def test_leaves + setup_test_formula "foo" + setup_test_formula "bar" + assert_equal "", cmd("leaves") + + (HOMEBREW_CELLAR/"foo/0.1/somedir").mkpath + assert_equal "foo", cmd("leaves") + + (HOMEBREW_CELLAR/"bar/0.1/somedir").mkpath + assert_equal "bar", cmd("leaves") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_link.rb b/Library/Homebrew/test/test_integration_cmds_link.rb new file mode 100644 index 0000000000..8c4255476f --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_link.rb @@ -0,0 +1,23 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestLink < IntegrationCommandTests + def test_link + assert_match "This command requires a keg argument", cmd_fail("link") + + setup_test_formula "testball1" + cmd("install", "testball1") + cmd("link", "testball1") + + cmd("unlink", "testball1") + assert_match "Would link", cmd("link", "--dry-run", "testball1") + assert_match "Would remove", + cmd("link", "--dry-run", "--overwrite", "testball1") + assert_match "Linking", cmd("link", "testball1") + + setup_test_formula "testball2", <<-EOS.undent + keg_only "just because" + EOS + cmd("install", "testball2") + assert_match "testball2 is keg-only", cmd("link", "testball2") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_linkapps.rb b/Library/Homebrew/test/test_integration_cmds_linkapps.rb new file mode 100644 index 0000000000..9afb84b77b --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_linkapps.rb @@ -0,0 +1,15 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestLinkapps < IntegrationCommandTests + def test_linkapps + home_dir = Pathname.new(mktmpdir) + (home_dir/"Applications").mkpath + + setup_test_formula "testball" + + source_dir = HOMEBREW_CELLAR/"testball/0.1/TestBall.app" + source_dir.mkpath + assert_match "Linking: #{source_dir}", + cmd("linkapps", "--local", "HOME" => home_dir) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_list.rb b/Library/Homebrew/test/test_integration_cmds_list.rb new file mode 100644 index 0000000000..917366905f --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_list.rb @@ -0,0 +1,13 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestList < IntegrationCommandTests + def test_list + formulae = %w[bar foo qux] + formulae.each do |f| + (HOMEBREW_CELLAR/"#{f}/1.0/somedir").mkpath + end + + assert_equal formulae.join("\n"), + cmd("list") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_log.rb b/Library/Homebrew/test/test_integration_cmds_log.rb new file mode 100644 index 0000000000..1799d777db --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_log.rb @@ -0,0 +1,13 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestLog < IntegrationCommandTests + def test_log + FileUtils.cd HOMEBREW_REPOSITORY do + shutup do + system "git", "init" + system "git", "commit", "--allow-empty", "-m", "This is a test commit" + end + end + assert_match "This is a test commit", cmd("log") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_log_formula.rb b/Library/Homebrew/test/test_integration_cmds_log_formula.rb new file mode 100644 index 0000000000..2f1f44d005 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_log_formula.rb @@ -0,0 +1,27 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestLogFormula < IntegrationCommandTests + def test_log_formula + core_tap = CoreTap.new + setup_test_formula "testball" + + core_tap.path.cd do + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "This is a test commit for Testball" + end + end + + core_tap_url = "file://#{core_tap.path}" + shallow_tap = Tap.fetch("homebrew", "shallow") + shutup do + system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path + end + + assert_match "This is a test commit for Testball", + cmd("log", "#{shallow_tap}/testball") + assert_predicate shallow_tap.path/".git/shallow", :exist?, + "A shallow clone should have been created." + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_migrate.rb b/Library/Homebrew/test/test_integration_cmds_migrate.rb new file mode 100644 index 0000000000..3918cbb3e6 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_migrate.rb @@ -0,0 +1,18 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestMigrate < IntegrationCommandTests + def test_migrate + setup_test_formula "testball1" + setup_test_formula "testball2" + assert_match "Invalid usage", cmd_fail("migrate") + assert_match "No available formula with the name \"testball\"", + cmd_fail("migrate", "testball") + assert_match "testball1 doesn't replace any formula", + cmd_fail("migrate", "testball1") + + install_and_rename_coretap_formula "testball1", "testball2" + assert_match "Migrating testball1 to testball2", cmd("migrate", "testball1") + (HOMEBREW_CELLAR/"testball1").unlink + assert_match "Error: No such keg", cmd_fail("migrate", "testball1") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_missing.rb b/Library/Homebrew/test/test_integration_cmds_missing.rb new file mode 100644 index 0000000000..68c3a72a45 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_missing.rb @@ -0,0 +1,11 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestMissing < IntegrationCommandTests + def test_missing + setup_test_formula "foo" + setup_test_formula "bar" + + (HOMEBREW_CELLAR/"bar/1.0").mkpath + assert_match "foo", cmd("missing") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_options.rb b/Library/Homebrew/test/test_integration_cmds_options.rb new file mode 100644 index 0000000000..de527804c0 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_options.rb @@ -0,0 +1,12 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestOptions < IntegrationCommandTests + def test_options + setup_test_formula "testball", <<-EOS.undent + depends_on "bar" => :recommended + EOS + + assert_equal "--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support", + cmd_output("options", "testball").chomp + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_outdated.rb b/Library/Homebrew/test/test_integration_cmds_outdated.rb new file mode 100644 index 0000000000..b42e7bc1a2 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_outdated.rb @@ -0,0 +1,10 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestOutdated < IntegrationCommandTests + def test_outdated + setup_test_formula "testball" + (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath + + assert_equal "testball", cmd("outdated") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_pin_unpin.rb b/Library/Homebrew/test/test_integration_cmds_pin_unpin.rb new file mode 100644 index 0000000000..828ca49c04 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_pin_unpin.rb @@ -0,0 +1,18 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestPinUnpin < IntegrationCommandTests + def test_pin_unpin + setup_test_formula "testball" + (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath + + cmd("pin", "testball") + cmd("upgrade") + refute((HOMEBREW_CELLAR/"testball/0.1").directory?, + "The latest version directory should NOT be created") + + cmd("unpin", "testball") + cmd("upgrade") + assert((HOMEBREW_CELLAR/"testball/0.1").directory?, + "The latest version directory should be created") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_prefix.rb b/Library/Homebrew/test/test_integration_cmds_prefix.rb new file mode 100644 index 0000000000..80a71c5ec9 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_prefix.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestPrefix < IntegrationCommandTests + def test_prefix + assert_equal HOMEBREW_PREFIX.to_s, + cmd("--prefix") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_prefix_formula.rb b/Library/Homebrew/test/test_integration_cmds_prefix_formula.rb new file mode 100644 index 0000000000..a901309cf7 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_prefix_formula.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestPrefixFormula < IntegrationCommandTests + def test_prefix_formula + assert_match "#{HOMEBREW_CELLAR}/testball", + cmd("--prefix", testball) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_prune.rb b/Library/Homebrew/test/test_integration_cmds_prune.rb new file mode 100644 index 0000000000..6072c832eb --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_prune.rb @@ -0,0 +1,21 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestPrune < IntegrationCommandTests + def test_prune + share = (HOMEBREW_PREFIX/"share") + + (share/"pruneable/directory/here").mkpath + (share/"notpruneable/file").write "I'm here" + FileUtils.ln_s "/i/dont/exist/no/really/i/dont", share/"pruneable_symlink" + + assert_match %r{Would remove \(empty directory\): .*/pruneable/directory/here}, + cmd("prune", "--dry-run") + assert_match "Pruned 1 symbolic links and 3 directories", + cmd("prune") + refute((share/"pruneable").directory?) + assert((share/"notpruneable").directory?) + refute((share/"pruneable_symlink").symlink?) + + assert_match "Nothing pruned", cmd("prune", "--verbose") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_pull.rb b/Library/Homebrew/test/test_integration_cmds_pull.rb new file mode 100644 index 0000000000..1cfb286a3f --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_pull.rb @@ -0,0 +1,27 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestPull < IntegrationCommandTests + def test_pull + skip "Requires network connection" if ENV["HOMEBREW_NO_GITHUB_API"] + + core_tap = CoreTap.new + core_tap.path.cd do + shutup do + system "git", "init" + system "git", "checkout", "-b", "new-branch" + end + end + + assert_match "Testing URLs require `--bottle`!", + cmd_fail("pull", "https://bot.brew.sh/job/Homebrew\%20Testing/1028/") + assert_match "Current branch is new-branch", + cmd_fail("pull", "1") + assert_match "No changed formulae found to bump", + cmd_fail("pull", "--bump", "8") + assert_match "Can only bump one changed formula", + cmd_fail("pull", "--bump", + "https://api.github.com/repos/Homebrew/homebrew-core/pulls/122") + assert_match "Patch failed to apply", + cmd_fail("pull", "https://github.com/Homebrew/homebrew-core/pull/1") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_pull_offline.rb b/Library/Homebrew/test/test_integration_cmds_pull_offline.rb new file mode 100644 index 0000000000..bb6fd24cff --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_pull_offline.rb @@ -0,0 +1,10 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestPullOffline < IntegrationCommandTests + def test_pull_offline + assert_match "You meant `git pull --rebase`.", cmd_fail("pull", "--rebase") + assert_match "This command requires at least one argument", cmd_fail("pull") + assert_match "Not a GitHub pull request or commit", + cmd_fail("pull", "0") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_readall.rb b/Library/Homebrew/test/test_integration_cmds_readall.rb new file mode 100644 index 0000000000..1a6ca45471 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_readall.rb @@ -0,0 +1,12 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestReadall < IntegrationCommandTests + def test_readall + formula_file = setup_test_formula "testball" + alias_file = CoreTap.new.alias_dir/"foobar" + alias_file.parent.mkpath + FileUtils.ln_s formula_file, alias_file + cmd("readall", "--aliases", "--syntax") + cmd("readall", "homebrew/core") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_reinstall.rb b/Library/Homebrew/test/test_integration_cmds_reinstall.rb new file mode 100644 index 0000000000..ce1c0c9196 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_reinstall.rb @@ -0,0 +1,15 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestReinstall < IntegrationCommandTests + def test_reinstall + setup_test_formula "testball" + + cmd("install", "testball", "--with-foo") + foo_dir = HOMEBREW_CELLAR/"testball/0.1/foo" + assert foo_dir.exist? + foo_dir.rmtree + assert_match "Reinstalling testball with --with-foo", + cmd("reinstall", "testball") + assert foo_dir.exist? + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_reinstall_pinned.rb b/Library/Homebrew/test/test_integration_cmds_reinstall_pinned.rb new file mode 100644 index 0000000000..dc4695e408 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_reinstall_pinned.rb @@ -0,0 +1,15 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestReinstallPinned < IntegrationCommandTests + def test_reinstall_pinned + setup_test_formula "testball" + + HOMEBREW_CELLAR.join("testball/0.1").mkpath + HOMEBREW_PINNED_KEGS.mkpath + FileUtils.ln_s HOMEBREW_CELLAR.join("testball/0.1"), HOMEBREW_PINNED_KEGS/"testball" + + assert_match "testball is pinned. You must unpin it to reinstall.", cmd("reinstall", "testball") + + HOMEBREW_PINNED_KEGS.rmtree + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_repository.rb b/Library/Homebrew/test/test_integration_cmds_repository.rb new file mode 100644 index 0000000000..a90dc1814a --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_repository.rb @@ -0,0 +1,10 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestRepository < IntegrationCommandTests + def test_repository + assert_match HOMEBREW_REPOSITORY.to_s, + cmd("--repository") + assert_match "#{HOMEBREW_LIBRARY}/Taps/foo/homebrew-bar", + cmd("--repository", "foo/bar") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_search.rb b/Library/Homebrew/test/test_integration_cmds_search.rb new file mode 100644 index 0000000000..f85d1d67e4 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_search.rb @@ -0,0 +1,30 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestSearch < IntegrationCommandTests + def test_search + setup_test_formula "testball" + desc_cache = HOMEBREW_CACHE/"desc_cache.json" + refute_predicate desc_cache, :exist?, "Cached file should not exist" + + assert_match "testball", cmd("search") + assert_match "testball", cmd("search", "testball") + assert_match "testball", cmd("search", "homebrew/homebrew-core/testball") + assert_match "testball", cmd("search", "--desc", "Some test") + + flags = { + "macports" => "https://www.macports.org/ports.php?by=name&substr=testball", + "fink" => "http://pdb.finkproject.org/pdb/browse.php?summary=testball", + "debian" => "https://packages.debian.org/search?keywords=testball&searchon=names&suite=all§ion=all", + "opensuse" => "https://software.opensuse.org/search?q=testball", + "fedora" => "https://admin.fedoraproject.org/pkgdb/packages/%2Atestball%2A/", + "ubuntu" => "http://packages.ubuntu.com/search?keywords=testball&searchon=names&suite=all§ion=all", + } + + flags.each do |flag, url| + assert_equal url, cmd("search", "--#{flag}", + "testball", "HOMEBREW_BROWSER" => "echo") + end + + assert_predicate desc_cache, :exist?, "Cached file should exist" + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_services.rb b/Library/Homebrew/test/test_integration_cmds_services.rb new file mode 100644 index 0000000000..043b5b0d6f --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_services.rb @@ -0,0 +1,11 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestServices < IntegrationCommandTests + def test_services + needs_test_cmd_taps + needs_macos + setup_remote_tap("homebrew/services") + assert_equal "Warning: No services available to control with `brew services`", + cmd("services", "list") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_sh.rb b/Library/Homebrew/test/test_integration_cmds_sh.rb new file mode 100644 index 0000000000..be9e119c52 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_sh.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestSh < IntegrationCommandTests + def test_sh + assert_match "Your shell has been configured", + cmd("sh", "SHELL" => which("true")) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_switch.rb b/Library/Homebrew/test/test_integration_cmds_switch.rb new file mode 100644 index 0000000000..50b636d14a --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_switch.rb @@ -0,0 +1,20 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestSwitch < IntegrationCommandTests + def test_switch + assert_match "Usage: brew switch ", cmd_fail("switch") + assert_match "testball not found", cmd_fail("switch", "testball", "0.1") + + setup_test_formula "testball", <<-EOS.undent + keg_only "just because" + EOS + + cmd("install", "testball") + testball_rack = HOMEBREW_CELLAR/"testball" + FileUtils.cp_r testball_rack/"0.1", testball_rack/"0.2" + + cmd("switch", "testball", "0.2") + assert_match "testball does not have a version \"0.3\"", + cmd_fail("switch", "testball", "0.3") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_tap.rb b/Library/Homebrew/test/test_integration_cmds_tap.rb new file mode 100644 index 0000000000..22cfd8e93b --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_tap.rb @@ -0,0 +1,30 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestTap < IntegrationCommandTests + def test_tap + path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" + path.mkpath + path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + FileUtils.touch "readme" + system "git", "add", "--all" + system "git", "commit", "-m", "init" + end + end + + assert_match "homebrew/foo", cmd("tap") + assert_match "homebrew/versions", cmd("tap", "--list-official") + assert_match "2 taps", cmd("tap-info") + assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "homebrew/foo") + assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "--json=v1", "--installed") + assert_match "Pinned homebrew/foo", cmd("tap-pin", "homebrew/foo") + assert_match "homebrew/foo", cmd("tap", "--list-pinned") + assert_match "Unpinned homebrew/foo", cmd("tap-unpin", "homebrew/foo") + assert_match "Tapped", cmd("tap", "homebrew/bar", path/".git") + assert_match "Untapped", cmd("untap", "homebrew/bar") + assert_equal "", cmd("tap", "homebrew/bar", path/".git", "-q", "--full") + assert_match "Untapped", cmd("untap", "homebrew/bar") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_tap_readme.rb b/Library/Homebrew/test/test_integration_cmds_tap_readme.rb new file mode 100644 index 0000000000..c1f53c42d2 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_tap_readme.rb @@ -0,0 +1,10 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestTapReadme < IntegrationCommandTests + def test_tap_readme + assert_match "brew install homebrew/foo/", + cmd("tap-readme", "foo", "--verbose") + readme = HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo/README.md" + assert readme.exist?, "The README should be created" + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_test_formula.rb b/Library/Homebrew/test/test_integration_cmds_test_formula.rb new file mode 100644 index 0000000000..4350fdbe9d --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_test_formula.rb @@ -0,0 +1,30 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestTestFormula < IntegrationCommandTests + def test_test_formula + assert_match "This command requires a formula argument", cmd_fail("test") + assert_match "Testing requires the latest version of testball", + cmd_fail("test", testball) + + cmd("install", testball) + assert_match "testball defines no test", cmd_fail("test", testball) + + setup_test_formula "testball_copy", <<-EOS.undent + head "https://github.com/example/testball2.git" + + devel do + url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" + sha256 "#{TESTBALL_SHA256}" + end + + keg_only "just because" + + test do + end + EOS + + cmd("install", "testball_copy") + assert_match "Testing testball_copy", cmd("test", "--HEAD", "testball_copy") + assert_match "Testing testball_copy", cmd("test", "--devel", "testball_copy") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_uninstall.rb b/Library/Homebrew/test/test_integration_cmds_uninstall.rb new file mode 100644 index 0000000000..6f82bedc77 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_uninstall.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestUninstall < IntegrationCommandTests + def test_uninstall + cmd("install", testball) + assert_match "Uninstalling testball", cmd("uninstall", "--force", testball) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_unlink.rb b/Library/Homebrew/test/test_integration_cmds_unlink.rb new file mode 100644 index 0000000000..b64cc81406 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_unlink.rb @@ -0,0 +1,10 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestUnlink < IntegrationCommandTests + def test_unlink + setup_test_formula "testball" + + cmd("install", "testball") + assert_match "Would remove", cmd("unlink", "--dry-run", "testball") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_unlinkapps.rb b/Library/Homebrew/test/test_integration_cmds_unlinkapps.rb new file mode 100644 index 0000000000..047f17a1da --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_unlinkapps.rb @@ -0,0 +1,19 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestUnlinkapps < IntegrationCommandTests + def test_unlinkapps + home_dir = Pathname.new(mktmpdir) + apps_dir = home_dir/"Applications" + apps_dir.mkpath + + setup_test_formula "testball" + + source_app = (HOMEBREW_CELLAR/"testball/0.1/TestBall.app") + source_app.mkpath + + FileUtils.ln_s source_app, "#{apps_dir}/TestBall.app" + + assert_match "Unlinking: #{apps_dir}/TestBall.app", + cmd("unlinkapps", "--local", "HOME" => home_dir) + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_unpack.rb b/Library/Homebrew/test/test_integration_cmds_unpack.rb new file mode 100644 index 0000000000..1b6e97e52d --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_unpack.rb @@ -0,0 +1,13 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestUnpack < IntegrationCommandTests + def test_unpack + setup_test_formula "testball" + + mktmpdir do |path| + cmd "unpack", "testball", "--destdir=#{path}" + assert File.directory?("#{path}/testball-0.1"), + "The tarball should be unpacked" + end + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_upgrade.rb b/Library/Homebrew/test/test_integration_cmds_upgrade.rb new file mode 100644 index 0000000000..5eee33d56b --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_upgrade.rb @@ -0,0 +1,12 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestUpgrade < IntegrationCommandTests + def test_upgrade + setup_test_formula "testball" + (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath + + cmd("upgrade") + assert((HOMEBREW_CELLAR/"testball/0.1").directory?, + "The latest version directory should be created") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_uses.rb b/Library/Homebrew/test/test_integration_cmds_uses.rb new file mode 100644 index 0000000000..e5c0c0f770 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_uses.rb @@ -0,0 +1,16 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestUses < IntegrationCommandTests + def test_uses + setup_test_formula "foo" + setup_test_formula "bar" + setup_test_formula "baz", <<-EOS.undent + url "https://example.com/baz-1.0" + depends_on "bar" + EOS + + assert_equal "", cmd("uses", "baz") + assert_equal "baz", cmd("uses", "bar") + assert_equal "bar\nbaz", cmd("uses", "--recursive", "foo") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_version.rb b/Library/Homebrew/test/test_integration_cmds_version.rb new file mode 100644 index 0000000000..b434d0d955 --- /dev/null +++ b/Library/Homebrew/test/test_integration_cmds_version.rb @@ -0,0 +1,8 @@ +require "integration_cmds_tests" + +class IntegrationCommandTestVersion < IntegrationCommandTests + def test_version + assert_match HOMEBREW_VERSION.to_s, + cmd("--version") + end +end From d508b124a43f4d1fd5500e9b023dcf9a1b41fc6a Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 27 Sep 2016 00:03:40 +0200 Subject: [PATCH 2/2] Rename/merge test files. --- .../integration_command_test_case.rb} | 6 ++-- Library/Homebrew/test/test_ENV.rb | 28 +++++++++++++++++ ...on_cmds_analytics.rb => test_analytics.rb} | 4 +-- .../test/{test_cmd_audit.rb => test_audit.rb} | 0 ...egration_cmds_bottle.rb => test_bottle.rb} | 4 +-- ...egration_cmds_bundle.rb => test_bundle.rb} | 4 +-- Library/Homebrew/test/test_cache.rb | 8 +++++ ...cache_formula.rb => test_cache_formula.rb} | 4 +-- ..._integration_cmds_cask.rb => test_cask.rb} | 4 +-- ...st_integration_cmds_cat.rb => test_cat.rb} | 4 +-- Library/Homebrew/test/test_cellar.rb | 8 +++++ ...llar_formula.rb => test_cellar_formula.rb} | 4 +-- Library/Homebrew/test/test_cleanup.rb | 8 +++++ ...ration_cmds_command.rb => test_command.rb} | 4 +-- Library/Homebrew/test/test_commands.rb | 8 +++++ ...egration_cmds_config.rb => test_config.rb} | 4 +-- ...egration_cmds_create.rb => test_create.rb} | 4 +-- ...stom_command.rb => test_custom_command.rb} | 4 +-- ..._integration_cmds_deps.rb => test_deps.rb} | 4 +-- ..._integration_cmds_desc.rb => test_desc.rb} | 4 +-- ...egration_cmds_doctor.rb => test_doctor.rb} | 4 +-- ..._integration_cmds_edit.rb => test_edit.rb} | 4 +-- ...ntegration_cmds_fetch.rb => test_fetch.rb} | 4 +-- ..._integration_cmds_help.rb => test_help.rb} | 4 +-- ..._integration_cmds_home.rb => test_home.rb} | 4 +-- .../test/{test_cmd_info.rb => test_info.rb} | 10 +++++++ ...ration_cmds_install.rb => test_install.rb} | 4 +-- .../test/test_integration_cmds_cache.rb | 8 ----- .../test/test_integration_cmds_cellar.rb | 8 ----- .../test/test_integration_cmds_cleanup.rb | 8 ----- .../test/test_integration_cmds_commands.rb | 8 ----- .../test/test_integration_cmds_env.rb | 8 ----- .../test/test_integration_cmds_env_bash.rb | 8 ----- .../test/test_integration_cmds_env_csh.rb | 8 ----- .../test/test_integration_cmds_env_fish.rb | 8 ----- .../test/test_integration_cmds_env_plain.rb | 8 ----- .../test/test_integration_cmds_info.rb | 10 ------- .../test/test_integration_cmds_options.rb | 12 -------- .../test/test_integration_cmds_prefix.rb | 8 ----- .../test/test_integration_cmds_tap.rb | 30 ------------------- .../test/test_integration_cmds_version.rb | 8 ----- ...st_integration_cmds_irb.rb => test_irb.rb} | 4 +-- ...egration_cmds_leaves.rb => test_leaves.rb} | 4 +-- ..._integration_cmds_link.rb => test_link.rb} | 4 +-- ...tion_cmds_linkapps.rb => test_linkapps.rb} | 4 +-- ..._integration_cmds_list.rb => test_list.rb} | 4 +-- ...st_integration_cmds_log.rb => test_log.rb} | 4 +-- ...mds_log_formula.rb => test_log_formula.rb} | 4 +-- ...ration_cmds_migrate.rb => test_migrate.rb} | 4 +-- ...ration_cmds_missing.rb => test_missing.rb} | 4 +-- Library/Homebrew/test/test_options.rb | 12 ++++++++ ...tion_cmds_outdated.rb => test_outdated.rb} | 4 +-- ...on_cmds_pin_unpin.rb => test_pin_unpin.rb} | 4 +-- Library/Homebrew/test/test_prefix.rb | 8 +++++ ...efix_formula.rb => test_prefix_formula.rb} | 4 +-- ...ntegration_cmds_prune.rb => test_prune.rb} | 4 +-- ..._integration_cmds_pull.rb => test_pull.rb} | 4 +-- ...s_pull_offline.rb => test_pull_offline.rb} | 4 +-- ...ration_cmds_readall.rb => test_readall.rb} | 4 +-- ...on_cmds_reinstall.rb => test_reinstall.rb} | 4 +-- ...all_pinned.rb => test_reinstall_pinned.rb} | 4 +-- ..._cmds_repository.rb => test_repository.rb} | 4 +-- ...egration_cmds_search.rb => test_search.rb} | 4 +-- ...tion_cmds_services.rb => test_services.rb} | 4 +-- ...test_integration_cmds_sh.rb => test_sh.rb} | 4 +-- ...egration_cmds_switch.rb => test_switch.rb} | 4 +-- Library/Homebrew/test/test_tap.rb | 30 +++++++++++++++++++ ..._cmds_tap_readme.rb => test_tap_readme.rb} | 4 +-- ...s_test_formula.rb => test_test_formula.rb} | 4 +-- ...on_cmds_uninstall.rb => test_uninstall.rb} | 4 +-- ...egration_cmds_unlink.rb => test_unlink.rb} | 4 +-- ..._cmds_unlinkapps.rb => test_unlinkapps.rb} | 4 +-- ...egration_cmds_unpack.rb => test_unpack.rb} | 4 +-- ...ration_cmds_upgrade.rb => test_upgrade.rb} | 4 +-- ..._integration_cmds_uses.rb => test_uses.rb} | 4 +-- Library/Homebrew/test/test_version.rb | 8 +++++ 76 files changed, 231 insertions(+), 243 deletions(-) rename Library/Homebrew/test/{integration_cmds_tests.rb => helper/integration_command_test_case.rb} (96%) rename Library/Homebrew/test/{test_integration_cmds_analytics.rb => test_analytics.rb} (85%) rename Library/Homebrew/test/{test_cmd_audit.rb => test_audit.rb} (100%) rename Library/Homebrew/test/{test_integration_cmds_bottle.rb => test_bottle.rb} (84%) rename Library/Homebrew/test/{test_integration_cmds_bundle.rb => test_bundle.rb} (80%) create mode 100644 Library/Homebrew/test/test_cache.rb rename Library/Homebrew/test/{test_integration_cmds_cache_formula.rb => test_cache_formula.rb} (78%) rename Library/Homebrew/test/{test_integration_cmds_cask.rb => test_cask.rb} (54%) rename Library/Homebrew/test/{test_integration_cmds_cat.rb => test_cat.rb} (56%) create mode 100644 Library/Homebrew/test/test_cellar.rb rename Library/Homebrew/test/{test_integration_cmds_cellar_formula.rb => test_cellar_formula.rb} (78%) rename Library/Homebrew/test/{test_integration_cmds_command.rb => test_command.rb} (66%) rename Library/Homebrew/test/{test_integration_cmds_config.rb => test_config.rb} (51%) rename Library/Homebrew/test/{test_integration_cmds_create.rb => test_create.rb} (76%) rename Library/Homebrew/test/{test_integration_cmds_custom_command.rb => test_custom_command.rb} (88%) rename Library/Homebrew/test/{test_integration_cmds_deps.rb => test_deps.rb} (75%) rename Library/Homebrew/test/{test_integration_cmds_desc.rb => test_desc.rb} (82%) rename Library/Homebrew/test/{test_integration_cmds_doctor.rb => test_doctor.rb} (55%) rename Library/Homebrew/test/{test_integration_cmds_edit.rb => test_edit.rb} (66%) rename Library/Homebrew/test/{test_integration_cmds_fetch.rb => test_fetch.rb} (63%) rename Library/Homebrew/test/{test_integration_cmds_help.rb => test_help.rb} (88%) rename Library/Homebrew/test/{test_integration_cmds_home.rb => test_home.rb} (71%) rename Library/Homebrew/test/{test_cmd_info.rb => test_info.rb} (75%) rename Library/Homebrew/test/{test_integration_cmds_install.rb => test_install.rb} (90%) delete mode 100644 Library/Homebrew/test/test_integration_cmds_cache.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_cellar.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_cleanup.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_commands.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_env.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_env_bash.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_env_csh.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_env_fish.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_env_plain.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_info.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_options.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_prefix.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_tap.rb delete mode 100644 Library/Homebrew/test/test_integration_cmds_version.rb rename Library/Homebrew/test/{test_integration_cmds_irb.rb => test_irb.rb} (76%) rename Library/Homebrew/test/{test_integration_cmds_leaves.rb => test_leaves.rb} (72%) rename Library/Homebrew/test/{test_integration_cmds_link.rb => test_link.rb} (85%) rename Library/Homebrew/test/{test_integration_cmds_linkapps.rb => test_linkapps.rb} (73%) rename Library/Homebrew/test/{test_integration_cmds_list.rb => test_list.rb} (65%) rename Library/Homebrew/test/{test_integration_cmds_log.rb => test_log.rb} (70%) rename Library/Homebrew/test/{test_integration_cmds_log_formula.rb => test_log_formula.rb} (86%) rename Library/Homebrew/test/{test_integration_cmds_migrate.rb => test_migrate.rb} (84%) rename Library/Homebrew/test/{test_integration_cmds_missing.rb => test_missing.rb} (59%) rename Library/Homebrew/test/{test_integration_cmds_outdated.rb => test_outdated.rb} (58%) rename Library/Homebrew/test/{test_integration_cmds_pin_unpin.rb => test_pin_unpin.rb} (79%) create mode 100644 Library/Homebrew/test/test_prefix.rb rename Library/Homebrew/test/{test_integration_cmds_prefix_formula.rb => test_prefix_formula.rb} (78%) rename Library/Homebrew/test/{test_integration_cmds_prune.rb => test_prune.rb} (85%) rename Library/Homebrew/test/{test_integration_cmds_pull.rb => test_pull.rb} (88%) rename Library/Homebrew/test/{test_integration_cmds_pull_offline.rb => test_pull_offline.rb} (86%) rename Library/Homebrew/test/{test_integration_cmds_readall.rb => test_readall.rb} (71%) rename Library/Homebrew/test/{test_integration_cmds_reinstall.rb => test_reinstall.rb} (74%) rename Library/Homebrew/test/{test_integration_cmds_reinstall_pinned.rb => test_reinstall_pinned.rb} (88%) rename Library/Homebrew/test/{test_integration_cmds_repository.rb => test_repository.rb} (65%) rename Library/Homebrew/test/{test_integration_cmds_search.rb => test_search.rb} (91%) rename Library/Homebrew/test/{test_integration_cmds_services.rb => test_services.rb} (66%) rename Library/Homebrew/test/{test_integration_cmds_sh.rb => test_sh.rb} (54%) rename Library/Homebrew/test/{test_integration_cmds_switch.rb => test_switch.rb} (83%) rename Library/Homebrew/test/{test_integration_cmds_tap_readme.rb => test_tap_readme.rb} (70%) rename Library/Homebrew/test/{test_integration_cmds_test_formula.rb => test_test_formula.rb} (94%) rename Library/Homebrew/test/{test_integration_cmds_uninstall.rb => test_uninstall.rb} (55%) rename Library/Homebrew/test/{test_integration_cmds_unlink.rb => test_unlink.rb} (60%) rename Library/Homebrew/test/{test_integration_cmds_unlinkapps.rb => test_unlinkapps.rb} (78%) rename Library/Homebrew/test/{test_integration_cmds_unpack.rb => test_unpack.rb} (68%) rename Library/Homebrew/test/{test_integration_cmds_upgrade.rb => test_upgrade.rb} (68%) rename Library/Homebrew/test/{test_integration_cmds_uses.rb => test_uses.rb} (76%) create mode 100644 Library/Homebrew/test/test_version.rb diff --git a/Library/Homebrew/test/integration_cmds_tests.rb b/Library/Homebrew/test/helper/integration_command_test_case.rb similarity index 96% rename from Library/Homebrew/test/integration_cmds_tests.rb rename to Library/Homebrew/test/helper/integration_command_test_case.rb index a63b343c03..ab7fcbeaa0 100644 --- a/Library/Homebrew/test/integration_cmds_tests.rb +++ b/Library/Homebrew/test/helper/integration_command_test_case.rb @@ -4,7 +4,7 @@ require "fileutils" require "pathname" require "formula" -class IntegrationCommandTests < Homebrew::TestCase +class IntegrationCommandTestCase < Homebrew::TestCase def setup @cmd_id_index = 0 # Assign unique IDs to invocations of `cmd_output`. (HOMEBREW_PREFIX/"bin").mkpath @@ -120,7 +120,7 @@ class IntegrationCommandTests < Homebrew::TestCase content = <<-EOS.undent desc "Some test" homepage "https://example.com/#{name}" - url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" + url "file://#{File.expand_path("../..", __FILE__)}/tarballs/testball-0.1.tbz" sha256 "#{TESTBALL_SHA256}" option "with-foo", "Build with foo" @@ -189,6 +189,6 @@ class IntegrationCommandTests < Homebrew::TestCase end def testball - "#{File.expand_path("..", __FILE__)}/testball.rb" + "#{File.expand_path("../..", __FILE__)}/testball.rb" end end diff --git a/Library/Homebrew/test/test_ENV.rb b/Library/Homebrew/test/test_ENV.rb index 665e344e63..e38c75c6e4 100644 --- a/Library/Homebrew/test/test_ENV.rb +++ b/Library/Homebrew/test/test_ENV.rb @@ -1,5 +1,33 @@ require "testing_env" require "extend/ENV" +require "helper/integration_command_test_case" + +class IntegrationCommandTestEnv < IntegrationCommandTestCase + def test_env + assert_match(/CMAKE_PREFIX_PATH="#{Regexp.escape(HOMEBREW_PREFIX)}[:"]/, + cmd("--env")) + end + + def test_env_fish + assert_match(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/, + cmd("--env", "--shell=fish")) + end + + def test_env_csh + assert_match(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/, + cmd("--env", "--shell=tcsh")) + end + + def test_env_bash + assert_match(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/, + cmd("--env", "--shell=bash")) + end + + def test_env_plain + assert_match(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/, + cmd("--env", "--plain")) + end +end module SharedEnvTests def setup diff --git a/Library/Homebrew/test/test_integration_cmds_analytics.rb b/Library/Homebrew/test/test_analytics.rb similarity index 85% rename from Library/Homebrew/test/test_integration_cmds_analytics.rb rename to Library/Homebrew/test/test_analytics.rb index 17afe7fe85..00e0593db4 100644 --- a/Library/Homebrew/test/test_integration_cmds_analytics.rb +++ b/Library/Homebrew/test/test_analytics.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestAnalytics < IntegrationCommandTests +class IntegrationCommandTestAnalytics < IntegrationCommandTestCase def test_analytics HOMEBREW_REPOSITORY.cd do shutup do diff --git a/Library/Homebrew/test/test_cmd_audit.rb b/Library/Homebrew/test/test_audit.rb similarity index 100% rename from Library/Homebrew/test/test_cmd_audit.rb rename to Library/Homebrew/test/test_audit.rb diff --git a/Library/Homebrew/test/test_integration_cmds_bottle.rb b/Library/Homebrew/test/test_bottle.rb similarity index 84% rename from Library/Homebrew/test/test_integration_cmds_bottle.rb rename to Library/Homebrew/test/test_bottle.rb index b6d9de714c..48727cfd90 100644 --- a/Library/Homebrew/test/test_integration_cmds_bottle.rb +++ b/Library/Homebrew/test/test_bottle.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestBottle < IntegrationCommandTests +class IntegrationCommandTestBottle < IntegrationCommandTestCase def test_bottle cmd("install", "--build-bottle", testball) assert_match "Formula not from core or any taps", diff --git a/Library/Homebrew/test/test_integration_cmds_bundle.rb b/Library/Homebrew/test/test_bundle.rb similarity index 80% rename from Library/Homebrew/test/test_integration_cmds_bundle.rb rename to Library/Homebrew/test/test_bundle.rb index 726bd4d106..6b040df1db 100644 --- a/Library/Homebrew/test/test_integration_cmds_bundle.rb +++ b/Library/Homebrew/test/test_bundle.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestBundle < IntegrationCommandTests +class IntegrationCommandTestBundle < IntegrationCommandTestCase def test_bundle needs_test_cmd_taps setup_remote_tap("homebrew/bundle") diff --git a/Library/Homebrew/test/test_cache.rb b/Library/Homebrew/test/test_cache.rb new file mode 100644 index 0000000000..cd7a5e2fab --- /dev/null +++ b/Library/Homebrew/test/test_cache.rb @@ -0,0 +1,8 @@ +require "helper/integration_command_test_case" + +class IntegrationCommandTestCache < IntegrationCommandTestCase + def test_cache + assert_equal HOMEBREW_CACHE.to_s, + cmd("--cache") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_cache_formula.rb b/Library/Homebrew/test/test_cache_formula.rb similarity index 78% rename from Library/Homebrew/test/test_integration_cmds_cache_formula.rb rename to Library/Homebrew/test/test_cache_formula.rb index 82c3421b24..f4e37e2a2e 100644 --- a/Library/Homebrew/test/test_integration_cmds_cache_formula.rb +++ b/Library/Homebrew/test/test_cache_formula.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestCacheFormula < IntegrationCommandTests +class IntegrationCommandTestCacheFormula < IntegrationCommandTestCase def test_cache_formula assert_match %r{#{HOMEBREW_CACHE}/testball-}, cmd("--cache", testball) diff --git a/Library/Homebrew/test/test_integration_cmds_cask.rb b/Library/Homebrew/test/test_cask.rb similarity index 54% rename from Library/Homebrew/test/test_integration_cmds_cask.rb rename to Library/Homebrew/test/test_cask.rb index e97bb868c5..6f4f4601a9 100644 --- a/Library/Homebrew/test/test_integration_cmds_cask.rb +++ b/Library/Homebrew/test/test_cask.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestCask < IntegrationCommandTests +class IntegrationCommandTestCask < IntegrationCommandTestCase def test_cask needs_test_cmd_taps needs_macos diff --git a/Library/Homebrew/test/test_integration_cmds_cat.rb b/Library/Homebrew/test/test_cat.rb similarity index 56% rename from Library/Homebrew/test/test_integration_cmds_cat.rb rename to Library/Homebrew/test/test_cat.rb index ad4ef199b6..4cfd19c3dc 100644 --- a/Library/Homebrew/test/test_integration_cmds_cat.rb +++ b/Library/Homebrew/test/test_cat.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestCat < IntegrationCommandTests +class IntegrationCommandTestCat < IntegrationCommandTestCase def test_cat formula_file = setup_test_formula "testball" assert_equal formula_file.read.chomp, cmd("cat", "testball") diff --git a/Library/Homebrew/test/test_cellar.rb b/Library/Homebrew/test/test_cellar.rb new file mode 100644 index 0000000000..b793c53424 --- /dev/null +++ b/Library/Homebrew/test/test_cellar.rb @@ -0,0 +1,8 @@ +require "helper/integration_command_test_case" + +class IntegrationCommandTestCellar < IntegrationCommandTestCase + def test_cellar + assert_equal HOMEBREW_CELLAR.to_s, + cmd("--cellar") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_cellar_formula.rb b/Library/Homebrew/test/test_cellar_formula.rb similarity index 78% rename from Library/Homebrew/test/test_integration_cmds_cellar_formula.rb rename to Library/Homebrew/test/test_cellar_formula.rb index 356c79d6d4..7c458be9d0 100644 --- a/Library/Homebrew/test/test_integration_cmds_cellar_formula.rb +++ b/Library/Homebrew/test/test_cellar_formula.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestCellarFormula < IntegrationCommandTests +class IntegrationCommandTestCellarFormula < IntegrationCommandTestCase def test_cellar_formula assert_match "#{HOMEBREW_CELLAR}/testball", cmd("--cellar", testball) diff --git a/Library/Homebrew/test/test_cleanup.rb b/Library/Homebrew/test/test_cleanup.rb index 1351c85a6c..dffcd12f2f 100644 --- a/Library/Homebrew/test/test_cleanup.rb +++ b/Library/Homebrew/test/test_cleanup.rb @@ -3,6 +3,14 @@ require "testball" require "cleanup" require "fileutils" require "pathname" +require "helper/integration_command_test_case" + +class IntegrationCommandTestCleanup < IntegrationCommandTestCase + def test_cleanup + (HOMEBREW_CACHE/"test").write "test" + assert_match "#{HOMEBREW_CACHE}/test", cmd("cleanup", "--prune=all") + end +end class CleanupTests < Homebrew::TestCase def setup diff --git a/Library/Homebrew/test/test_integration_cmds_command.rb b/Library/Homebrew/test/test_command.rb similarity index 66% rename from Library/Homebrew/test/test_integration_cmds_command.rb rename to Library/Homebrew/test/test_command.rb index 33cfdc8ed5..d051846313 100644 --- a/Library/Homebrew/test/test_integration_cmds_command.rb +++ b/Library/Homebrew/test/test_command.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestCommand < IntegrationCommandTests +class IntegrationCommandTestCommand < IntegrationCommandTestCase def test_command assert_equal "#{HOMEBREW_LIBRARY_PATH}/cmd/info.rb", cmd("command", "info") diff --git a/Library/Homebrew/test/test_commands.rb b/Library/Homebrew/test/test_commands.rb index c51e815590..ef138049c1 100644 --- a/Library/Homebrew/test/test_commands.rb +++ b/Library/Homebrew/test/test_commands.rb @@ -2,6 +2,14 @@ require "testing_env" require "cmd/command" require "cmd/commands" require "fileutils" +require "helper/integration_command_test_case" + +class IntegrationCommandTestCommands < IntegrationCommandTestCase + def test_commands + assert_match "Built-in commands", + cmd("commands") + end +end class CommandsTests < Homebrew::TestCase def setup diff --git a/Library/Homebrew/test/test_integration_cmds_config.rb b/Library/Homebrew/test/test_config.rb similarity index 51% rename from Library/Homebrew/test/test_integration_cmds_config.rb rename to Library/Homebrew/test/test_config.rb index f1cb5cb7e9..33a2937357 100644 --- a/Library/Homebrew/test/test_integration_cmds_config.rb +++ b/Library/Homebrew/test/test_config.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestConfig < IntegrationCommandTests +class IntegrationCommandTestConfig < IntegrationCommandTestCase def test_config assert_match "HOMEBREW_VERSION: #{HOMEBREW_VERSION}", cmd("config") diff --git a/Library/Homebrew/test/test_integration_cmds_create.rb b/Library/Homebrew/test/test_create.rb similarity index 76% rename from Library/Homebrew/test/test_integration_cmds_create.rb rename to Library/Homebrew/test/test_create.rb index 20765f9c82..b30e855478 100644 --- a/Library/Homebrew/test/test_integration_cmds_create.rb +++ b/Library/Homebrew/test/test_create.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestCreate < IntegrationCommandTests +class IntegrationCommandTestCreate < IntegrationCommandTestCase def test_create url = "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" cmd("create", url, "HOMEBREW_EDITOR" => "/bin/cat") diff --git a/Library/Homebrew/test/test_integration_cmds_custom_command.rb b/Library/Homebrew/test/test_custom_command.rb similarity index 88% rename from Library/Homebrew/test/test_integration_cmds_custom_command.rb rename to Library/Homebrew/test/test_custom_command.rb index 3ea2e6360d..b3cd39f276 100644 --- a/Library/Homebrew/test/test_integration_cmds_custom_command.rb +++ b/Library/Homebrew/test/test_custom_command.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestCustomCommand < IntegrationCommandTests +class IntegrationCommandTestCustomCommand < IntegrationCommandTestCase def test_custom_command mktmpdir do |path| cmd = "int-test-#{rand}" diff --git a/Library/Homebrew/test/test_integration_cmds_deps.rb b/Library/Homebrew/test/test_deps.rb similarity index 75% rename from Library/Homebrew/test/test_integration_cmds_deps.rb rename to Library/Homebrew/test/test_deps.rb index 10a654b60c..83cc9aa6a7 100644 --- a/Library/Homebrew/test/test_integration_cmds_deps.rb +++ b/Library/Homebrew/test/test_deps.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestDeps < IntegrationCommandTests +class IntegrationCommandTestDeps < IntegrationCommandTestCase def test_deps setup_test_formula "foo" setup_test_formula "bar" diff --git a/Library/Homebrew/test/test_integration_cmds_desc.rb b/Library/Homebrew/test/test_desc.rb similarity index 82% rename from Library/Homebrew/test/test_integration_cmds_desc.rb rename to Library/Homebrew/test/test_desc.rb index e93b715782..075ea991a2 100644 --- a/Library/Homebrew/test/test_integration_cmds_desc.rb +++ b/Library/Homebrew/test/test_desc.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestDesc < IntegrationCommandTests +class IntegrationCommandTestDesc < IntegrationCommandTestCase def test_desc setup_test_formula "testball" diff --git a/Library/Homebrew/test/test_integration_cmds_doctor.rb b/Library/Homebrew/test/test_doctor.rb similarity index 55% rename from Library/Homebrew/test/test_integration_cmds_doctor.rb rename to Library/Homebrew/test/test_doctor.rb index e3edf1b0f5..ccb909dce0 100644 --- a/Library/Homebrew/test/test_integration_cmds_doctor.rb +++ b/Library/Homebrew/test/test_doctor.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestDoctor < IntegrationCommandTests +class IntegrationCommandTestDoctor < IntegrationCommandTestCase def test_doctor assert_match "This is an integration test", cmd_fail("doctor", "check_integration_test") diff --git a/Library/Homebrew/test/test_integration_cmds_edit.rb b/Library/Homebrew/test/test_edit.rb similarity index 66% rename from Library/Homebrew/test/test_integration_cmds_edit.rb rename to Library/Homebrew/test/test_edit.rb index b47e0d4f9a..8d14371730 100644 --- a/Library/Homebrew/test/test_integration_cmds_edit.rb +++ b/Library/Homebrew/test/test_edit.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestEdit < IntegrationCommandTests +class IntegrationCommandTestEdit < IntegrationCommandTestCase def test_edit (HOMEBREW_REPOSITORY/".git").mkpath setup_test_formula "testball" diff --git a/Library/Homebrew/test/test_integration_cmds_fetch.rb b/Library/Homebrew/test/test_fetch.rb similarity index 63% rename from Library/Homebrew/test/test_integration_cmds_fetch.rb rename to Library/Homebrew/test/test_fetch.rb index 9c060a3538..7b57c62469 100644 --- a/Library/Homebrew/test/test_integration_cmds_fetch.rb +++ b/Library/Homebrew/test/test_fetch.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestFetch < IntegrationCommandTests +class IntegrationCommandTestFetch < IntegrationCommandTestCase def test_fetch setup_test_formula "testball" diff --git a/Library/Homebrew/test/test_integration_cmds_help.rb b/Library/Homebrew/test/test_help.rb similarity index 88% rename from Library/Homebrew/test/test_integration_cmds_help.rb rename to Library/Homebrew/test/test_help.rb index 44fd774c97..9c14f9b78f 100644 --- a/Library/Homebrew/test/test_integration_cmds_help.rb +++ b/Library/Homebrew/test/test_help.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestHelp < IntegrationCommandTests +class IntegrationCommandTestHelp < IntegrationCommandTestCase def test_help assert_match "Example usage:\n", cmd_fail # Generic help (empty argument list). diff --git a/Library/Homebrew/test/test_integration_cmds_home.rb b/Library/Homebrew/test/test_home.rb similarity index 71% rename from Library/Homebrew/test/test_integration_cmds_home.rb rename to Library/Homebrew/test/test_home.rb index ef21e85ca1..9c26353bec 100644 --- a/Library/Homebrew/test/test_integration_cmds_home.rb +++ b/Library/Homebrew/test/test_home.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestHome < IntegrationCommandTests +class IntegrationCommandTestHome < IntegrationCommandTestCase def test_home setup_test_formula "testball" diff --git a/Library/Homebrew/test/test_cmd_info.rb b/Library/Homebrew/test/test_info.rb similarity index 75% rename from Library/Homebrew/test/test_cmd_info.rb rename to Library/Homebrew/test/test_info.rb index ddc06ee01c..35f9183e13 100644 --- a/Library/Homebrew/test/test_cmd_info.rb +++ b/Library/Homebrew/test/test_info.rb @@ -1,6 +1,16 @@ require "testing_env" require "cmd/info" require "formula" +require "helper/integration_command_test_case" + +class IntegrationCommandTestInfo < IntegrationCommandTestCase + def test_info + setup_test_formula "testball" + + assert_match "testball: stable 0.1", + cmd("info", "testball") + end +end class InfoCommandTests < Homebrew::TestCase def test_github_remote_path diff --git a/Library/Homebrew/test/test_integration_cmds_install.rb b/Library/Homebrew/test/test_install.rb similarity index 90% rename from Library/Homebrew/test/test_integration_cmds_install.rb rename to Library/Homebrew/test/test_install.rb index 7ce4a3484d..5d27d978b0 100644 --- a/Library/Homebrew/test/test_integration_cmds_install.rb +++ b/Library/Homebrew/test/test_install.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestInstall < IntegrationCommandTests +class IntegrationCommandTestInstall < IntegrationCommandTestCase def test_install setup_test_formula "testball1" assert_match "Specify `--HEAD`", cmd_fail("install", "testball1", "--head") diff --git a/Library/Homebrew/test/test_integration_cmds_cache.rb b/Library/Homebrew/test/test_integration_cmds_cache.rb deleted file mode 100644 index 716724f4f9..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_cache.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestCache < IntegrationCommandTests - def test_cache - assert_equal HOMEBREW_CACHE.to_s, - cmd("--cache") - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_cellar.rb b/Library/Homebrew/test/test_integration_cmds_cellar.rb deleted file mode 100644 index 3adb8fccad..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_cellar.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestCellar < IntegrationCommandTests - def test_cellar - assert_equal HOMEBREW_CELLAR.to_s, - cmd("--cellar") - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_cleanup.rb b/Library/Homebrew/test/test_integration_cmds_cleanup.rb deleted file mode 100644 index fe9ce9952c..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_cleanup.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestCleanup < IntegrationCommandTests - def test_cleanup - (HOMEBREW_CACHE/"test").write "test" - assert_match "#{HOMEBREW_CACHE}/test", cmd("cleanup", "--prune=all") - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_commands.rb b/Library/Homebrew/test/test_integration_cmds_commands.rb deleted file mode 100644 index 47c4e25ca6..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_commands.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestCommands < IntegrationCommandTests - def test_commands - assert_match "Built-in commands", - cmd("commands") - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_env.rb b/Library/Homebrew/test/test_integration_cmds_env.rb deleted file mode 100644 index 9f6fc7cbb4..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_env.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestEnv < IntegrationCommandTests - def test_env - assert_match(/CMAKE_PREFIX_PATH="#{Regexp.escape(HOMEBREW_PREFIX)}[:"]/, - cmd("--env")) - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_env_bash.rb b/Library/Homebrew/test/test_integration_cmds_env_bash.rb deleted file mode 100644 index 71f807199f..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_env_bash.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestEnvBash < IntegrationCommandTests - def test_env_bash - assert_match(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/, - cmd("--env", "--shell=bash")) - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_env_csh.rb b/Library/Homebrew/test/test_integration_cmds_env_csh.rb deleted file mode 100644 index 19a6ed7d2f..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_env_csh.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestEnvCsh < IntegrationCommandTests - def test_env_csh - assert_match(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/, - cmd("--env", "--shell=tcsh")) - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_env_fish.rb b/Library/Homebrew/test/test_integration_cmds_env_fish.rb deleted file mode 100644 index 9c4bf0e16d..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_env_fish.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestEnvFish < IntegrationCommandTests - def test_env_fish - assert_match(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/, - cmd("--env", "--shell=fish")) - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_env_plain.rb b/Library/Homebrew/test/test_integration_cmds_env_plain.rb deleted file mode 100644 index a21ad7f033..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_env_plain.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestEnvPlain < IntegrationCommandTests - def test_env_plain - assert_match(/CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}/, - cmd("--env", "--plain")) - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_info.rb b/Library/Homebrew/test/test_integration_cmds_info.rb deleted file mode 100644 index acb272d15b..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_info.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestInfo < IntegrationCommandTests - def test_info - setup_test_formula "testball" - - assert_match "testball: stable 0.1", - cmd("info", "testball") - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_options.rb b/Library/Homebrew/test/test_integration_cmds_options.rb deleted file mode 100644 index de527804c0..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_options.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestOptions < IntegrationCommandTests - def test_options - setup_test_formula "testball", <<-EOS.undent - depends_on "bar" => :recommended - EOS - - assert_equal "--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support", - cmd_output("options", "testball").chomp - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_prefix.rb b/Library/Homebrew/test/test_integration_cmds_prefix.rb deleted file mode 100644 index 80a71c5ec9..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_prefix.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestPrefix < IntegrationCommandTests - def test_prefix - assert_equal HOMEBREW_PREFIX.to_s, - cmd("--prefix") - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_tap.rb b/Library/Homebrew/test/test_integration_cmds_tap.rb deleted file mode 100644 index 22cfd8e93b..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_tap.rb +++ /dev/null @@ -1,30 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestTap < IntegrationCommandTests - def test_tap - path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" - path.mkpath - path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - FileUtils.touch "readme" - system "git", "add", "--all" - system "git", "commit", "-m", "init" - end - end - - assert_match "homebrew/foo", cmd("tap") - assert_match "homebrew/versions", cmd("tap", "--list-official") - assert_match "2 taps", cmd("tap-info") - assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "homebrew/foo") - assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "--json=v1", "--installed") - assert_match "Pinned homebrew/foo", cmd("tap-pin", "homebrew/foo") - assert_match "homebrew/foo", cmd("tap", "--list-pinned") - assert_match "Unpinned homebrew/foo", cmd("tap-unpin", "homebrew/foo") - assert_match "Tapped", cmd("tap", "homebrew/bar", path/".git") - assert_match "Untapped", cmd("untap", "homebrew/bar") - assert_equal "", cmd("tap", "homebrew/bar", path/".git", "-q", "--full") - assert_match "Untapped", cmd("untap", "homebrew/bar") - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_version.rb b/Library/Homebrew/test/test_integration_cmds_version.rb deleted file mode 100644 index b434d0d955..0000000000 --- a/Library/Homebrew/test/test_integration_cmds_version.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "integration_cmds_tests" - -class IntegrationCommandTestVersion < IntegrationCommandTests - def test_version - assert_match HOMEBREW_VERSION.to_s, - cmd("--version") - end -end diff --git a/Library/Homebrew/test/test_integration_cmds_irb.rb b/Library/Homebrew/test/test_irb.rb similarity index 76% rename from Library/Homebrew/test/test_integration_cmds_irb.rb rename to Library/Homebrew/test/test_irb.rb index 338b32fd97..bf35b65241 100644 --- a/Library/Homebrew/test/test_integration_cmds_irb.rb +++ b/Library/Homebrew/test/test_irb.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestIrb < IntegrationCommandTests +class IntegrationCommandTestIrb < IntegrationCommandTestCase def test_irb assert_match "'v8'.f # => instance of the v8 formula", cmd("irb", "--examples") diff --git a/Library/Homebrew/test/test_integration_cmds_leaves.rb b/Library/Homebrew/test/test_leaves.rb similarity index 72% rename from Library/Homebrew/test/test_integration_cmds_leaves.rb rename to Library/Homebrew/test/test_leaves.rb index 2ea7779d69..2a9bbadd97 100644 --- a/Library/Homebrew/test/test_integration_cmds_leaves.rb +++ b/Library/Homebrew/test/test_leaves.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestLeaves < IntegrationCommandTests +class IntegrationCommandTestLeaves < IntegrationCommandTestCase def test_leaves setup_test_formula "foo" setup_test_formula "bar" diff --git a/Library/Homebrew/test/test_integration_cmds_link.rb b/Library/Homebrew/test/test_link.rb similarity index 85% rename from Library/Homebrew/test/test_integration_cmds_link.rb rename to Library/Homebrew/test/test_link.rb index 8c4255476f..3f05070724 100644 --- a/Library/Homebrew/test/test_integration_cmds_link.rb +++ b/Library/Homebrew/test/test_link.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestLink < IntegrationCommandTests +class IntegrationCommandTestLink < IntegrationCommandTestCase def test_link assert_match "This command requires a keg argument", cmd_fail("link") diff --git a/Library/Homebrew/test/test_integration_cmds_linkapps.rb b/Library/Homebrew/test/test_linkapps.rb similarity index 73% rename from Library/Homebrew/test/test_integration_cmds_linkapps.rb rename to Library/Homebrew/test/test_linkapps.rb index 9afb84b77b..b7c4cb8114 100644 --- a/Library/Homebrew/test/test_integration_cmds_linkapps.rb +++ b/Library/Homebrew/test/test_linkapps.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestLinkapps < IntegrationCommandTests +class IntegrationCommandTestLinkapps < IntegrationCommandTestCase def test_linkapps home_dir = Pathname.new(mktmpdir) (home_dir/"Applications").mkpath diff --git a/Library/Homebrew/test/test_integration_cmds_list.rb b/Library/Homebrew/test/test_list.rb similarity index 65% rename from Library/Homebrew/test/test_integration_cmds_list.rb rename to Library/Homebrew/test/test_list.rb index 917366905f..1ffdb45286 100644 --- a/Library/Homebrew/test/test_integration_cmds_list.rb +++ b/Library/Homebrew/test/test_list.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestList < IntegrationCommandTests +class IntegrationCommandTestList < IntegrationCommandTestCase def test_list formulae = %w[bar foo qux] formulae.each do |f| diff --git a/Library/Homebrew/test/test_integration_cmds_log.rb b/Library/Homebrew/test/test_log.rb similarity index 70% rename from Library/Homebrew/test/test_integration_cmds_log.rb rename to Library/Homebrew/test/test_log.rb index 1799d777db..b20a098fd8 100644 --- a/Library/Homebrew/test/test_integration_cmds_log.rb +++ b/Library/Homebrew/test/test_log.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestLog < IntegrationCommandTests +class IntegrationCommandTestLog < IntegrationCommandTestCase def test_log FileUtils.cd HOMEBREW_REPOSITORY do shutup do diff --git a/Library/Homebrew/test/test_integration_cmds_log_formula.rb b/Library/Homebrew/test/test_log_formula.rb similarity index 86% rename from Library/Homebrew/test/test_integration_cmds_log_formula.rb rename to Library/Homebrew/test/test_log_formula.rb index 2f1f44d005..34509bf72b 100644 --- a/Library/Homebrew/test/test_integration_cmds_log_formula.rb +++ b/Library/Homebrew/test/test_log_formula.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestLogFormula < IntegrationCommandTests +class IntegrationCommandTestLogFormula < IntegrationCommandTestCase def test_log_formula core_tap = CoreTap.new setup_test_formula "testball" diff --git a/Library/Homebrew/test/test_integration_cmds_migrate.rb b/Library/Homebrew/test/test_migrate.rb similarity index 84% rename from Library/Homebrew/test/test_integration_cmds_migrate.rb rename to Library/Homebrew/test/test_migrate.rb index 3918cbb3e6..53b32777a3 100644 --- a/Library/Homebrew/test/test_integration_cmds_migrate.rb +++ b/Library/Homebrew/test/test_migrate.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestMigrate < IntegrationCommandTests +class IntegrationCommandTestMigrate < IntegrationCommandTestCase def test_migrate setup_test_formula "testball1" setup_test_formula "testball2" diff --git a/Library/Homebrew/test/test_integration_cmds_missing.rb b/Library/Homebrew/test/test_missing.rb similarity index 59% rename from Library/Homebrew/test/test_integration_cmds_missing.rb rename to Library/Homebrew/test/test_missing.rb index 68c3a72a45..3a5fd3df09 100644 --- a/Library/Homebrew/test/test_integration_cmds_missing.rb +++ b/Library/Homebrew/test/test_missing.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestMissing < IntegrationCommandTests +class IntegrationCommandTestMissing < IntegrationCommandTestCase def test_missing setup_test_formula "foo" setup_test_formula "bar" diff --git a/Library/Homebrew/test/test_options.rb b/Library/Homebrew/test/test_options.rb index 9b123bc3c9..bfde7a9b64 100644 --- a/Library/Homebrew/test/test_options.rb +++ b/Library/Homebrew/test/test_options.rb @@ -1,5 +1,17 @@ require "testing_env" require "options" +require "helper/integration_command_test_case" + +class IntegrationCommandTestOptions < IntegrationCommandTestCase + def test_options + setup_test_formula "testball", <<-EOS.undent + depends_on "bar" => :recommended + EOS + + assert_equal "--with-foo\n\tBuild with foo\n--without-bar\n\tBuild without bar support", + cmd_output("options", "testball").chomp + end +end class OptionTests < Homebrew::TestCase def setup diff --git a/Library/Homebrew/test/test_integration_cmds_outdated.rb b/Library/Homebrew/test/test_outdated.rb similarity index 58% rename from Library/Homebrew/test/test_integration_cmds_outdated.rb rename to Library/Homebrew/test/test_outdated.rb index b42e7bc1a2..cc0f024c8d 100644 --- a/Library/Homebrew/test/test_integration_cmds_outdated.rb +++ b/Library/Homebrew/test/test_outdated.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestOutdated < IntegrationCommandTests +class IntegrationCommandTestOutdated < IntegrationCommandTestCase def test_outdated setup_test_formula "testball" (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath diff --git a/Library/Homebrew/test/test_integration_cmds_pin_unpin.rb b/Library/Homebrew/test/test_pin_unpin.rb similarity index 79% rename from Library/Homebrew/test/test_integration_cmds_pin_unpin.rb rename to Library/Homebrew/test/test_pin_unpin.rb index 828ca49c04..37682d45ee 100644 --- a/Library/Homebrew/test/test_integration_cmds_pin_unpin.rb +++ b/Library/Homebrew/test/test_pin_unpin.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestPinUnpin < IntegrationCommandTests +class IntegrationCommandTestPinUnpin < IntegrationCommandTestCase def test_pin_unpin setup_test_formula "testball" (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath diff --git a/Library/Homebrew/test/test_prefix.rb b/Library/Homebrew/test/test_prefix.rb new file mode 100644 index 0000000000..4aa63fa071 --- /dev/null +++ b/Library/Homebrew/test/test_prefix.rb @@ -0,0 +1,8 @@ +require "helper/integration_command_test_case" + +class IntegrationCommandTestPrefix < IntegrationCommandTestCase + def test_prefix + assert_equal HOMEBREW_PREFIX.to_s, + cmd("--prefix") + end +end diff --git a/Library/Homebrew/test/test_integration_cmds_prefix_formula.rb b/Library/Homebrew/test/test_prefix_formula.rb similarity index 78% rename from Library/Homebrew/test/test_integration_cmds_prefix_formula.rb rename to Library/Homebrew/test/test_prefix_formula.rb index a901309cf7..d76a966d73 100644 --- a/Library/Homebrew/test/test_integration_cmds_prefix_formula.rb +++ b/Library/Homebrew/test/test_prefix_formula.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestPrefixFormula < IntegrationCommandTests +class IntegrationCommandTestPrefixFormula < IntegrationCommandTestCase def test_prefix_formula assert_match "#{HOMEBREW_CELLAR}/testball", cmd("--prefix", testball) diff --git a/Library/Homebrew/test/test_integration_cmds_prune.rb b/Library/Homebrew/test/test_prune.rb similarity index 85% rename from Library/Homebrew/test/test_integration_cmds_prune.rb rename to Library/Homebrew/test/test_prune.rb index 6072c832eb..293a3746dd 100644 --- a/Library/Homebrew/test/test_integration_cmds_prune.rb +++ b/Library/Homebrew/test/test_prune.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestPrune < IntegrationCommandTests +class IntegrationCommandTestPrune < IntegrationCommandTestCase def test_prune share = (HOMEBREW_PREFIX/"share") diff --git a/Library/Homebrew/test/test_integration_cmds_pull.rb b/Library/Homebrew/test/test_pull.rb similarity index 88% rename from Library/Homebrew/test/test_integration_cmds_pull.rb rename to Library/Homebrew/test/test_pull.rb index 1cfb286a3f..9707ff8a82 100644 --- a/Library/Homebrew/test/test_integration_cmds_pull.rb +++ b/Library/Homebrew/test/test_pull.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestPull < IntegrationCommandTests +class IntegrationCommandTestPull < IntegrationCommandTestCase def test_pull skip "Requires network connection" if ENV["HOMEBREW_NO_GITHUB_API"] diff --git a/Library/Homebrew/test/test_integration_cmds_pull_offline.rb b/Library/Homebrew/test/test_pull_offline.rb similarity index 86% rename from Library/Homebrew/test/test_integration_cmds_pull_offline.rb rename to Library/Homebrew/test/test_pull_offline.rb index bb6fd24cff..2716af346d 100644 --- a/Library/Homebrew/test/test_integration_cmds_pull_offline.rb +++ b/Library/Homebrew/test/test_pull_offline.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestPullOffline < IntegrationCommandTests +class IntegrationCommandTestPullOffline < IntegrationCommandTestCase def test_pull_offline assert_match "You meant `git pull --rebase`.", cmd_fail("pull", "--rebase") assert_match "This command requires at least one argument", cmd_fail("pull") diff --git a/Library/Homebrew/test/test_integration_cmds_readall.rb b/Library/Homebrew/test/test_readall.rb similarity index 71% rename from Library/Homebrew/test/test_integration_cmds_readall.rb rename to Library/Homebrew/test/test_readall.rb index 1a6ca45471..d0c078e493 100644 --- a/Library/Homebrew/test/test_integration_cmds_readall.rb +++ b/Library/Homebrew/test/test_readall.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestReadall < IntegrationCommandTests +class IntegrationCommandTestReadall < IntegrationCommandTestCase def test_readall formula_file = setup_test_formula "testball" alias_file = CoreTap.new.alias_dir/"foobar" diff --git a/Library/Homebrew/test/test_integration_cmds_reinstall.rb b/Library/Homebrew/test/test_reinstall.rb similarity index 74% rename from Library/Homebrew/test/test_integration_cmds_reinstall.rb rename to Library/Homebrew/test/test_reinstall.rb index ce1c0c9196..d07a960517 100644 --- a/Library/Homebrew/test/test_integration_cmds_reinstall.rb +++ b/Library/Homebrew/test/test_reinstall.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestReinstall < IntegrationCommandTests +class IntegrationCommandTestReinstall < IntegrationCommandTestCase def test_reinstall setup_test_formula "testball" diff --git a/Library/Homebrew/test/test_integration_cmds_reinstall_pinned.rb b/Library/Homebrew/test/test_reinstall_pinned.rb similarity index 88% rename from Library/Homebrew/test/test_integration_cmds_reinstall_pinned.rb rename to Library/Homebrew/test/test_reinstall_pinned.rb index dc4695e408..c9cb8a849f 100644 --- a/Library/Homebrew/test/test_integration_cmds_reinstall_pinned.rb +++ b/Library/Homebrew/test/test_reinstall_pinned.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestReinstallPinned < IntegrationCommandTests +class IntegrationCommandTestReinstallPinned < IntegrationCommandTestCase def test_reinstall_pinned setup_test_formula "testball" diff --git a/Library/Homebrew/test/test_integration_cmds_repository.rb b/Library/Homebrew/test/test_repository.rb similarity index 65% rename from Library/Homebrew/test/test_integration_cmds_repository.rb rename to Library/Homebrew/test/test_repository.rb index a90dc1814a..2029876ad7 100644 --- a/Library/Homebrew/test/test_integration_cmds_repository.rb +++ b/Library/Homebrew/test/test_repository.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestRepository < IntegrationCommandTests +class IntegrationCommandTestRepository < IntegrationCommandTestCase def test_repository assert_match HOMEBREW_REPOSITORY.to_s, cmd("--repository") diff --git a/Library/Homebrew/test/test_integration_cmds_search.rb b/Library/Homebrew/test/test_search.rb similarity index 91% rename from Library/Homebrew/test/test_integration_cmds_search.rb rename to Library/Homebrew/test/test_search.rb index f85d1d67e4..8310d1c2b2 100644 --- a/Library/Homebrew/test/test_integration_cmds_search.rb +++ b/Library/Homebrew/test/test_search.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestSearch < IntegrationCommandTests +class IntegrationCommandTestSearch < IntegrationCommandTestCase def test_search setup_test_formula "testball" desc_cache = HOMEBREW_CACHE/"desc_cache.json" diff --git a/Library/Homebrew/test/test_integration_cmds_services.rb b/Library/Homebrew/test/test_services.rb similarity index 66% rename from Library/Homebrew/test/test_integration_cmds_services.rb rename to Library/Homebrew/test/test_services.rb index 043b5b0d6f..b5ccb7c778 100644 --- a/Library/Homebrew/test/test_integration_cmds_services.rb +++ b/Library/Homebrew/test/test_services.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestServices < IntegrationCommandTests +class IntegrationCommandTestServices < IntegrationCommandTestCase def test_services needs_test_cmd_taps needs_macos diff --git a/Library/Homebrew/test/test_integration_cmds_sh.rb b/Library/Homebrew/test/test_sh.rb similarity index 54% rename from Library/Homebrew/test/test_integration_cmds_sh.rb rename to Library/Homebrew/test/test_sh.rb index be9e119c52..449b7b5b3e 100644 --- a/Library/Homebrew/test/test_integration_cmds_sh.rb +++ b/Library/Homebrew/test/test_sh.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestSh < IntegrationCommandTests +class IntegrationCommandTestSh < IntegrationCommandTestCase def test_sh assert_match "Your shell has been configured", cmd("sh", "SHELL" => which("true")) diff --git a/Library/Homebrew/test/test_integration_cmds_switch.rb b/Library/Homebrew/test/test_switch.rb similarity index 83% rename from Library/Homebrew/test/test_integration_cmds_switch.rb rename to Library/Homebrew/test/test_switch.rb index 50b636d14a..88fdf85b98 100644 --- a/Library/Homebrew/test/test_integration_cmds_switch.rb +++ b/Library/Homebrew/test/test_switch.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestSwitch < IntegrationCommandTests +class IntegrationCommandTestSwitch < IntegrationCommandTestCase def test_switch assert_match "Usage: brew switch ", cmd_fail("switch") assert_match "testball not found", cmd_fail("switch", "testball", "0.1") diff --git a/Library/Homebrew/test/test_tap.rb b/Library/Homebrew/test/test_tap.rb index fafac252fa..1396d0a0eb 100644 --- a/Library/Homebrew/test/test_tap.rb +++ b/Library/Homebrew/test/test_tap.rb @@ -1,4 +1,34 @@ require "testing_env" +require "helper/integration_command_test_case" + +class IntegrationCommandTestTap < IntegrationCommandTestCase + def test_tap + path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" + path.mkpath + path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + FileUtils.touch "readme" + system "git", "add", "--all" + system "git", "commit", "-m", "init" + end + end + + assert_match "homebrew/foo", cmd("tap") + assert_match "homebrew/versions", cmd("tap", "--list-official") + assert_match "2 taps", cmd("tap-info") + assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "homebrew/foo") + assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "--json=v1", "--installed") + assert_match "Pinned homebrew/foo", cmd("tap-pin", "homebrew/foo") + assert_match "homebrew/foo", cmd("tap", "--list-pinned") + assert_match "Unpinned homebrew/foo", cmd("tap-unpin", "homebrew/foo") + assert_match "Tapped", cmd("tap", "homebrew/bar", path/".git") + assert_match "Untapped", cmd("untap", "homebrew/bar") + assert_equal "", cmd("tap", "homebrew/bar", path/".git", "-q", "--full") + assert_match "Untapped", cmd("untap", "homebrew/bar") + end +end class TapTest < Homebrew::TestCase include FileUtils diff --git a/Library/Homebrew/test/test_integration_cmds_tap_readme.rb b/Library/Homebrew/test/test_tap_readme.rb similarity index 70% rename from Library/Homebrew/test/test_integration_cmds_tap_readme.rb rename to Library/Homebrew/test/test_tap_readme.rb index c1f53c42d2..1181c3ffc5 100644 --- a/Library/Homebrew/test/test_integration_cmds_tap_readme.rb +++ b/Library/Homebrew/test/test_tap_readme.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestTapReadme < IntegrationCommandTests +class IntegrationCommandTestTapReadme < IntegrationCommandTestCase def test_tap_readme assert_match "brew install homebrew/foo/", cmd("tap-readme", "foo", "--verbose") diff --git a/Library/Homebrew/test/test_integration_cmds_test_formula.rb b/Library/Homebrew/test/test_test_formula.rb similarity index 94% rename from Library/Homebrew/test/test_integration_cmds_test_formula.rb rename to Library/Homebrew/test/test_test_formula.rb index 4350fdbe9d..b3889d6a2f 100644 --- a/Library/Homebrew/test/test_integration_cmds_test_formula.rb +++ b/Library/Homebrew/test/test_test_formula.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestTestFormula < IntegrationCommandTests +class IntegrationCommandTestTestFormula < IntegrationCommandTestCase def test_test_formula assert_match "This command requires a formula argument", cmd_fail("test") assert_match "Testing requires the latest version of testball", diff --git a/Library/Homebrew/test/test_integration_cmds_uninstall.rb b/Library/Homebrew/test/test_uninstall.rb similarity index 55% rename from Library/Homebrew/test/test_integration_cmds_uninstall.rb rename to Library/Homebrew/test/test_uninstall.rb index 6f82bedc77..050934238e 100644 --- a/Library/Homebrew/test/test_integration_cmds_uninstall.rb +++ b/Library/Homebrew/test/test_uninstall.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestUninstall < IntegrationCommandTests +class IntegrationCommandTestUninstall < IntegrationCommandTestCase def test_uninstall cmd("install", testball) assert_match "Uninstalling testball", cmd("uninstall", "--force", testball) diff --git a/Library/Homebrew/test/test_integration_cmds_unlink.rb b/Library/Homebrew/test/test_unlink.rb similarity index 60% rename from Library/Homebrew/test/test_integration_cmds_unlink.rb rename to Library/Homebrew/test/test_unlink.rb index b64cc81406..091bd8c45b 100644 --- a/Library/Homebrew/test/test_integration_cmds_unlink.rb +++ b/Library/Homebrew/test/test_unlink.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestUnlink < IntegrationCommandTests +class IntegrationCommandTestUnlink < IntegrationCommandTestCase def test_unlink setup_test_formula "testball" diff --git a/Library/Homebrew/test/test_integration_cmds_unlinkapps.rb b/Library/Homebrew/test/test_unlinkapps.rb similarity index 78% rename from Library/Homebrew/test/test_integration_cmds_unlinkapps.rb rename to Library/Homebrew/test/test_unlinkapps.rb index 047f17a1da..2de4e3ff8a 100644 --- a/Library/Homebrew/test/test_integration_cmds_unlinkapps.rb +++ b/Library/Homebrew/test/test_unlinkapps.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestUnlinkapps < IntegrationCommandTests +class IntegrationCommandTestUnlinkapps < IntegrationCommandTestCase def test_unlinkapps home_dir = Pathname.new(mktmpdir) apps_dir = home_dir/"Applications" diff --git a/Library/Homebrew/test/test_integration_cmds_unpack.rb b/Library/Homebrew/test/test_unpack.rb similarity index 68% rename from Library/Homebrew/test/test_integration_cmds_unpack.rb rename to Library/Homebrew/test/test_unpack.rb index 1b6e97e52d..de1452a297 100644 --- a/Library/Homebrew/test/test_integration_cmds_unpack.rb +++ b/Library/Homebrew/test/test_unpack.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestUnpack < IntegrationCommandTests +class IntegrationCommandTestUnpack < IntegrationCommandTestCase def test_unpack setup_test_formula "testball" diff --git a/Library/Homebrew/test/test_integration_cmds_upgrade.rb b/Library/Homebrew/test/test_upgrade.rb similarity index 68% rename from Library/Homebrew/test/test_integration_cmds_upgrade.rb rename to Library/Homebrew/test/test_upgrade.rb index 5eee33d56b..73618293bc 100644 --- a/Library/Homebrew/test/test_integration_cmds_upgrade.rb +++ b/Library/Homebrew/test/test_upgrade.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestUpgrade < IntegrationCommandTests +class IntegrationCommandTestUpgrade < IntegrationCommandTestCase def test_upgrade setup_test_formula "testball" (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath diff --git a/Library/Homebrew/test/test_integration_cmds_uses.rb b/Library/Homebrew/test/test_uses.rb similarity index 76% rename from Library/Homebrew/test/test_integration_cmds_uses.rb rename to Library/Homebrew/test/test_uses.rb index e5c0c0f770..b0e79ef2d8 100644 --- a/Library/Homebrew/test/test_integration_cmds_uses.rb +++ b/Library/Homebrew/test/test_uses.rb @@ -1,6 +1,6 @@ -require "integration_cmds_tests" +require "helper/integration_command_test_case" -class IntegrationCommandTestUses < IntegrationCommandTests +class IntegrationCommandTestUses < IntegrationCommandTestCase def test_uses setup_test_formula "foo" setup_test_formula "bar" diff --git a/Library/Homebrew/test/test_version.rb b/Library/Homebrew/test/test_version.rb new file mode 100644 index 0000000000..ca37e3567a --- /dev/null +++ b/Library/Homebrew/test/test_version.rb @@ -0,0 +1,8 @@ +require "helper/integration_command_test_case" + +class IntegrationCommandTestVersion < IntegrationCommandTestCase + def test_version + assert_match HOMEBREW_VERSION.to_s, + cmd("--version") + end +end