comparison truffle/com.oracle.truffle.tck/src/com/oracle/truffle/tck/TruffleTextListener.java @ 21951:9c8c0937da41

Moving all sources into truffle subdirectory
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 17 Jun 2015 10:58:08 +0200
parents graal/com.oracle.truffle.tck/src/com/oracle/truffle/tck/TruffleTextListener.java@0a6e10379b9b
children dc83cc1f94f2
comparison
equal deleted inserted replaced
21950:2a5011c7e641 21951:9c8c0937da41
1 /*
2 * Copyright (c) 2015, 2015, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.oracle.truffle.tck;
26
27 import java.io.*;
28
29 import org.junit.internal.*;
30 import org.junit.runner.*;
31 import org.junit.runner.notification.*;
32
33 class TruffleTextListener implements TruffleJUnitRunListener {
34
35 private final PrintStream fWriter;
36 protected Failure lastFailure;
37
38 public TruffleTextListener(JUnitSystem system) {
39 this(system.out());
40 }
41
42 public TruffleTextListener(PrintStream writer) {
43 fWriter = writer;
44 }
45
46 @Override
47 public PrintStream getWriter() {
48 return fWriter;
49 }
50
51 public Failure getLastFailure() {
52 return lastFailure;
53 }
54
55 @Override
56 public void testRunStarted(Description description) {
57 }
58
59 @Override
60 public void testRunFinished(Result result) {
61 }
62
63 @Override
64 public void testAssumptionFailure(Failure failure) {
65 }
66
67 @Override
68 public void testClassStarted(Class<?> clazz) {
69 }
70
71 @Override
72 public void testClassFinished(Class<?> clazz) {
73 }
74
75 @Override
76 public void testStarted(Description description) {
77 getWriter().print('.');
78 }
79
80 @Override
81 public void testFinished(Description description) {
82 }
83
84 @Override
85 public void testFailed(Failure failure) {
86 getWriter().print('E');
87 lastFailure = failure;
88 }
89
90 @Override
91 public void testSucceeded(Description description) {
92 }
93
94 @Override
95 public void testIgnored(Description description) {
96 getWriter().print('I');
97 }
98
99 @Override
100 public void testClassFinishedDelimiter() {
101 }
102
103 @Override
104 public void testClassStartedDelimiter() {
105 }
106
107 @Override
108 public void testStartedDelimiter() {
109 }
110
111 @Override
112 public void testFinishedDelimiter() {
113 }
114
115 public static RunListener createRunListener(final TruffleJUnitRunListener l) {
116 return new TextListener(l.getWriter()) {
117 private Class<?> lastClass;
118 private boolean failed;
119
120 @Override
121 public final void testStarted(Description description) {
122 Class<?> currentClass = description.getTestClass();
123 if (currentClass != lastClass) {
124 if (lastClass != null) {
125 l.testClassFinished(lastClass);
126 l.testClassFinishedDelimiter();
127 }
128 lastClass = currentClass;
129 l.testClassStarted(currentClass);
130 l.testClassStartedDelimiter();
131 }
132 failed = false;
133 l.testStarted(description);
134 l.testStartedDelimiter();
135 }
136
137 @Override
138 public final void testFailure(Failure failure) {
139 failed = true;
140 l.testFailed(failure);
141 }
142
143 @Override
144 public final void testFinished(Description description) {
145 // we have to do this because there is no callback for successful tests
146 if (!failed) {
147 l.testSucceeded(description);
148 }
149 l.testFinished(description);
150 l.testFinishedDelimiter();
151 }
152
153 @Override
154 public void testIgnored(Description description) {
155 l.testStarted(description);
156 l.testStartedDelimiter();
157 l.testIgnored(description);
158 l.testFinished(description);
159 l.testFinishedDelimiter();
160 }
161
162 @Override
163 public void testRunStarted(Description description) {
164 l.testRunStarted(description);
165 }
166
167 @Override
168 public void testRunFinished(Result result) {
169 if (lastClass != null) {
170 l.testClassFinished(lastClass);
171 }
172 l.testRunFinished(result);
173 super.testRunFinished(result);
174 }
175
176 @Override
177 public void testAssumptionFailure(Failure failure) {
178 l.testAssumptionFailure(failure);
179 }
180
181 };
182 }
183
184 }