Home | History | Annotate | Download | only in desugar
      1 #!/bin/bash -e
      2 #
      3 # Copyright 2016 The Bazel Authors. All rights reserved.
      4 #
      5 # Licensed under the Apache License, Version 2.0 (the "License");
      6 # you may not use this file except in compliance with the License.
      7 # You may obtain a copy of the License at
      8 #
      9 #    http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 # Unless required by applicable law or agreed to in writing, software
     12 # distributed under the License is distributed on an "AS IS" BASIS,
     13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 # See the License for the specific language governing permissions and
     15 # limitations under the License.
     16 
     17 # Test that lists the content of the desugared Jar and compares it to a golden
     18 # file.  This makes sure that output is deterministic and the resulting Jar
     19 # doesn't contain any unwanted files, such as lambdas generated as part of
     20 # running the desugaring tool.
     21 
     22 progdir="$(dirname "$0")"
     23 
     24 if [ -d "$TEST_TMPDIR" ]; then
     25   # Running as part of blaze test
     26   tmpdir="$TEST_TMPDIR"
     27 else
     28   # Manual run from command line
     29   tmpdir="/tmp/test-$$"
     30   mkdir "${tmpdir}"
     31 fi
     32 
     33 if [ -d "$TEST_UNDECLARED_OUTPUTS_DIR" ]; then
     34   # Running as part of blaze test: capture test output
     35   output="$TEST_UNDECLARED_OUTPUTS_DIR"
     36 else
     37   # Manual run from command line: just write into temp dir
     38   output="${tmpdir}"
     39 fi
     40 
     41 JAVABASE=$3
     42 $JAVABASE/bin/jar tf "$1" >"${output}/actual_toc.txt"
     43 # sorting can be removed when cl/145334839 is released
     44 diff <(sort "$2") <(sort "${output}/actual_toc.txt")
     45