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

Unified Diff: client/tests/run_isolated_test.py

Issue 1932143003: run_isolated: support non-isolated commands (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@run-isolated-download-stats
Patch Set: 80cols Created 4 years, 8 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 | « client/swarming.py ('k') | client/tools/parallel_execution.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/run_isolated_test.py
diff --git a/client/tests/run_isolated_test.py b/client/tests/run_isolated_test.py
index ca3de92639b8cf981f6ed31ef4f272280f59e4a0..1b19861da185443bc8f3fd7372712d71116a1230 100755
--- a/client/tests/run_isolated_test.py
+++ b/client/tests/run_isolated_test.py
@@ -176,7 +176,8 @@ class RunIsolatedTest(RunIsolatedTestBase):
],
self.popen_calls)
- def _run_tha_test(self, isolated_hash, files):
+ def _run_tha_test(self, isolated_hash=None, files=None, command=None):
+ files = files or {}
make_tree_call = []
def add(i, _):
make_tree_call.append(i)
@@ -185,6 +186,7 @@ class RunIsolatedTest(RunIsolatedTestBase):
self.mock(file_path, i, functools.partial(add, i))
ret = run_isolated.run_tha_test(
+ command,
isolated_hash,
StorageFake(files),
isolateserver.MemoryCache(),
@@ -193,7 +195,7 @@ class RunIsolatedTest(RunIsolatedTestBase):
None,
None,
None,
- [])
+ None)
self.assertEqual(0, ret)
return make_tree_call
@@ -273,7 +275,14 @@ class RunIsolatedTest(RunIsolatedTestBase):
[([self.temp_join(u'invalid'), u'command'], {'detached': True})],
self.popen_calls)
+ def mock_popen_with_oserr(self):
+ def r(self, args, **kwargs):
+ old_init(self, args, **kwargs)
+ raise OSError('Unknown')
+ old_init = self.mock(subprocess42.Popen, '__init__', r)
+
def test_main_naked(self):
+ self.mock_popen_with_oserr()
self.mock(on_error, 'report', lambda _: None)
# The most naked .isolated file that can exist.
self.mock(tools, 'disable_buffering', lambda: None)
@@ -283,11 +292,6 @@ class RunIsolatedTest(RunIsolatedTestBase):
return StorageFake({isolated_hash:isolated})
self.mock(isolateserver, 'get_storage', get_storage)
- def r(self, args, **kwargs):
- old_init(self, args, **kwargs)
- raise OSError('Unknown')
- old_init = self.mock(subprocess42.Popen, '__init__', r)
-
cmd = [
'--no-log',
'--isolated', isolated_hash,
@@ -301,6 +305,21 @@ class RunIsolatedTest(RunIsolatedTestBase):
[([self.temp_join(u'invalid'), u'command'], {'detached': True})],
self.popen_calls)
+ def test_main_naked_without_isolated(self):
+ self.mock_popen_with_oserr()
+ cmd = [
+ '--no-log',
+ '/bin/echo',
+ 'hello',
+ 'world',
+ ]
+ ret = run_isolated.main(cmd)
+ self.assertEqual(1, ret)
+ self.assertEqual(1, len(self.popen_calls))
+ self.assertEqual(
+ [([u'/bin/echo', u'hello', u'world'], {'detached': True})],
+ self.popen_calls)
+
def test_modified_cwd(self):
isolated = json_dumps({
'command': ['../out/some.exe', 'arg'],
@@ -331,6 +350,12 @@ class RunIsolatedTest(RunIsolatedTestBase):
],
self.popen_calls)
+ def test_run_tha_test_non_isolated(self):
+ _ = self._run_tha_test(command=['/bin/echo', 'hello', 'world'])
+ self.assertEqual(
+ [([u'/bin/echo', u'hello', u'world'], {'detached': True})],
+ self.popen_calls)
+
class RunIsolatedTestRun(RunIsolatedTestBase):
def test_output(self):
@@ -364,6 +389,7 @@ class RunIsolatedTestRun(RunIsolatedTestBase):
self.mock(sys, 'stdout', StringIO.StringIO())
ret = run_isolated.run_tha_test(
+ None,
isolated_hash,
store,
isolateserver.MemoryCache(),
« no previous file with comments | « client/swarming.py ('k') | client/tools/parallel_execution.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698