Mercurial > hg > truffle
annotate graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTextListener.java @ 21194:5557f74bfd30
MoveResolver: improve assertion.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 22 Apr 2015 14:17:11 +0200 |
parents | 840257b6cdc5 |
children |
rev | line source |
---|---|
15500 | 1 /* |
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.graal.test; | |
24 | |
25 import java.io.*; | |
26 | |
27 import org.junit.internal.*; | |
28 import org.junit.runner.*; | |
29 import org.junit.runner.notification.*; | |
30 | |
31 public class GraalTextListener implements GraalJUnitRunListener { | |
32 | |
33 private final PrintStream fWriter; | |
18326
840257b6cdc5
mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents:
15500
diff
changeset
|
34 protected Failure lastFailure; |
15500 | 35 |
36 public GraalTextListener(JUnitSystem system) { | |
37 this(system.out()); | |
38 } | |
39 | |
40 public GraalTextListener(PrintStream writer) { | |
41 fWriter = writer; | |
42 } | |
43 | |
44 @Override | |
45 public PrintStream getWriter() { | |
46 return fWriter; | |
47 } | |
48 | |
18326
840257b6cdc5
mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents:
15500
diff
changeset
|
49 public Failure getLastFailure() { |
840257b6cdc5
mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents:
15500
diff
changeset
|
50 return lastFailure; |
840257b6cdc5
mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents:
15500
diff
changeset
|
51 } |
840257b6cdc5
mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents:
15500
diff
changeset
|
52 |
15500 | 53 @Override |
54 public void testRunStarted(Description description) { | |
55 } | |
56 | |
57 @Override | |
58 public void testRunFinished(Result result) { | |
59 } | |
60 | |
61 @Override | |
62 public void testAssumptionFailure(Failure failure) { | |
63 } | |
64 | |
65 @Override | |
66 public void testClassStarted(Class<?> clazz) { | |
67 } | |
68 | |
69 @Override | |
70 public void testClassFinished(Class<?> clazz) { | |
71 } | |
72 | |
73 @Override | |
74 public void testStarted(Description description) { | |
75 getWriter().print('.'); | |
76 } | |
77 | |
78 @Override | |
79 public void testFinished(Description description) { | |
80 } | |
81 | |
82 @Override | |
83 public void testFailed(Failure failure) { | |
84 getWriter().print('E'); | |
18326
840257b6cdc5
mx: added --fail-fast option to unittest that stops Junit after first input class causing a test failure
Doug Simon <doug.simon@oracle.com>
parents:
15500
diff
changeset
|
85 lastFailure = failure; |
15500 | 86 } |
87 | |
88 @Override | |
89 public void testSucceeded(Description description) { | |
90 } | |
91 | |
92 @Override | |
93 public void testIgnored(Description description) { | |
94 getWriter().print('I'); | |
95 } | |
96 | |
97 @Override | |
98 public void testClassFinishedDelimiter() { | |
99 } | |
100 | |
101 @Override | |
102 public void testClassStartedDelimiter() { | |
103 } | |
104 | |
105 @Override | |
106 public void testStartedDelimiter() { | |
107 } | |
108 | |
109 @Override | |
110 public void testFinishedDelimiter() { | |
111 } | |
112 | |
113 public static RunListener createRunListener(GraalJUnitRunListener l) { | |
114 return new TextListener(l.getWriter()) { | |
115 private Class<?> lastClass; | |
116 private boolean failed; | |
117 | |
118 @Override | |
119 public final void testStarted(Description description) { | |
120 Class<?> currentClass = description.getTestClass(); | |
121 if (currentClass != lastClass) { | |
122 if (lastClass != null) { | |
123 l.testClassFinished(lastClass); | |
124 l.testClassFinishedDelimiter(); | |
125 } | |
126 lastClass = currentClass; | |
127 l.testClassStarted(currentClass); | |
128 l.testClassStartedDelimiter(); | |
129 } | |
130 failed = false; | |
131 l.testStarted(description); | |
132 l.testStartedDelimiter(); | |
133 } | |
134 | |
135 @Override | |
136 public final void testFailure(Failure failure) { | |
137 failed = true; | |
138 l.testFailed(failure); | |
139 } | |
140 | |
141 @Override | |
142 public final void testFinished(Description description) { | |
143 // we have to do this because there is no callback for successful tests | |
144 if (!failed) { | |
145 l.testSucceeded(description); | |
146 } | |
147 l.testFinished(description); | |
148 l.testFinishedDelimiter(); | |
149 } | |
150 | |
151 @Override | |
152 public void testIgnored(Description description) { | |
153 l.testStarted(description); | |
154 l.testStartedDelimiter(); | |
155 l.testIgnored(description); | |
156 l.testFinished(description); | |
157 l.testFinishedDelimiter(); | |
158 } | |
159 | |
160 @Override | |
161 public void testRunStarted(Description description) { | |
162 l.testRunStarted(description); | |
163 } | |
164 | |
165 @Override | |
166 public void testRunFinished(Result result) { | |
167 if (lastClass != null) { | |
168 l.testClassFinished(lastClass); | |
169 } | |
170 l.testRunFinished(result); | |
171 super.testRunFinished(result); | |
172 } | |
173 | |
174 @Override | |
175 public void testAssumptionFailure(Failure failure) { | |
176 l.testAssumptionFailure(failure); | |
177 } | |
178 | |
179 }; | |
180 } | |
181 | |
182 } |