github.com/bazelbuild/rules_webtesting@v0.2.0/go/metadata/main/merger_test.sh (about)

     1  #!/bin/bash -eu
     2  #
     3  # Copyright 2016 Google Inc.
     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  ################################################################################
    18  #
    19  set +e
    20  printenv
    21  
    22  error=0
    23  
    24  # TODO(DrMarcII): Figure out how to not hard code this path.
    25  merger=$TEST_SRCDIR/$TEST_WORKSPACE/go/metadata/main/linux_amd64_stripped/main
    26  
    27  $merger --output $TEST_TMPDIR/out.json \
    28      $TEST_SRCDIR/$TEST_WORKSPACE/testdata/chrome-linux.json \
    29      $TEST_SRCDIR/$TEST_WORKSPACE/testdata/android-browser-gingerbread-nexus-s.json
    30  
    31  diff -b $TEST_TMPDIR/out.json \
    32      $TEST_SRCDIR/$TEST_WORKSPACE/testdata/merger-result.json
    33  if [[ $? != 0 ]]; then
    34    echo "Merge of chrome-linux.json with android-browser-gingerbread-nexus-s.json didn't equal merger-result.json."
    35    error=1
    36  fi
    37  
    38  $merger --output $TEST_TMPDIR/out2.json \
    39      $TEST_SRCDIR/$TEST_WORKSPACE/testdata/named-files1.json \
    40      $TEST_SRCDIR/$TEST_WORKSPACE/testdata/named-files1.json
    41  if [[ $? != 0 ]]; then
    42    echo "Merge of named-files1.json with itself failed."
    43    error=1
    44  fi
    45  
    46  $merger --output $TEST_TMPDIR/out2.json \
    47      $TEST_SRCDIR/$TEST_WORKSPACE/testdata/named-files1.json \
    48      $TEST_SRCDIR/$TEST_WORKSPACE/testdata/named-files2.json
    49  if [[ $? == 0 ]]; then
    50    echo "Expected merge of named-files1.json with named-files2.json to fail."
    51    error=1
    52  fi
    53  
    54  $merger --output $TEST_TMPDIR/out2.json \
    55      $TEST_SRCDIR/$TEST_WORKSPACE/testdata/bad-named-files.json
    56  if [[ $? == 0 ]]; then
    57    echo "Expected load of bad-named-files.json to fail."
    58    error=1
    59  fi
    60  
    61  exit $error