diff options
| author | Jack Nagel | 2012-08-30 00:09:29 -0500 |
|---|---|---|
| committer | Jack Nagel | 2012-08-30 00:10:02 -0500 |
| commit | 4197a4872d33495183f10a9964f8fbafb3c9415c (patch) | |
| tree | 3589b2a21551d3ab412a367d5b848e14d1af0235 | |
| parent | 0481473163b2b84fedb8325d9360063c7bf40d74 (diff) | |
| download | homebrew-4197a4872d33495183f10a9964f8fbafb3c9415c.tar.bz2 | |
tests: avoid unnecessary chdir
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
| -rw-r--r-- | Library/Homebrew/test/Rakefile | 6 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_mach.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/test/testing_env.rb | 7 |
3 files changed, 12 insertions, 11 deletions
diff --git a/Library/Homebrew/test/Rakefile b/Library/Homebrew/test/Rakefile index 5faa77ca7..c92b19640 100644 --- a/Library/Homebrew/test/Rakefile +++ b/Library/Homebrew/test/Rakefile @@ -1,7 +1,9 @@ require 'rake' require 'rake/testtask' +require 'pathname' + +TEST_DIRECTORY = Pathname.new(File.expand_path(__FILE__)).parent.realpath -TEST_DIRECTORY = File.expand_path(File.dirname(__FILE__)) TEST_FILES = FileList["#{TEST_DIRECTORY}/test_*.rb"] Dir.chdir TEST_DIRECTORY @@ -34,7 +36,7 @@ begin --exclude=test_ --exclude=testball --exclude=testing} - t.output_dir = TEST_DIRECTORY+'/coverage' + t.output_dir = TEST_DIRECTORY+'coverage' end rescue LoadError nil diff --git a/Library/Homebrew/test/test_mach.rb b/Library/Homebrew/test/test_mach.rb index 7b14fd431..c4d41f713 100644 --- a/Library/Homebrew/test/test_mach.rb +++ b/Library/Homebrew/test/test_mach.rb @@ -136,8 +136,12 @@ class MachOPathnameTests < Test::Unit::TestCase end class TextExecutableTests < Test::Unit::TestCase + def teardown + (HOMEBREW_PREFIX/'foo_script').unlink + end + def test_simple_shebang - pn = Pathname.new('foo') + pn = HOMEBREW_PREFIX/'foo_script' pn.write '#!/bin/sh' assert !pn.universal? assert !pn.i386? @@ -153,7 +157,7 @@ class TextExecutableTests < Test::Unit::TestCase end def test_shebang_with_options - pn = Pathname.new('bar') + pn = HOMEBREW_PREFIX/'foo_script' pn.write '#! /usr/bin/perl -w' assert !pn.universal? assert !pn.i386? @@ -169,7 +173,7 @@ class TextExecutableTests < Test::Unit::TestCase end def test_malformed_shebang - pn = Pathname.new('baz') + pn = HOMEBREW_PREFIX/'foo_script' pn.write ' #!' assert !pn.universal? assert !pn.i386? diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index 7042b77e1..1333db5a8 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -26,12 +26,7 @@ MACOS_VERSION=10.6 (HOMEBREW_PREFIX+'Library/Formula').mkpath -prevwd = Dir.pwd -Dir.chdir HOMEBREW_PREFIX -at_exit do - Dir.chdir prevwd - HOMEBREW_PREFIX.parent.rmtree -end +at_exit { HOMEBREW_PREFIX.parent.rmtree } # Test fixtures and files can be found relative to this path TEST_FOLDER = Pathname.new(ABS__FILE__).parent.realpath |
