diff options
| author | Markus Reiter | 2017-02-09 04:39:53 +0100 |
|---|---|---|
| committer | Markus Reiter | 2017-02-10 17:19:19 +0100 |
| commit | 31b9dc28e3105d9164fb28d7e29985ba1f1775eb (patch) | |
| tree | 7ccaf0268385f3d7c0d52e866426798a2f524917 /Library | |
| parent | b9de5c04908bbbe2e2c30fff57b1301e17082202 (diff) | |
| download | brew-31b9dc28e3105d9164fb28d7e29985ba1f1775eb.tar.bz2 | |
Remove cask test directory.
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Homebrew/cask/cmd/brew-cask-tests.rb | 31 | ||||
| -rwxr-xr-x | Library/Homebrew/cask/spec/upload_coverage.rb (renamed from Library/Homebrew/cask/test/upload_coverage.rb) | 0 | ||||
| -rw-r--r-- | Library/Homebrew/cask/test/support/cleanup.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/cask/test/support/fake_dirs.rb | 31 | ||||
| -rw-r--r-- | Library/Homebrew/cask/test/support/fake_system_command.rb | 77 | ||||
| -rw-r--r-- | Library/Homebrew/cask/test/support/shared_examples.rb | 25 | ||||
| -rw-r--r-- | Library/Homebrew/cask/test/test_helper.rb | 102 |
7 files changed, 10 insertions, 266 deletions
diff --git a/Library/Homebrew/cask/cmd/brew-cask-tests.rb b/Library/Homebrew/cask/cmd/brew-cask-tests.rb index bdcabd4dc..b27bc2fe7 100755 --- a/Library/Homebrew/cask/cmd/brew-cask-tests.rb +++ b/Library/Homebrew/cask/cmd/brew-cask-tests.rb @@ -21,36 +21,25 @@ cask_root.cd do system "bundle", "install" end - rspec = ARGV.flag?("--rspec") || !ARGV.flag?("--minitest") - minitest = ARGV.flag?("--minitest") || !ARGV.flag?("--rspec") - if ARGV.flag?("--coverage") ENV["HOMEBREW_TESTS_COVERAGE"] = "1" upload_coverage = ENV["CODECOV_TOKEN"] || ENV["TRAVIS"] end - failed = false - - if rspec - run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[ - --color - --require spec_helper - --format progress - --format ParallelTests::RSpec::RuntimeLogger - --out tmp/parallel_runtime_rspec.log - ] - failed ||= !$CHILD_STATUS.success? - end + run_tests "parallel_rspec", Dir["spec/**/*_spec.rb"], %w[ + --color + --require spec_helper + --format progress + --format ParallelTests::RSpec::RuntimeLogger + --out tmp/parallel_runtime_rspec.log + ] - if minitest - run_tests "parallel_test", Dir["test/**/*_test.rb"] - failed ||= !$CHILD_STATUS.success? + unless $CHILD_STATUS.success? + Homebrew.failed = true end - Homebrew.failed = failed - if upload_coverage puts "Submitting Codecov coverage..." - system "bundle", "exec", "test/upload_coverage.rb" + system "bundle", "exec", "spec/upload_coverage.rb" end end diff --git a/Library/Homebrew/cask/test/upload_coverage.rb b/Library/Homebrew/cask/spec/upload_coverage.rb index 06d38157d..06d38157d 100755 --- a/Library/Homebrew/cask/test/upload_coverage.rb +++ b/Library/Homebrew/cask/spec/upload_coverage.rb diff --git a/Library/Homebrew/cask/test/support/cleanup.rb b/Library/Homebrew/cask/test/support/cleanup.rb deleted file mode 100644 index c31a74be2..000000000 --- a/Library/Homebrew/cask/test/support/cleanup.rb +++ /dev/null @@ -1,10 +0,0 @@ -module MiniTest - class Spec - def after_teardown - super - Hbc.installed.each do |cask| - Hbc::Installer.new(cask).purge_versioned_files - end - end - end -end diff --git a/Library/Homebrew/cask/test/support/fake_dirs.rb b/Library/Homebrew/cask/test/support/fake_dirs.rb deleted file mode 100644 index ea7acc685..000000000 --- a/Library/Homebrew/cask/test/support/fake_dirs.rb +++ /dev/null @@ -1,31 +0,0 @@ -# wire in a set of fake link dirs per-test -module FakeDirHooks - DIRS = [:appdir, :qlplugindir, :binarydir].freeze - - def before_setup - super - - @canned_dirs = {} - - DIRS.each do |dir_name| - dir = HOMEBREW_PREFIX.join("#{dir_name}-#{Time.now.to_i}-#{rand(1024)}") - dir.mkpath - Hbc.send("#{dir_name}=", dir) - @canned_dirs[:dir_name] = dir - end - end - - def after_teardown - super - - @canned_dirs.each_value do |dir| - dir.rmtree if dir.exist? - end - end -end - -module MiniTest - class Spec - include FakeDirHooks - end -end diff --git a/Library/Homebrew/cask/test/support/fake_system_command.rb b/Library/Homebrew/cask/test/support/fake_system_command.rb deleted file mode 100644 index 97efd0761..000000000 --- a/Library/Homebrew/cask/test/support/fake_system_command.rb +++ /dev/null @@ -1,77 +0,0 @@ -module Hbc - class FakeSystemCommand - def self.responses - @responses ||= {} - end - - def self.expectations - @expectations ||= {} - end - - def self.system_calls - @system_calls ||= Hash.new(0) - end - - def self.clear - @responses = nil - @expectations = nil - @system_calls = nil - end - - def self.stubs_command(command, response = "") - responses[command] = response - end - - def self.expects_command(command, response = "", times = 1) - stubs_command(command, response) - expectations[command] = times - end - - def self.expect_and_pass_through(command, times = 1) - pass_through = ->(cmd, opts) { Hbc::SystemCommand.run(cmd, opts) } - expects_command(command, pass_through, times) - end - - def self.verify_expectations! - expectations.each do |command, times| - unless system_calls[command] == times - raise("expected #{command.inspect} to be run #{times} times, but got #{system_calls[command]}") - end - end - end - - def self.run(command_string, options = {}) - command = Hbc::SystemCommand.new(command_string, options).command - unless responses.key?(command) - raise("no response faked for #{command.inspect}, faked responses are: #{responses.inspect}") - end - system_calls[command] += 1 - - response = responses[command] - if response.respond_to?(:call) - response.call(command_string, options) - else - Hbc::SystemCommand::Result.new(command, response, "", 0) - end - end - - def self.run!(command, options = {}) - run(command, options.merge(must_succeed: true)) - end - end -end - -module FakeSystemCommandHooks - def after_teardown - super - Hbc::FakeSystemCommand.verify_expectations! - ensure - Hbc::FakeSystemCommand.clear - end -end - -module MiniTest - class Spec - include FakeSystemCommandHooks - end -end diff --git a/Library/Homebrew/cask/test/support/shared_examples.rb b/Library/Homebrew/cask/test/support/shared_examples.rb deleted file mode 100644 index 594ca81c1..000000000 --- a/Library/Homebrew/cask/test/support/shared_examples.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Adapted from https://gist.github.com/jodosha/1560208 -MiniTest::Spec.class_eval do - def self.shared_examples - @shared_examples ||= {} - end -end - -module MiniTest - class Spec - module SharedExamples - def shared_examples_for(desc, &block) - MiniTest::Spec.shared_examples[desc] = block - end - - def it_behaves_like(desc, *args, &block) - instance_exec(*args, &MiniTest::Spec.shared_examples[desc]) - instance_eval(&block) if block_given? - end - end - end -end - -Object.class_eval do - include(MiniTest::Spec::SharedExamples) -end diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb deleted file mode 100644 index a4bb9af0f..000000000 --- a/Library/Homebrew/cask/test/test_helper.rb +++ /dev/null @@ -1,102 +0,0 @@ -require "bundler" -require "bundler/setup" -require "pathname" - -require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] - -# add Homebrew to load path -$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew")) -$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew/test/support/lib")) - -require "global" - -# add Homebrew-Cask to load path -$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s) - -require "test/support/helper/shutup" -include Test::Helper::Shutup - -def sudo(*args) - %w[/usr/bin/sudo -E --] + args.flatten -end - -# must be called after testing_env so at_exit hooks are in proper order -require "minitest/autorun" -require "minitest/reporters" -Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true) - -require "parallel_tests/test/runtime_logger" - -# Force mocha to patch MiniTest since we have both loaded thanks to homebrew's testing_env -require "mocha/api" -require "mocha/integration/mini_test" -Mocha::Integration::MiniTest.activate - -# our baby -require "hbc" - -# create and override default directories -Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath) -Hbc.cache.mkpath -Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath) -Hbc.default_tap = Tap.fetch("caskroom", "test").tap do |tap| - # link test casks - FileUtils.mkdir_p tap.path.dirname - FileUtils.ln_s TEST_FIXTURE_DIR.join("cask"), tap.path -end - -# pretend that the caskroom/cask Tap is installed -FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path - -class TestHelper - # helpers for test Casks to reference local files easily - def self.local_binary_path(name) - File.expand_path(File.join(File.dirname(__FILE__), "support", "binaries", name)) - end - - def self.local_binary_url(name) - "file://" + local_binary_path(name) - end - - def self.valid_symlink?(candidate) - return false unless candidate.symlink? - candidate.readlink.exist? - end - - def self.install_without_artifacts(cask) - Hbc::Installer.new(cask).tap do |i| - shutup do - i.download - i.extract_primary_container - end - end - end - - def self.install_with_caskfile(cask) - Hbc::Installer.new(cask).tap do |i| - shutup do - i.save_caskfile - end - end - end - - def self.install_without_artifacts_with_caskfile(cask) - Hbc::Installer.new(cask).tap do |i| - shutup do - i.download - i.extract_primary_container - i.save_caskfile - end - end - end -end - -# Extend MiniTest API with support for RSpec-style shared examples -require "support/shared_examples" - -require "support/fake_dirs" -require "support/fake_system_command" -require "support/cleanup" -require "support/never_sudo_system_command" -require "tmpdir" -require "tempfile" |
