mirror of
https://github.com/ariya/phantomjs.git
synced 2024-10-26 14:29:13 +03:00
Make paths to PhantomJS and Python interpreters available to tests.
Incidental refactoring of the environment variable setup code in run-tests.py and testharness.js.
This commit is contained in:
parent
8f7d29b875
commit
ed4c4526db
@ -1461,6 +1461,16 @@ if (args.test_script === "") {
|
|||||||
// process_command_line has already issued an error message.
|
// process_command_line has already issued an error message.
|
||||||
phantom.exit(2);
|
phantom.exit(2);
|
||||||
} else {
|
} else {
|
||||||
|
// run-tests.py sets these environment variables to the base URLs
|
||||||
|
// of its HTTP and HTTPS servers.
|
||||||
|
expose(sys.env['TEST_HTTP_BASE'], 'TEST_HTTP_BASE');
|
||||||
|
expose(sys.env['TEST_HTTPS_BASE'], 'TEST_HTTPS_BASE');
|
||||||
|
|
||||||
|
// run-tests.py sets these environment variables to the full pathnames
|
||||||
|
// of the PhantomJS binary and Python interpreter.
|
||||||
|
expose(sys.env['PHANTOMJS'], 'PHANTOMJS');
|
||||||
|
expose(sys.env['PYTHON'], 'PYTHON');
|
||||||
|
|
||||||
// run-tests.py sets this environment variable to the root of the
|
// run-tests.py sets this environment variable to the root of the
|
||||||
// test directory.
|
// test directory.
|
||||||
expose(sys.env['TEST_DIR'], 'TEST_DIR');
|
expose(sys.env['TEST_DIR'], 'TEST_DIR');
|
||||||
@ -1478,11 +1488,6 @@ if (args.test_script === "") {
|
|||||||
test_script.lastIndexOf(fs.separator));
|
test_script.lastIndexOf(fs.separator));
|
||||||
require.paths.push(phantom.libraryPath);
|
require.paths.push(phantom.libraryPath);
|
||||||
|
|
||||||
// run-tests.py sets these environment variables to the base URLs
|
|
||||||
// of its HTTP and HTTPS servers.
|
|
||||||
expose(sys.env['TEST_HTTP_BASE'], 'TEST_HTTP_BASE');
|
|
||||||
expose(sys.env['TEST_HTTPS_BASE'], 'TEST_HTTPS_BASE');
|
|
||||||
|
|
||||||
var output = new Output(sys.stdout, args.verbose);
|
var output = new Output(sys.stdout, args.verbose);
|
||||||
var tests = new Tests(output);
|
var tests = new Tests(output);
|
||||||
|
|
||||||
|
@ -771,6 +771,36 @@ class TestRunner(object):
|
|||||||
self.debugger = options.debugger
|
self.debugger = options.debugger
|
||||||
self.to_run = options.to_run
|
self.to_run = options.to_run
|
||||||
self.server_errs = []
|
self.server_errs = []
|
||||||
|
self.prepare_environ()
|
||||||
|
|
||||||
|
def prepare_environ(self):
|
||||||
|
os.environ["TEST_DIR"] = self.base_path
|
||||||
|
|
||||||
|
# Tell test processes where to find the PhantomJS binary and
|
||||||
|
# the Python interpreter.
|
||||||
|
os.environ["PHANTOMJS"] = self.phantomjs_exe
|
||||||
|
os.environ["PYTHON"] = sys.executable
|
||||||
|
|
||||||
|
# Run all the tests in the "C" locale. (A UTF-8-based locale
|
||||||
|
# which is thoroughly different from "C" would flush out more
|
||||||
|
# bugs, but we have no way of knowing if such a locale exists.)
|
||||||
|
for var in list(os.environ.keys()):
|
||||||
|
if var[:3] == 'LC_' or var[:4] == 'LANG':
|
||||||
|
del os.environ[var]
|
||||||
|
os.environ["LANG"] = "C"
|
||||||
|
|
||||||
|
# Run all the tests in Chatham Islands Standard Time, UTC+12:45.
|
||||||
|
# This timezone is deliberately chosen to be unusual: it's not a
|
||||||
|
# whole number of hours offset from UTC *and* it's more than twelve
|
||||||
|
# hours offset from UTC.
|
||||||
|
#
|
||||||
|
# The Chatham Islands do observe daylight savings, but we don't
|
||||||
|
# implement that because testsuite issues only reproducible on two
|
||||||
|
# particular days out of the year are too much tsuris.
|
||||||
|
#
|
||||||
|
# Note that the offset in a TZ value is the negative of the way it's
|
||||||
|
# usually written, e.g. UTC+1 would be xxx-1:00.
|
||||||
|
os.environ["TZ"] = "CIST-12:45:00"
|
||||||
|
|
||||||
def signal_server_error(self, exc_info):
|
def signal_server_error(self, exc_info):
|
||||||
self.server_errs.append(exc_info)
|
self.server_errs.append(exc_info)
|
||||||
@ -981,7 +1011,6 @@ class TestRunner(object):
|
|||||||
|
|
||||||
def init():
|
def init():
|
||||||
base_path = os.path.normpath(os.path.dirname(os.path.abspath(__file__)))
|
base_path = os.path.normpath(os.path.dirname(os.path.abspath(__file__)))
|
||||||
os.environ["TEST_DIR"] = base_path
|
|
||||||
|
|
||||||
phantomjs_exe = os.path.normpath(base_path + '/../bin/phantomjs')
|
phantomjs_exe = os.path.normpath(base_path + '/../bin/phantomjs')
|
||||||
if sys.platform in ('win32', 'cygwin'):
|
if sys.platform in ('win32', 'cygwin'):
|
||||||
@ -1019,28 +1048,6 @@ def init():
|
|||||||
|
|
||||||
sys.stdout.write(colorize("b", "## Testing PhantomJS "+ver[0])+"\n")
|
sys.stdout.write(colorize("b", "## Testing PhantomJS "+ver[0])+"\n")
|
||||||
|
|
||||||
# Run all the tests in Chatham Islands Standard Time, UTC+12:45.
|
|
||||||
# This timezone is deliberately chosen to be unusual: it's not a
|
|
||||||
# whole number of hours offset from UTC *and* it's more than twelve
|
|
||||||
# hours offset from UTC.
|
|
||||||
#
|
|
||||||
# The Chatham Islands do observe daylight savings, but we don't
|
|
||||||
# implement that because testsuite issues only reproducible on two
|
|
||||||
# particular days out of the year are too much tsuris.
|
|
||||||
#
|
|
||||||
# Note that the offset in a TZ value is the negative of the way it's
|
|
||||||
# usually written, e.g. UTC+1 would be xxx-1:00.
|
|
||||||
os.environ["TZ"] = "CIST-12:45:00"
|
|
||||||
|
|
||||||
# Run all the tests in the "C" locale. (A UTF-8-based locale
|
|
||||||
# which is thoroughly different from "C" would flush out more
|
|
||||||
# bugs, but we have no way of knowing if such a locale exists.)
|
|
||||||
for var in list(os.environ.keys()):
|
|
||||||
if var[:3] == 'LC_' or var[:4] == 'LANG':
|
|
||||||
del os.environ[var]
|
|
||||||
|
|
||||||
os.environ["LANG"] = "C"
|
|
||||||
|
|
||||||
return runner
|
return runner
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
Reference in New Issue
Block a user