blob: fc0f161e5a145ce3ee2925c19653f393392b952c [file] [log] [blame]
Jakob Buchgraber7a2597d2017-03-22 16:33:40 +00001// Copyright 2017 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package com.google.devtools.build.lib.runtime;
16
17import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos;
18import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.TestStatus;
19import com.google.devtools.build.lib.view.test.TestStatus.BlazeTestStatus;
20
21/**
22 * Utility methods for the build event stream.
23 *
aehligc5ddd422017-06-27 14:25:54 +020024 * <p>TODO(aehlig): remove once {@link BlazeTestStatus} is replaced by {@link TestStatus} from the
25 * {@link BuildEventStreamProtos}.
Jakob Buchgraber7a2597d2017-03-22 16:33:40 +000026 */
27public final class BuildEventStreamerUtils {
28
29 /** Map BlazeTestStatus to TestStatus. */
30 public static TestStatus bepStatus(BlazeTestStatus status) {
31 switch (status) {
32 case NO_STATUS:
33 return BuildEventStreamProtos.TestStatus.NO_STATUS;
34 case PASSED:
35 return BuildEventStreamProtos.TestStatus.PASSED;
36 case FLAKY:
37 return BuildEventStreamProtos.TestStatus.FLAKY;
38 case FAILED:
39 return BuildEventStreamProtos.TestStatus.FAILED;
40 case TIMEOUT:
41 return BuildEventStreamProtos.TestStatus.TIMEOUT;
42 case INCOMPLETE:
43 return BuildEventStreamProtos.TestStatus.INCOMPLETE;
44 case REMOTE_FAILURE:
45 return BuildEventStreamProtos.TestStatus.REMOTE_FAILURE;
46 case BLAZE_HALTED_BEFORE_TESTING:
aehligc6fa3172017-09-01 09:09:53 +020047 return BuildEventStreamProtos.TestStatus.TOOL_HALTED_BEFORE_TESTING;
Jakob Buchgraber7a2597d2017-03-22 16:33:40 +000048 default:
49 // Not used as the above is a complete case distinction; however, by the open
50 // nature of protobuf enums, we need the clause to convice java, that we always
51 // have a return statement.
52 return BuildEventStreamProtos.TestStatus.NO_STATUS;
53 }
54 }
55}