1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 import java.io.PrintStream;
18 
19 // Results collector for VarHandle Unit tests
20 public final class VarHandleUnitTestCollector {
21     private final PrintStream out = System.out;
22 
23     private int numberOfSuccesses;
24     private int numberOfSkips;
25     private int numberOfFailures;
26 
start(String testName)27     public void start(String testName) {
28         out.print(testName);
29         out.print("...");
30     }
31 
skip()32     public void skip() {
33         numberOfSkips += 1;
34         out.println("SKIP");
35     }
36 
success()37     public void success() {
38         numberOfSuccesses += 1;
39         out.println("OK");
40     }
41 
fail(String errorMessage)42     public void fail(String errorMessage) {
43         numberOfFailures += 1;
44         out.println("FAIL");
45         out.print(errorMessage);
46     }
47 
printSummary()48     public void printSummary() {
49         out.append(Integer.toString(numberOfSuccesses))
50                 .append(" successes, ")
51                 .append(Integer.toString(numberOfSkips))
52                 .append(" skips, ")
53                 .append(Integer.toString(numberOfFailures))
54                 .append(" failures.");
55         out.println();
56     }
57 
failuresOccurred()58     boolean failuresOccurred() {
59         return numberOfFailures != 0;
60     }
61 }
62