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

Unified Diff: run_isolated.py

Issue 25549003: Fix running 'import run_isolated' at python interactive prompt. (Closed) Base URL: https://chromium.googlesource.com/a/chromium/tools/swarm_client@1_update_item
Patch Set: Added comment Created 7 years, 3 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 | « no previous file | swarming.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: run_isolated.py
diff --git a/run_isolated.py b/run_isolated.py
index 0c1b4cc0c7552350a98b9caca9000d071198b25e..950f33c67431f9e77aad7228c671ade216125329 100755
--- a/run_isolated.py
+++ b/run_isolated.py
@@ -39,7 +39,13 @@ THIS_FILE_PATH = os.path.abspath(__file__) if __file__ else None
BASE_DIR = os.path.dirname(THIS_FILE_PATH) if __file__ else None
# Directory that contains currently running script file.
-MAIN_DIR = os.path.dirname(os.path.abspath(zip_package.get_main_script_path()))
+if zip_package.get_main_script_path():
+ MAIN_DIR = os.path.dirname(
+ os.path.abspath(zip_package.get_main_script_path()))
+else:
+ # This happens when 'import run_isolated' is executed at the python
+ # interactive prompt, in that case __file__ is undefined.
+ MAIN_DIR = None
# Types of action accepted by link_file().
HARDLINK, HARDLINK_WITH_FALLBACK, SYMLINK, COPY = range(1, 5)
@@ -514,8 +520,9 @@ def run_tha_test(isolated_hash, cache_dir, retriever, policies):
# TODO(vadimsh): Pass it via 'env_vars' in manifest.
# Add a rotating log file if one doesn't already exist.
env = os.environ.copy()
- env.setdefault('RUN_TEST_CASES_LOG_FILE',
- os.path.join(MAIN_DIR, RUN_TEST_CASES_LOG))
+ if MAIN_DIR:
+ env.setdefault('RUN_TEST_CASES_LOG_FILE',
+ os.path.join(MAIN_DIR, RUN_TEST_CASES_LOG))
try:
with tools.Profiler('RunTest'):
return subprocess.call(settings.command, cwd=cwd, env=env)
« no previous file with comments | « no previous file | swarming.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698