#!/bin/bash -e

# Copyright (c) 2013 - present Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

# This script takes a buck target and runs the respective tests.

# Arguments:
# $1 : buck target
# [$2] : "keep" or "replace". Keep will keep the temporary folders used in the tests.
#         Replace will replace the saved dot files with the new created ones.

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )"

cd $SCRIPT_DIR/../../

case $2 in
    keep)
        INFER_KEEP_FOLDER=Y buck test --no-results-cache $1 ;;
    replace)
        INFER_DOT_REPLACE=Y buck test --no-results-cache $1 ;;
    *)
        buck test --no-results-cache $1 ;;
esac
