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

Unified Diff: appengine/swarming/swarming_bot/bot_code/task_runner_test.py

Issue 2443663002: Pass args in file from task_runner to run_isolated (Closed)
Patch Set: Created 4 years, 2 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
Index: appengine/swarming/swarming_bot/bot_code/task_runner_test.py
diff --git a/appengine/swarming/swarming_bot/bot_code/task_runner_test.py b/appengine/swarming/swarming_bot/bot_code/task_runner_test.py
index 83a7f85e64e490a00d91dbdfd4fec4be049e4093..718d5bf0b270af627753b1c6ab5a8fa7d9bdb494 100755
--- a/appengine/swarming/swarming_bot/bot_code/task_runner_test.py
+++ b/appengine/swarming/swarming_bot/bot_code/task_runner_test.py
@@ -363,9 +363,14 @@ class TestTaskRunner(TestTaskRunnerBase):
# Mock running run_isolated with a script.
SCRIPT_ISOLATED = (
'import json, sys;\n'
- 'if len(sys.argv) != 2:\n'
- ' raise Exception(sys.argv);\n'
- 'with open(sys.argv[1], \'wb\') as f:\n'
+ 'args = []\n'
+ 'if len(sys.argv) != 3 or sys.argv[1] != \'-f\':\n'
+ ' raise Exception(sys.argv)\n'
+ 'with open(sys.argv[2], \'r\') as argsfile:\n'
+ ' args = json.loads(argsfile.read())\n'
+ 'if len(args) != 1:\n'
+ ' raise Exception(args);\n'
+ 'with open(args[0], \'wb\') as f:\n'
' json.dump({\n'
' \'exit_code\': 0,\n'
' \'had_hard_timeout\': False,\n'
@@ -378,9 +383,13 @@ class TestTaskRunner(TestTaskRunnerBase):
' }, f)\n'
'sys.stdout.write(\'hi\\n\')')
self.mock(
- task_runner, 'get_isolated_cmd',
+ task_runner, 'get_run_isolated',
+ lambda :
+ [sys.executable, '-u', '-c', SCRIPT_ISOLATED])
+ self.mock(
+ task_runner, 'get_isolated_args',
lambda _work_dir, _details, isolated_result, bot_file, min_free_space:
- [sys.executable, '-u', '-c', SCRIPT_ISOLATED, isolated_result])
+ [isolated_result])
expected = {
u'exit_code': 0,
u'hard_timeout': False,
@@ -1088,6 +1097,7 @@ class TaskRunnerSmoke(unittest.TestCase):
self.root_dir = tempfile.mkdtemp(prefix='task_runner')
logging.info('Temp: %s', self.root_dir)
self._server = fake_swarming.Server(self)
+ self.maxDiff = None
M-A Ruel 2016/10/21 20:15:20 Remove, you just have to pass -v on the command li
aludwin 2016/10/21 20:32:00 Yeesh. Would have been nice if someone said that o
def tearDown(self):
try:

Powered by Google App Engine
This is Rietveld 408576698