OLD | NEW |
1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
2 # Copyright 2009, Google Inc. | 2 # Copyright 2009, Google Inc. |
3 # All rights reserved. | 3 # All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 13 matching lines...) Expand all Loading... |
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
31 """Test runtest (hey, recursion!) (MEDIUM TEST).""" | 31 """Test runtest (hey, recursion!) (MEDIUM TEST).""" |
32 | 32 |
33 import TestFramework | 33 import TestFramework |
| 34 import optparse |
34 import os | 35 import os |
| 36 import StringIO |
35 import sys | 37 import sys |
36 | 38 |
37 | 39 |
38 expect_stdout = """usage: runtest.py [options] | 40 expect_stdout = """usage: runtest.py [options] |
39 | 41 |
40 options: | 42 options: |
41 -a, --all Run all tests; does a virtual 'find' for all tests | 43 -a, --all Run all tests; does a virtual 'find' for all tests |
42 under the current directory. | 44 under the current directory. |
43 -d, --debug Runs the script under the Python debugger (pdb.py) so | 45 -d, --debug Runs the script under the Python debugger (pdb.py) so |
44 you don't have to muck with PYTHONPATH yourself. | 46 you don't have to muck with PYTHONPATH yourself. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 # Convert test args to a list, so we can add args with spaces below | 94 # Convert test args to a list, so we can add args with spaces below |
93 runtest = runtest.split() | 95 runtest = runtest.split() |
94 | 96 |
95 test = TestFramework.TestFramework(program=sys.executable) | 97 test = TestFramework.TestFramework(program=sys.executable) |
96 | 98 |
97 base = 'runtest/' | 99 base = 'runtest/' |
98 test.subdir(base) | 100 test.subdir(base) |
99 test.write('dummy_test.py', dummy_test_contents) | 101 test.write('dummy_test.py', dummy_test_contents) |
100 test.write('other.py', other_py_contents) | 102 test.write('other.py', other_py_contents) |
101 | 103 |
102 # On mac, help output is slightly different | 104 # Alter expected result based on optparse version (string case changed). |
103 if sys.platform == 'darwin': | 105 op = optparse.OptionParser() |
| 106 fh = StringIO.StringIO() |
| 107 op.print_help(fh) |
| 108 if 'Usage:' in fh.getvalue(): |
104 global expect_stdout | 109 global expect_stdout |
105 expect_stdout = expect_stdout.replace('usage:', 'Usage:') | 110 expect_stdout = expect_stdout.replace('usage:', 'Usage:') |
106 expect_stdout = expect_stdout.replace('options:', 'Options:') | 111 expect_stdout = expect_stdout.replace('options:', 'Options:') |
107 | 112 |
108 # Check help | 113 # Check help |
109 test.run(arguments=runtest + ['--help'], stdout=expect_stdout) | 114 test.run(arguments=runtest + ['--help'], stdout=expect_stdout) |
110 | 115 |
111 # Check running itself but doing nothing | 116 # Check running itself but doing nothing |
112 test.run(arguments=runtest + ['-n', '-a']) | 117 test.run(arguments=runtest + ['-n', '-a']) |
113 | 118 |
(...skipping 18 matching lines...) Expand all Loading... |
132 test.FakeWindowsPFX(base + 'fake1.pfx') | 137 test.FakeWindowsPFX(base + 'fake1.pfx') |
133 test.must_exist(base + 'fake1.pfx') | 138 test.must_exist(base + 'fake1.pfx') |
134 | 139 |
135 test.pass_test() | 140 test.pass_test() |
136 | 141 |
137 return 0 | 142 return 0 |
138 | 143 |
139 | 144 |
140 if __name__ == '__main__': | 145 if __name__ == '__main__': |
141 main() | 146 main() |
OLD | NEW |