• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The Bazel Authors. All rights reserved.
2#
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.
14
15#!/bin/bash
16#
17# template generated by genshtest
18
19# Find input files
20declare -r INPUT_JDEPS="${TEST_SRCDIR}/src/tools/jdeps/testdata/test_data.jdeps"
21declare -r OUT_JDEPS="${TEST_TMPDIR}/test_data.filtered.jdeps"
22declare -r JDEPS_FILTER_TOOL="${TEST_SRCDIR}/src/tools/jdeps/jdeps"
23declare -r JDEPS_PRINT_TOOL="${TEST_SRCDIR}/src/tools/jdeps/print_jdeps"
24
25# Verify that _resource.jar is in jdeps
26jdeps=`$JDEPS_PRINT_TOOL --in $INPUT_JDEPS`
27matches=`echo "$jdeps" | grep '_resources.jar$' | wc -l`
28entries=`echo "$jdeps" | wc -l`
29[ $matches -eq 1 ] || die "Original jdeps did not have one resources.jar"
30
31# Run filter tool
32$JDEPS_FILTER_TOOL --in $INPUT_JDEPS --target "_resources.jar" --out $OUT_JDEPS
33
34# Verify that _resource.jar is not in jdeps
35filtered_jdeps=`$JDEPS_PRINT_TOOL --in $OUT_JDEPS`
36filtered_matches=`echo "$filtered_jdeps" | grep '_resources.jar$' | wc -l`
37filtered_entries=`echo "$filtered_jdeps" | wc -l`
38[ $filtered_matches -eq 0 ] || die "Filtered jdeps still has resources.jar"
39
40# Verify that we removed one item
41[ $(($entries-$filtered_entries)) -eq 1 ] || die "Did not remove one item from jdeps"
42
43echo "PASS"
44