Mercurial > hg > truffle
comparison test/testlibrary/OutputAnalyzerTest.java @ 9077:480d934f62a8
Merge
author | mgerdin |
---|---|
date | Thu, 11 Apr 2013 16:35:34 +0200 |
parents | 3b890cd4da64 |
children | 9e11762cee52 |
comparison
equal
deleted
inserted
replaced
9076:7b835924c31c | 9077:480d934f62a8 |
---|---|
33 | 33 |
34 public static void main(String args[]) throws Exception { | 34 public static void main(String args[]) throws Exception { |
35 | 35 |
36 String stdout = "aaaaaa"; | 36 String stdout = "aaaaaa"; |
37 String stderr = "bbbbbb"; | 37 String stderr = "bbbbbb"; |
38 | |
39 // Regexps used for testing pattern matching of the test input | |
40 String stdoutPattern = "[a]"; | |
41 String stderrPattern = "[b]"; | |
42 String nonExistingPattern = "[c]"; | |
38 | 43 |
39 OutputAnalyzer output = new OutputAnalyzer(stdout, stderr); | 44 OutputAnalyzer output = new OutputAnalyzer(stdout, stderr); |
40 | 45 |
41 if (!stdout.equals(output.getStdout())) { | 46 if (!stdout.equals(output.getStdout())) { |
42 throw new Exception("getStdout() returned '" + output.getStdout() + "', expected '" + stdout + "'"); | 47 throw new Exception("getStdout() returned '" + output.getStdout() + "', expected '" + stdout + "'"); |
97 } catch (RuntimeException e) { | 102 } catch (RuntimeException e) { |
98 // expected | 103 // expected |
99 } | 104 } |
100 | 105 |
101 try { | 106 try { |
102 output.stderrShouldNotContain(stderr); | 107 output.stderrShouldNotContain(stderr); |
103 throw new Exception("shouldContain() failed to throw exception"); | 108 throw new Exception("shouldContain() failed to throw exception"); |
104 } catch (RuntimeException e) { | 109 } catch (RuntimeException e) { |
105 // expected | 110 // expected |
111 } | |
112 | |
113 // Should match | |
114 try { | |
115 output.shouldMatch(stdoutPattern); | |
116 output.stdoutShouldMatch(stdoutPattern); | |
117 output.shouldMatch(stderrPattern); | |
118 output.stderrShouldMatch(stderrPattern); | |
119 } catch (RuntimeException e) { | |
120 throw new Exception("shouldMatch() failed", e); | |
121 } | |
122 | |
123 try { | |
124 output.shouldMatch(nonExistingPattern); | |
125 throw new Exception("shouldMatch() failed to throw exception"); | |
126 } catch (RuntimeException e) { | |
127 // expected | |
128 } | |
129 | |
130 try { | |
131 output.stdoutShouldMatch(stderrPattern); | |
132 throw new Exception( | |
133 "stdoutShouldMatch() failed to throw exception"); | |
134 } catch (RuntimeException e) { | |
135 // expected | |
136 } | |
137 | |
138 try { | |
139 output.stderrShouldMatch(stdoutPattern); | |
140 throw new Exception( | |
141 "stderrShouldMatch() failed to throw exception"); | |
142 } catch (RuntimeException e) { | |
143 // expected | |
144 } | |
145 | |
146 // Should not match | |
147 try { | |
148 output.shouldNotMatch(nonExistingPattern); | |
149 output.stdoutShouldNotMatch(nonExistingPattern); | |
150 output.stderrShouldNotMatch(nonExistingPattern); | |
151 } catch (RuntimeException e) { | |
152 throw new Exception("shouldNotMatch() failed", e); | |
153 } | |
154 | |
155 try { | |
156 output.shouldNotMatch(stdoutPattern); | |
157 throw new Exception("shouldNotMatch() failed to throw exception"); | |
158 } catch (RuntimeException e) { | |
159 // expected | |
160 } | |
161 | |
162 try { | |
163 output.stdoutShouldNotMatch(stdoutPattern); | |
164 throw new Exception("shouldNotMatch() failed to throw exception"); | |
165 } catch (RuntimeException e) { | |
166 // expected | |
167 } | |
168 | |
169 try { | |
170 output.stderrShouldNotMatch(stderrPattern); | |
171 throw new Exception("shouldNotMatch() failed to throw exception"); | |
172 } catch (RuntimeException e) { | |
173 // expected | |
106 } | 174 } |
107 } | 175 } |
108 } | 176 } |