blob: 4cb899826ae557153af57cd160fcb6400e621956 [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001// Copyright 2014 The Bazel Authors. All rights reserved.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01002//
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.
14package com.google.devtools.build.lib.skyframe;
15
16import com.google.common.base.Function;
17import com.google.common.collect.Iterables;
18import com.google.devtools.build.lib.analysis.ConfiguredTarget;
19import com.google.devtools.build.lib.analysis.LabelAndConfiguration;
20import com.google.devtools.build.skyframe.SkyKey;
21import com.google.devtools.build.skyframe.SkyValue;
22
23import 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 */
29public 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 Ramakrishnanf745e992016-03-03 08:08:50 +000035 return SkyKey.create(SkyFunctions.TEST_COMPLETION, new TestCompletionKey(lac, exclusive));
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010036 }
37
38 public static Iterable<SkyKey> keys(Collection<ConfiguredTarget> targets,
39 final boolean exclusive) {
Janak Ramakrishnanf745e992016-03-03 08:08:50 +000040 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 Nienhuysd08b27f2015-02-25 16:45:20 +010050 }
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}