Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Unified Diff: testing/test_env.py

Issue 9621014: Separate xvfb.py logic into its own script (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base.gyp ('k') | testing/xvfb.py » ('j') | testing/xvfb.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/test_env.py
diff --git a/testing/test_env.py b/testing/test_env.py
new file mode 100755
index 0000000000000000000000000000000000000000..f2a4f286842b4e70edf20fbcd900a79b65fa0d81
--- /dev/null
+++ b/testing/test_env.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Sets environment variables needed to run a chromium unit test."""
+
+import os
+import subprocess
+import sys
+
+# This is hardcoded to be src/ relative to this script.
+ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+
+def run_executable(cmd, env):
+ """Runs an executable with:
+ - environment variable CR_SOURCE_ROOT set to the root directory.
+ - environment variable LANGUAGE to en_US.UTF-8.
+ - Reuses sys.executable automatically.
+ """
+ # Many tests assume a English interface...
+ env['LANGUAGE'] = 'en_US.UTF-8'
+ # Used by base/base_paths_linux.cc
+ env['CR_SOURCE_ROOT'] = os.path.abspath(ROOT_DIR).encode('utf-8')
+ if cmd[0].endswith('.py'):
+ cmd.insert(0, sys.executable)
+ return subprocess.call(cmd, env=env)
+
+
+def main():
+ return run_executable(sys.argv[1:], os.environ.copy())
+
+
+if __name__ == "__main__":
+ sys.exit(main())
« no previous file with comments | « base/base.gyp ('k') | testing/xvfb.py » ('j') | testing/xvfb.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698