tests: avoid unnecessary chdir
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
1a9c2917a4
commit
be8827d8a4
@ -1,7 +1,9 @@
|
|||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/testtask'
|
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"]
|
TEST_FILES = FileList["#{TEST_DIRECTORY}/test_*.rb"]
|
||||||
|
|
||||||
Dir.chdir TEST_DIRECTORY
|
Dir.chdir TEST_DIRECTORY
|
||||||
@ -34,7 +36,7 @@ begin
|
|||||||
--exclude=test_
|
--exclude=test_
|
||||||
--exclude=testball
|
--exclude=testball
|
||||||
--exclude=testing}
|
--exclude=testing}
|
||||||
t.output_dir = TEST_DIRECTORY+'/coverage'
|
t.output_dir = TEST_DIRECTORY+'coverage'
|
||||||
end
|
end
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
nil
|
nil
|
||||||
|
|||||||
@ -136,8 +136,12 @@ class MachOPathnameTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
class TextExecutableTests < Test::Unit::TestCase
|
class TextExecutableTests < Test::Unit::TestCase
|
||||||
|
def teardown
|
||||||
|
(HOMEBREW_PREFIX/'foo_script').unlink
|
||||||
|
end
|
||||||
|
|
||||||
def test_simple_shebang
|
def test_simple_shebang
|
||||||
pn = Pathname.new('foo')
|
pn = HOMEBREW_PREFIX/'foo_script'
|
||||||
pn.write '#!/bin/sh'
|
pn.write '#!/bin/sh'
|
||||||
assert !pn.universal?
|
assert !pn.universal?
|
||||||
assert !pn.i386?
|
assert !pn.i386?
|
||||||
@ -153,7 +157,7 @@ class TextExecutableTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_with_options
|
def test_shebang_with_options
|
||||||
pn = Pathname.new('bar')
|
pn = HOMEBREW_PREFIX/'foo_script'
|
||||||
pn.write '#! /usr/bin/perl -w'
|
pn.write '#! /usr/bin/perl -w'
|
||||||
assert !pn.universal?
|
assert !pn.universal?
|
||||||
assert !pn.i386?
|
assert !pn.i386?
|
||||||
@ -169,7 +173,7 @@ class TextExecutableTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_malformed_shebang
|
def test_malformed_shebang
|
||||||
pn = Pathname.new('baz')
|
pn = HOMEBREW_PREFIX/'foo_script'
|
||||||
pn.write ' #!'
|
pn.write ' #!'
|
||||||
assert !pn.universal?
|
assert !pn.universal?
|
||||||
assert !pn.i386?
|
assert !pn.i386?
|
||||||
|
|||||||
@ -26,12 +26,7 @@ MACOS_VERSION=10.6
|
|||||||
|
|
||||||
(HOMEBREW_PREFIX+'Library/Formula').mkpath
|
(HOMEBREW_PREFIX+'Library/Formula').mkpath
|
||||||
|
|
||||||
prevwd = Dir.pwd
|
at_exit { HOMEBREW_PREFIX.parent.rmtree }
|
||||||
Dir.chdir HOMEBREW_PREFIX
|
|
||||||
at_exit do
|
|
||||||
Dir.chdir prevwd
|
|
||||||
HOMEBREW_PREFIX.parent.rmtree
|
|
||||||
end
|
|
||||||
|
|
||||||
# Test fixtures and files can be found relative to this path
|
# Test fixtures and files can be found relative to this path
|
||||||
TEST_FOLDER = Pathname.new(ABS__FILE__).parent.realpath
|
TEST_FOLDER = Pathname.new(ABS__FILE__).parent.realpath
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user