aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2017-01-17 18:49:59 +0000
committerGravatar Vladimir Moskva <vladmos@google.com>2017-01-17 19:12:47 +0000
commit296338723359df956cbc6c284faba200642a7b5d (patch)
treec47f8359b4b4f119fcc36efbfb1bc078db84b330 /src/test/java/com/google/devtools/build
parent29263e2cfe0af56c1d0f987b6d3a619267f84bbf (diff)
Remote repositories: add the infrastructure for extending the marker file
This add a markerData map to the RepositoryFunction#fetch function so RepositoryFunction-s can declare extraneous data to add to the marker file. The RepositoryFunction#verifyMarkerData is called to verify those data in order to know if the repository is up to date and need re-fetching. Design doc: https://bazel.build/designs/2016/10/18/repository-invalidation.html [step 2] -- Change-Id: I9083fb72a0142f418a7296f889cd3eaf32e92498 Reviewed-on: https://cr.bazel.build/7973 PiperOrigin-RevId: 144728497 MOS_MIGRATED_REVID=144728497
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryFunctionTest.java30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryFunctionTest.java b/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryFunctionTest.java
index 3cc0a84d24..177f2db017 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryFunctionTest.java
@@ -28,13 +28,12 @@ import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunctionException;
import com.google.devtools.build.skyframe.SkyValue;
-
+import java.util.Map;
+import javax.annotation.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import javax.annotation.Nullable;
-
/**
* Tests for @{link RepositoryFunction}
*/
@@ -48,9 +47,9 @@ public class RepositoryFunctionTest extends BuildViewTestCase {
static class TestingRepositoryFunction extends RepositoryFunction {
@Nullable
@Override
- public SkyValue fetch(
- Rule rule, Path outputDirectory, BlazeDirectories directories, SkyFunction.Environment env)
- throws SkyFunctionException, InterruptedException {
+ public SkyValue fetch(Rule rule, Path outputDirectory, BlazeDirectories directories,
+ SkyFunction.Environment env, Map<String, String> markerData)
+ throws SkyFunctionException, InterruptedException {
return null;
}
@@ -96,4 +95,23 @@ public class RepositoryFunctionTest extends BuildViewTestCase {
FileSystemUtils.readContentAsLatin1(rootDirectory.getRelative("WORKSPACE")));
assertThat(workspaceContent).contains("workspace(name = \"abc\")");
}
+
+ private static void assertMarkerFileEscaping(String testCase) {
+ String escaped = RepositoryDelegatorFunction.escape(testCase);
+ assertThat(RepositoryDelegatorFunction.unescape(escaped)).isEqualTo(testCase);
+ }
+
+ @Test
+ public void testMarkerFileEscaping() throws Exception {
+ assertMarkerFileEscaping(null);
+ assertMarkerFileEscaping("\\0");
+ assertMarkerFileEscaping("a\\0");
+ assertMarkerFileEscaping("a b");
+ assertMarkerFileEscaping("a b c");
+ assertMarkerFileEscaping("a \\b");
+ assertMarkerFileEscaping("a \\nb");
+ assertMarkerFileEscaping("a \\\\nb");
+ assertMarkerFileEscaping("a \\\nb");
+ assertMarkerFileEscaping("a \nb");
+ }
}