1*b2fa4294SXin Li#!/bin/bash 2*b2fa4294SXin Li# 3*b2fa4294SXin Li# Copyright 2018 The Bazel Authors. All rights reserved. 4*b2fa4294SXin Li# 5*b2fa4294SXin Li# Licensed under the Apache License, Version 2.0 (the "License"); 6*b2fa4294SXin Li# you may not use this file except in compliance with the License. 7*b2fa4294SXin Li# You may obtain a copy of the License at 8*b2fa4294SXin Li# 9*b2fa4294SXin Li# http://www.apache.org/licenses/LICENSE-2.0 10*b2fa4294SXin Li# 11*b2fa4294SXin Li# Unless required by applicable law or agreed to in writing, software 12*b2fa4294SXin Li# distributed under the License is distributed on an "AS IS" BASIS, 13*b2fa4294SXin Li# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*b2fa4294SXin Li# See the License for the specific language governing permissions and 15*b2fa4294SXin Li# limitations under the License. 16*b2fa4294SXin Li# 17*b2fa4294SXin Li# A shell test that the contents of an input file match a golden file. 18*b2fa4294SXin Li# 19*b2fa4294SXin Li# Usage: diff_test_runner.sh ACTUAL_FILE GOLDEN_FILE 20*b2fa4294SXin Li 21*b2fa4294SXin Liset -u 22*b2fa4294SXin Li 23*b2fa4294SXin Liactual_file=$1 24*b2fa4294SXin Lishift 1 25*b2fa4294SXin Ligolden_file=$1 26*b2fa4294SXin Lishift 1 27*b2fa4294SXin Li 28*b2fa4294SXin LiDIFF="$(diff ${actual_file} ${golden_file})" 29*b2fa4294SXin Li 30*b2fa4294SXin Liif [ "$DIFF" != "" ] 31*b2fa4294SXin Lithen 32*b2fa4294SXin Li echo "FAIL: Actual did not match golden." 33*b2fa4294SXin Li echo "${DIFF}" 34*b2fa4294SXin Li exit 1 35*b2fa4294SXin Lielse 36*b2fa4294SXin Li echo "SUCCESS: Result matches golden file" 37*b2fa4294SXin Lifi 38