Jakob Buchgraber | 7a2597d | 2017-03-22 16:33:40 +0000 | [diff] [blame] | 1 | // 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 | |
| 15 | package com.google.devtools.build.lib.runtime; |
| 16 | |
| 17 | import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos; |
| 18 | import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.TestStatus; |
| 19 | import com.google.devtools.build.lib.view.test.TestStatus.BlazeTestStatus; |
| 20 | |
| 21 | /** |
| 22 | * Utility methods for the build event stream. |
| 23 | * |
aehlig | c5ddd42 | 2017-06-27 14:25:54 +0200 | [diff] [blame] | 24 | * <p>TODO(aehlig): remove once {@link BlazeTestStatus} is replaced by {@link TestStatus} from the |
| 25 | * {@link BuildEventStreamProtos}. |
Jakob Buchgraber | 7a2597d | 2017-03-22 16:33:40 +0000 | [diff] [blame] | 26 | */ |
| 27 | public 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: |
aehlig | c6fa317 | 2017-09-01 09:09:53 +0200 | [diff] [blame] | 47 | return BuildEventStreamProtos.TestStatus.TOOL_HALTED_BEFORE_TESTING; |
Jakob Buchgraber | 7a2597d | 2017-03-22 16:33:40 +0000 | [diff] [blame] | 48 | 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 | } |