tests: avoid unnecessary chdir

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jack Nagel 2012-08-30 00:09:29 -05:00
parent 1a9c2917a4
commit be8827d8a4
3 changed files with 12 additions and 11 deletions

View File

@ -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

View File

@ -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?

View File

@ -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