diff options
| author | Martin Afanasjew | 2016-01-20 06:16:10 +0100 |
|---|---|---|
| committer | Martin Afanasjew | 2016-01-21 05:42:23 +0100 |
| commit | 274640c97a44756f1b4f32cf0adfd540cbce8b1a (patch) | |
| tree | e77ad59c916dacda2323b2498febac05b1fb85f5 /Library | |
| parent | 5786f36b624ec10c826953940c74f46041c2b50e (diff) | |
| download | brew-274640c97a44756f1b4f32cf0adfd540cbce8b1a.tar.bz2 | |
tests: use unique identifiers w/ integration tests
Commands executed during integration testing are executed in a separate
process and thus generate a new result set for each command. To avoid
that these results override each other, they need to have a unique
`command_name`. Derive this name from the test class/name and the index
of the command inside that test, resulting in identifiers like
`IntegrationCommandTests#test_prefix.1 brew --prefix`.
Also replaces `TEST_TMPDIR` in the arguments with `"@TMPDIR@"` to get a
cleaner command identifier that is independent of the temporary
directory that changes with every run.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/.simplecov | 4 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_integration_cmds.rb | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/Library/Homebrew/test/.simplecov b/Library/Homebrew/test/.simplecov index e6db2ca62..21c6acc18 100644 --- a/Library/Homebrew/test/.simplecov +++ b/Library/Homebrew/test/.simplecov @@ -13,8 +13,8 @@ SimpleCov.start do add_filter "Homebrew/vendor/" end -if name = ENV["HOMEBREW_INTEGRATION_TEST"] - SimpleCov.command_name "brew #{name}" +if ENV["HOMEBREW_INTEGRATION_TEST"] + SimpleCov.command_name ENV["HOMEBREW_INTEGRATION_TEST"] SimpleCov.at_exit do exit_code = $!.nil? ? 0 : $!.status $stdout.reopen("/dev/null") diff --git a/Library/Homebrew/test/test_integration_cmds.rb b/Library/Homebrew/test/test_integration_cmds.rb index 373260250..78b268a27 100644 --- a/Library/Homebrew/test/test_integration_cmds.rb +++ b/Library/Homebrew/test/test_integration_cmds.rb @@ -4,6 +4,16 @@ require "core_formula_repository" require "fileutils" class IntegrationCommandTests < Homebrew::TestCase + def setup + @cmd_id_index = 0 # Assign unique IDs to invocations of `cmd_output`. + 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 : {} @@ -18,7 +28,7 @@ class IntegrationCommandTests < Homebrew::TestCase cmd_args += args Bundler.with_original_env do ENV["HOMEBREW_BREW_FILE"] = HOMEBREW_PREFIX/"bin/brew" - ENV["HOMEBREW_INTEGRATION_TEST"] = args.join " " + ENV["HOMEBREW_INTEGRATION_TEST"] = cmd_id_from_args(args) ENV["HOMEBREW_TEST_TMPDIR"] = TEST_TMPDIR env.each_pair { |k,v| ENV[k] = v } |
