diff options
author | 2018-06-08 14:58:34 -0700 | |
---|---|---|
committer | 2018-06-08 15:00:11 -0700 | |
commit | 39780843f241da1b57fed2396f0b908d1a2cd5f4 (patch) | |
tree | cc23fcf1434a09d3934c619abfd609ca611879f7 /src/test/shell | |
parent | 8a45d082ae0e0be04f56fef82e354c8c70840d5c (diff) |
maven_jar: Actually add support for sources classifier
Closes: #308, #4798.
7a7c41d7d342cd427e74f091b55690eed13e280d was incomplete addition of
sources classifier. API wasn't extended to support source SHA1. This
has two implications:
1. Sources sha1 artifact cannot be checked once downloaded.
2. Repository cache integration: when enabled, the source artifact
cannot be retrieved from the cache, because its sha1 is not known.
Rectify the problem by adding src_sha1 attribute to native maven_jar
rule.
Test Plan:
$ bazel test src/test/shell/bazel:bazel_repository_cache_test
PiperOrigin-RevId: 198561462
Change-Id: I9c620cdc3876673195483f9e75bb58108acc87be
PiperOrigin-RevId: 199855818
Diffstat (limited to 'src/test/shell')
-rwxr-xr-x | src/test/shell/bazel/bazel_repository_cache_test.sh | 7 | ||||
-rwxr-xr-x | src/test/shell/bazel/maven_test.sh | 19 | ||||
-rwxr-xr-x | src/test/shell/bazel/remote_helpers.sh | 1 |
3 files changed, 26 insertions, 1 deletions
diff --git a/src/test/shell/bazel/bazel_repository_cache_test.sh b/src/test/shell/bazel/bazel_repository_cache_test.sh index b453a84dc1..0ff0fc3bca 100755 --- a/src/test/shell/bazel/bazel_repository_cache_test.sh +++ b/src/test/shell/bazel/bazel_repository_cache_test.sh @@ -105,6 +105,7 @@ maven_jar( artifact = "com.example.carnivore:carnivore:1.23", repository = 'http://localhost:$fileserver_port/', sha1 = '$sha1', + sha1_src = '$sha1_src', ) bind(name = 'mongoose', actual = '@endangered//jar') EOF @@ -497,7 +498,11 @@ function test_maven_jar_exists_in_cache() { || echo "Expected fetch to succeed" if [ ! -f $repo_cache_dir/content_addressable/sha1/$sha1/file ]; then - fail "the file was not cached successfully" + fail "the jar file was not cached successfully" + fi + + if [ ! -f $repo_cache_dir/content_addressable/sha1/$sha1_src/file ]; then + fail "the sources file was not cached successfully" fi } diff --git a/src/test/shell/bazel/maven_test.sh b/src/test/shell/bazel/maven_test.sh index 7a14c20bd6..299a3ee20d 100755 --- a/src/test/shell/bazel/maven_test.sh +++ b/src/test/shell/bazel/maven_test.sh @@ -62,6 +62,25 @@ maven_jar( artifact = "com.example.carnivore:carnivore:1.23", repository = 'http://127.0.0.1:$fileserver_port/', sha1 = '$sha1', + sha1_src = '$sha1_src', +) +bind(name = 'mongoose', actual = '@endangered//jar') +EOF + + bazel run //zoo:ball-pit >& $TEST_log || fail "Expected run to succeed" + expect_log "Tra-la!" +} + +function test_maven_jar_no_sha1_src() { + setup_zoo + serve_artifact com.example.carnivore carnivore 1.23 + + cat > WORKSPACE <<EOF +maven_jar( + name = 'endangered', + artifact = "com.example.carnivore:carnivore:1.23", + repository = 'http://127.0.0.1:$fileserver_port/', + sha1 = '$sha1', ) bind(name = 'mongoose', actual = '@endangered//jar') EOF diff --git a/src/test/shell/bazel/remote_helpers.sh b/src/test/shell/bazel/remote_helpers.sh index efdb5a392c..70c9017ac4 100755 --- a/src/test/shell/bazel/remote_helpers.sh +++ b/src/test/shell/bazel/remote_helpers.sh @@ -77,6 +77,7 @@ EOF sha256=$(sha256sum $test_jar | cut -f 1 -d ' ') # OS X doesn't have sha1sum, so use openssl. sha1=$(openssl sha1 $test_jar | cut -f 2 -d ' ') + sha1_src=$(openssl sha1 $test_srcjar | cut -f 2 -d ' ') cd - } |