Fixing gtest_parallel_wrapper_test on Windows.
Using tempfile is probably overkill in this case, but it is good to have a meaningful path printed out in case of error (instead of something like "/tmp" and then a Windows path). Bug: None Change-Id: I90b939d7b2a082f4c04f995b602942efe1e671bc Reviewed-on: https://webrtc-review.googlesource.com/81180 Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23516}
This commit is contained in:
parent
3ea3e300dc
commit
dac422f5d3
@ -8,11 +8,22 @@
|
|||||||
# in the file PATENTS. All contributing project authors may
|
# in the file PATENTS. All contributing project authors may
|
||||||
# be found in the AUTHORS file in the root of the source tree.
|
# be found in the AUTHORS file in the root of the source tree.
|
||||||
|
|
||||||
|
from contextlib import contextmanager
|
||||||
|
|
||||||
|
import os
|
||||||
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
script = __import__('gtest-parallel-wrapper') # pylint: disable=invalid-name
|
script = __import__('gtest-parallel-wrapper') # pylint: disable=invalid-name
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def TemporaryDirectory():
|
||||||
|
tmp_dir = tempfile.mkdtemp()
|
||||||
|
yield tmp_dir
|
||||||
|
os.rmdir(tmp_dir)
|
||||||
|
|
||||||
|
|
||||||
class GtestParallelWrapperTest(unittest.TestCase):
|
class GtestParallelWrapperTest(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _Expected(cls, gtest_parallel_args):
|
def _Expected(cls, gtest_parallel_args):
|
||||||
@ -50,14 +61,17 @@ class GtestParallelWrapperTest(unittest.TestCase):
|
|||||||
self.assertEqual(result.gtest_parallel_args, expected)
|
self.assertEqual(result.gtest_parallel_args, expected)
|
||||||
|
|
||||||
def testArtifacts(self):
|
def testArtifacts(self):
|
||||||
result = script.ParseArgs(['exec', '--store-test-artifacts',
|
with TemporaryDirectory() as tmp_dir:
|
||||||
'--output_dir', '/tmp/foo'])
|
output_dir = os.path.join(tmp_dir, 'foo')
|
||||||
expected = self._Expected(['--output_dir=/tmp/foo', 'exec', '--',
|
result = script.ParseArgs(['exec', '--store-test-artifacts',
|
||||||
'--test_artifacts_dir=/tmp/foo/test_artifacts'])
|
'--output_dir', output_dir])
|
||||||
self.assertEqual(result.gtest_parallel_args, expected)
|
exp_artifacts_dir = os.path.join(output_dir, 'test_artifacts')
|
||||||
self.assertEqual(result.output_dir, '/tmp/foo')
|
exp = self._Expected(['--output_dir=' + output_dir, 'exec', '--',
|
||||||
self.assertRegexpMatches(result.test_artifacts_dir,
|
'--test_artifacts_dir=' + exp_artifacts_dir])
|
||||||
'/tmp/foo.test_artifacts')
|
self.assertEqual(result.gtest_parallel_args, exp)
|
||||||
|
self.assertEqual(result.output_dir, output_dir)
|
||||||
|
self.assertRegexpMatches(result.test_artifacts_dir,
|
||||||
|
output_dir + '.test_artifacts')
|
||||||
|
|
||||||
def testNoDirsSpecified(self):
|
def testNoDirsSpecified(self):
|
||||||
result = script.ParseArgs(['exec'])
|
result = script.ParseArgs(['exec'])
|
||||||
@ -92,20 +106,23 @@ class GtestParallelWrapperTest(unittest.TestCase):
|
|||||||
self.assertEqual(result.gtest_parallel_args, expected)
|
self.assertEqual(result.gtest_parallel_args, expected)
|
||||||
|
|
||||||
def testDocExample(self):
|
def testDocExample(self):
|
||||||
result = script.ParseArgs([
|
with TemporaryDirectory() as tmp_dir:
|
||||||
'some_test', '--some_flag=some_value', '--another_flag',
|
output_dir = os.path.join(tmp_dir, 'foo')
|
||||||
'--output_dir=SOME_OUTPUT_DIR', '--store-test-artifacts',
|
result = script.ParseArgs([
|
||||||
'--isolated-script-test-output=SOME_DIR',
|
'some_test', '--some_flag=some_value', '--another_flag',
|
||||||
'--isolated-script-test-perf-output=SOME_OTHER_DIR',
|
'--output_dir=' + output_dir, '--store-test-artifacts',
|
||||||
'--foo=bar', '--baz'])
|
'--isolated-script-test-output=SOME_DIR',
|
||||||
expected = self._Expected([
|
'--isolated-script-test-perf-output=SOME_OTHER_DIR',
|
||||||
'--output_dir=SOME_OUTPUT_DIR', '--dump_json_test_results=SOME_DIR',
|
'--foo=bar', '--baz'])
|
||||||
'some_test', '--',
|
expected_artifacts_dir = os.path.join(output_dir, 'test_artifacts')
|
||||||
'--test_artifacts_dir=SOME_OUTPUT_DIR/test_artifacts',
|
expected = self._Expected([
|
||||||
'--some_flag=some_value', '--another_flag',
|
'--output_dir=' + output_dir, '--dump_json_test_results=SOME_DIR',
|
||||||
'--isolated-script-test-perf-output=SOME_OTHER_DIR',
|
'some_test', '--',
|
||||||
'--foo=bar', '--baz'])
|
'--test_artifacts_dir=' + expected_artifacts_dir,
|
||||||
self.assertEqual(result.gtest_parallel_args, expected)
|
'--some_flag=some_value', '--another_flag',
|
||||||
|
'--isolated-script-test-perf-output=SOME_OTHER_DIR',
|
||||||
|
'--foo=bar', '--baz'])
|
||||||
|
self.assertEqual(result.gtest_parallel_args, expected)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user