Damien Martin-Guillerez | f88f4d8 | 2015-09-25 13:56:55 +0000 | [diff] [blame] | 1 | // Copyright 2014 The Bazel Authors. All rights reserved. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 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 | package com.google.devtools.build.lib.skyframe; |
| 15 | |
| 16 | import com.google.common.base.Function; |
| 17 | import com.google.common.collect.Iterables; |
| 18 | import com.google.devtools.build.lib.analysis.ConfiguredTarget; |
| 19 | import com.google.devtools.build.lib.analysis.LabelAndConfiguration; |
| 20 | import com.google.devtools.build.skyframe.SkyKey; |
| 21 | import com.google.devtools.build.skyframe.SkyValue; |
| 22 | |
| 23 | import java.util.Collection; |
| 24 | |
| 25 | /** |
| 26 | * A test completion value represents the completion of a test target. This includes the execution |
| 27 | * of all test shards and repeated runs, if applicable. |
| 28 | */ |
| 29 | public class TestCompletionValue implements SkyValue { |
| 30 | static final TestCompletionValue TEST_COMPLETION_MARKER = new TestCompletionValue(); |
| 31 | |
| 32 | private TestCompletionValue() { } |
| 33 | |
| 34 | public static SkyKey key(LabelAndConfiguration lac, boolean exclusive) { |
Janak Ramakrishnan | f745e99 | 2016-03-03 08:08:50 +0000 | [diff] [blame^] | 35 | return SkyKey.create(SkyFunctions.TEST_COMPLETION, new TestCompletionKey(lac, exclusive)); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | public static Iterable<SkyKey> keys(Collection<ConfiguredTarget> targets, |
| 39 | final boolean exclusive) { |
Janak Ramakrishnan | f745e99 | 2016-03-03 08:08:50 +0000 | [diff] [blame^] | 40 | return Iterables.transform( |
| 41 | targets, |
| 42 | new Function<ConfiguredTarget, SkyKey>() { |
| 43 | @Override |
| 44 | public SkyKey apply(ConfiguredTarget ct) { |
| 45 | return SkyKey.create( |
| 46 | SkyFunctions.TEST_COMPLETION, |
| 47 | new TestCompletionKey(new LabelAndConfiguration(ct), exclusive)); |
| 48 | } |
| 49 | }); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | static class TestCompletionKey { |
| 53 | private final LabelAndConfiguration lac; |
| 54 | private final boolean exclusiveTesting; |
| 55 | |
| 56 | TestCompletionKey(LabelAndConfiguration lac, boolean exclusive) { |
| 57 | this.lac = lac; |
| 58 | this.exclusiveTesting = exclusive; |
| 59 | } |
| 60 | |
| 61 | public LabelAndConfiguration getLabelAndConfiguration() { |
| 62 | return lac; |
| 63 | } |
| 64 | |
| 65 | public boolean isExclusiveTesting() { |
| 66 | return exclusiveTesting; |
| 67 | } |
| 68 | } |
| 69 | } |