Chromium Code Reviews| Index: tools-webrtc/check_package_boundaries_test.py |
| diff --git a/tools-webrtc/check_package_boundaries_test.py b/tools-webrtc/check_package_boundaries_test.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..47a6ae6123d1118e55c0a5983abc3d2f529989bf |
| --- /dev/null |
| +++ b/tools-webrtc/check_package_boundaries_test.py |
| @@ -0,0 +1,48 @@ |
| +#!/usr/bin/env python |
| + |
| +# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| +# |
| +# Use of this source code is governed by a BSD-style license |
| +# that can be found in the LICENSE file in the root of the source |
| +# tree. An additional intellectual property rights grant can be found |
| +# in the file PATENTS. All contributing project authors may |
| +# be found in the AUTHORS file in the root of the source tree. |
| + |
| +import os |
| +import subprocess |
| +import unittest |
| + |
| + |
| +MSG_FORMAT = 'ERROR:check_package_boundaries.py: Unexpected %s.' |
| + |
| + |
| +def _RunCommand(command, cwd): |
| + """Runs a command and returns the output from that command.""" |
| + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
| + cwd=cwd) |
| + stdout = p.stdout.read() |
| + stderr = p.stderr.read() |
| + p.wait() |
| + p.stdout.close() |
| + p.stderr.close() |
| + return p.returncode, stdout, stderr |
| + |
| + |
| +class UnitTest(unittest.TestCase): |
| + def test_check_package_boundaries(self): |
| + os.chdir(os.path.dirname(os.path.abspath(__file__))) |
|
kjellander_webrtc
2017/01/24 09:33:19
It's generally bad practice to use os.chdir in scr
|
| + with open(os.path.join('testdata', 'expected_stderr')) as f: |
| + expected_stderr = f.read() |
| + with open(os.path.join('testdata', 'expected_stdout')) as f: |
| + expected_stdout = f.read() |
| + |
| + test_command = ['python', 'check_package_boundaries.py', 'testdata'] |
|
kjellander_webrtc
2017/01/24 09:33:19
Please refactor the check_package_boundaries modul
|
| + return_code, stdout, stderr = _RunCommand(test_command, cwd=os.getcwd()) |
| + |
| + self.assertEqual(return_code, 1) |
| + self.assertMultiLineEqual(expected_stdout, stdout) |
| + self.assertMultiLineEqual(expected_stderr, stderr) |
| + |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |