提交 26af67ab 编写于 作者: M Mislav Marohnić

ensure that tests can't shell out to our real `git` and `open` executables

Fake `git` and `open` executables are pushed to PATH in testing and error
out when invoked. This is because there are tests that shell out to `git init`
and `git clone`, or open the browser, and bugs and failures in these tests
would previously cause them to poke around the system uncontrolled.
上级 8bc31899
#!/bin/sh
if [[ $1 == "--version" ]]; then
echo "git version 1.7.0.4"
else
echo "ERROR: git was called, but wasn't supposed to:" git $*
exit 1
fi
#!/bin/sh
echo "ERROR: open was called, but wasn't supposed to:" open $*
exit 1
\ No newline at end of file
...@@ -12,6 +12,10 @@ require 'hub/standalone' ...@@ -12,6 +12,10 @@ require 'hub/standalone'
# We're looking for `open` in the tests. # We're looking for `open` in the tests.
ENV['BROWSER'] = 'open' ENV['BROWSER'] = 'open'
# Setup path with fake executables in case a test hits them
fakebin_dir = File.expand_path('../fakebin', __FILE__)
ENV['PATH'] = "#{fakebin_dir}:#{ENV['PATH']}"
class Test::Unit::TestCase class Test::Unit::TestCase
# Shortcut for creating a `Hub` instance. Pass it what you would # Shortcut for creating a `Hub` instance. Pass it what you would
# normally pass `hub` on the command line, e.g. # normally pass `hub` on the command line, e.g.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册