-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only report repository return values if containing new information
Repository rules have the option to return a new set of arguments that would allow them to reproduce identically (whereas the arguments could request following a branch). Currently, whenever a non-None value is returned, this is reported to the user; change this to only report, if the return value contains new information---and in this case, only return what has changed. While there, also remove the double digesting of the generated directory in case hashes are verified. Change-Id: I8bcff45891c755adac72f24c6d07909ed7eb9f3a PiperOrigin-RevId: 220252511
- Loading branch information
Showing
4 changed files
with
200 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...test/java/com/google/devtools/build/lib/bazel/repository/RepositoryResolvedEventTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2017 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.bazel.repository; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import com.google.devtools.build.lib.util.Pair; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
/** Test for {@link RepositoryOptions}. */ | ||
@RunWith(JUnit4.class) | ||
public class RepositoryResolvedEventTest { | ||
|
||
@Test | ||
public void testCompareReplace() { | ||
Pair<Map<String, Object>, List<String>> result = | ||
RepositoryResolvedEvent.compare( | ||
ImmutableMap.of("foo", "orig"), | ||
ImmutableMap.<String, Object>of(), | ||
ImmutableMap.of("foo", "changed")); | ||
assertThat(result.getFirst()).containsExactly("foo", "changed"); | ||
assertThat(result.getSecond()).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void testCompareDrop() { | ||
Pair<Map<String, Object>, List<String>> result = | ||
RepositoryResolvedEvent.compare( | ||
ImmutableMap.of("foo", "orig"), ImmutableMap.<String, Object>of(), ImmutableMap.of()); | ||
assertThat(result.getFirst()).isEmpty(); | ||
assertThat(result.getSecond()).containsExactly("foo"); | ||
} | ||
|
||
@Test | ||
public void testCompareAdd() { | ||
Pair<Map<String, Object>, List<String>> result = | ||
RepositoryResolvedEvent.compare( | ||
ImmutableMap.<String, Object>of(), | ||
ImmutableMap.<String, Object>of(), | ||
ImmutableMap.of("foo", "new")); | ||
assertThat(result.getFirst()).containsExactly("foo", "new"); | ||
assertThat(result.getSecond()).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void testCompareAddDefault() { | ||
Pair<Map<String, Object>, List<String>> result = | ||
RepositoryResolvedEvent.compare( | ||
ImmutableMap.<String, Object>of(), | ||
ImmutableMap.of("bar", "default", "unreleated", "xyz"), | ||
ImmutableMap.of("foo", "new", "bar", "default")); | ||
assertThat(result.getFirst()).containsExactly("foo", "new"); | ||
assertThat(result.getSecond()).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void testCompareAddDifferentFromDefault() { | ||
Pair<Map<String, Object>, List<String>> result = | ||
RepositoryResolvedEvent.compare( | ||
ImmutableMap.<String, Object>of(), | ||
ImmutableMap.of("bar", "default", "unreleated", "xyz"), | ||
ImmutableMap.of("foo", "new", "bar", "otherValue")); | ||
assertThat(result.getFirst()).containsExactly("foo", "new", "bar", "otherValue"); | ||
assertThat(result.getSecond()).isEmpty(); | ||
} | ||
} |