github.com/jenkins-x/jx/v2@v2.1.155/pkg/util/test_data/scripts/fail_iterator.sh (about)

     1  #!/bin/sh
     2  
     3  # This script is intended to be used to match a pass attempt in a loop. Currently used in command_test.go
     4  
     5  set -e
     6  
     7  _file="$1"
     8  [ $# -eq 0 ] && { echo "Usage: $0 filename"; exit 1; }
     9  [ ! -f "$_file" ] && { echo "Error: $0 file not found."; exit 2; }
    10   
    11  if [ -s "$_file" ] 
    12  then
    13  	read TRY < $_file
    14  else
    15  	TRY=1
    16  fi
    17  
    18  PASS_ATTEMPT=$2
    19  
    20  if [ "$TRY" = "$PASS_ATTEMPT" ]; then
    21  	echo "PASS"
    22  	TRY=$(($TRY + 1))
    23  	echo $TRY > $1
    24  	exit 0
    25  else
    26  	echo "FAILURE!"
    27  	TRY=$(($TRY + 1))
    28  	echo $TRY > $1
    29  	exit 1
    30  fi