cmogstored.git  about / heads / tags
alternative mogstored implementation for MogileFS
blob 42a5eee33927923b066851eb75ab88ef522ef189 1195 bytes (raw)
$ git show HEAD:test/gen-slow.sh	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
#!/bin/sh
# Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
#
# Splits out individual Test::Unit test cases to be standalone Ruby
# test files.  This requires Ruby test files to be properly
# formatted/indented.  Outputs a Makefile snippet to stdout of
# all files generated
#
# Usage: test/gen-slow.sh RUBY_TEST_FILES

AWK=${AWK-awk}
set -u
set -e

echo "SLOW_RB_FILES ="

for RB_TEST in "$@"
do
	TESTS="$($AWK '/^  def test_/ { print $2 }' $RB_TEST)"
	case $TESTS in '') continue ;; esac
	CLASS="$($AWK '/^class / && /::TestCase/ { print $2 }' $RB_TEST)"
	case $CLASS
	in '')
		echo "Ruby class name not found in $RB_TEST" >&2
		exit 1
		;;
	esac

	for TEST in $TESTS
	do
		RB_BASENAME="$(basename $RB_TEST)"
		RB_DIRNAME="$(dirname $RB_TEST)"
		RB_PFX=${RB_BASENAME%.rb}
		mkdir -p "$RB_DIRNAME/.$RB_PFX"
		FILE="$RB_DIRNAME/.$RB_PFX/${TEST#test_}.slowrb"
		tmp="$FILE.$$"
		cat > "$tmp" <<EOF
#!/bin/sh -u
# This file is auto-generated with: $0 $RB_TEST
exec "\$RUBY" -I"\$top_srcdir" -w "\$top_srcdir"/$RB_TEST -n $TEST
EOF
		chmod +x "$tmp"
		mv "$tmp" "$FILE"
		echo "SLOW_RB_FILES += $FILE"
	done
done

git clone https://yhbt.net/cmogstored.git