github.com/mackerelio/mackerel-agent-plugins@v0.89.3/test.bash (about)

     1  #!/bin/bash
     2  
     3  # install dependencies
     4  go install github.com/lufia/graphitemetrictest/cmd/graphite-metric-test@latest || exit
     5  
     6  # prepare tests
     7  for f in mackerel-plugin-*/test.sh
     8  do
     9  	dir=$(dirname "$f")
    10  	name=$(basename "$dir")
    11  	go build -o "$dir/$name" ./"$dir" || exit
    12  done
    13  
    14  # run tests
    15  declare -A plugins=()
    16  for f in mackerel-plugin-*/test.sh
    17  do
    18  	./"$f" &
    19  	pid=$!
    20  	plugins[$pid]="$f"
    21  	pids="${pids} ${pid}"
    22  done
    23  
    24  # collect the results
    25  declare -a results=()
    26  status=0
    27  for i in $pids
    28  do
    29  	if wait "$i"
    30  	then
    31  		results+=("OK: ${plugins[$i]}")
    32  	else
    33  		results+=("ERR: ${plugins[$i]}")
    34  		status=1
    35  	fi
    36  done
    37  echo '======' >&2
    38  for s in "${results[@]}"
    39  do
    40  	echo "$s" >&2
    41  done
    42  exit $status