bin/ai/regression/completeness.sh
author rubidium
Tue, 15 Apr 2008 22:52:18 +0000
branchnoai
changeset 10198 e88e56267777
parent 9812 4bc3062476c8
permissions -rwxr-xr-x
(svn r12730) [NoAI] -Fix: the regression completeness checker did not understand Valuate, thus gave some false positives.
9564
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
     1
#!/bin/sh
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
     2
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
     3
if ! [ -f ai/regression/regression.nut ]; then
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
     4
	echo "Make sure you are in the root of OpenTTD before starting this script."
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
     5
	exit 1
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
     6
fi
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
     7
9812
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
     8
cat ai/regression/regression.nut | tr ';' '\n' | awk '
9564
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
     9
/^function/ {
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    10
	for (local in locals) {
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    11
		delete locals[local]
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    12
	}
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    13
	if (match($0, "function Regression::Start") || match($0, "function Regression::Stop")) next
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    14
	locals["this"] = "AIControllerSquirrel"
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    15
}
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    16
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    17
/local/ {
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    18
	gsub(".*local", "local")
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    19
	if (match($4, "^AI")) {
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    20
		sub("\\(.*", "", $4)
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    21
		locals[$2] = $4
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    22
	}
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    23
}
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    24
10198
e88e56267777 (svn r12730) [NoAI] -Fix: the regression completeness checker did not understand Valuate, thus gave some false positives.
rubidium
parents: 9812
diff changeset
    25
/Valuate/ {
e88e56267777 (svn r12730) [NoAI] -Fix: the regression completeness checker did not understand Valuate, thus gave some false positives.
rubidium
parents: 9812
diff changeset
    26
	gsub(".*Valuate\\(", "")
e88e56267777 (svn r12730) [NoAI] -Fix: the regression completeness checker did not understand Valuate, thus gave some false positives.
rubidium
parents: 9812
diff changeset
    27
	gsub("\\).*", "")
e88e56267777 (svn r12730) [NoAI] -Fix: the regression completeness checker did not understand Valuate, thus gave some false positives.
rubidium
parents: 9812
diff changeset
    28
	gsub(",.*", "")
e88e56267777 (svn r12730) [NoAI] -Fix: the regression completeness checker did not understand Valuate, thus gave some false positives.
rubidium
parents: 9812
diff changeset
    29
	gsub("\\.", "::")
e88e56267777 (svn r12730) [NoAI] -Fix: the regression completeness checker did not understand Valuate, thus gave some false positives.
rubidium
parents: 9812
diff changeset
    30
	print $0
e88e56267777 (svn r12730) [NoAI] -Fix: the regression completeness checker did not understand Valuate, thus gave some false positives.
rubidium
parents: 9812
diff changeset
    31
}
e88e56267777 (svn r12730) [NoAI] -Fix: the regression completeness checker did not understand Valuate, thus gave some false positives.
rubidium
parents: 9812
diff changeset
    32
9564
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    33
/\./ {
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    34
	for (local in locals) {
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    35
		if (match($0, local ".")) {
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    36
			fname = substr($0, index($0, local "."))
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    37
			sub("\\(.*", "", fname)
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    38
			sub("\\.", "::", fname)
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    39
			sub(local, locals[local], fname)
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    40
			print fname
9812
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    41
			if (match(locals[local], "List")) {
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    42
				sub(locals[local], "AIAbstractList", fname)
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    43
				print fname
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    44
			}
9564
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    45
		}
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    46
	}
9812
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    47
	# We want to remove everything before the FIRST occurence of AI.
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    48
	# If we do not remove any other occurences of AI from the string
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    49
	# we will remove everything before the LAST occurence of AI, so
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    50
	# do some little magic to make it work the way we want.
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    51
	sub("AI", "AXXXXY")
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    52
	gsub("AI", "AXXXXX")
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    53
	sub(".*AXXXXY", "AI")
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    54
	if (match($0, "^AI") && match($0, ".")) {
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    55
		sub("\\(.*", "", $0)
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    56
		sub("\\.", "::", $0)
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    57
		print $0
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    58
	}
9564
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    59
}
9812
4bc3062476c8 (svn r12400) [NoAI] -Fix: reduce the number of false positives in the regression test completeness check script.
rubidium
parents: 9596
diff changeset
    60
' | sed 's/	//g' | sort | uniq > tmp.in_regression
9564
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    61
10198
e88e56267777 (svn r12730) [NoAI] -Fix: the regression completeness checker did not understand Valuate, thus gave some false positives.
rubidium
parents: 9812
diff changeset
    62
grep 'DefSQ.*Method' ../src/ai/api/*.hpp.sq | grep -v 'AIError::' | grep -v 'AIAbstractList::Valuate' | grep -v '::GetClassName' | sed 's/^[^,]*, &//g;s/,[^,]*//g' | sort > tmp.in_api
9564
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    63
9565
7237786c6197 (svn r9503) [NoAI] -Fix r9502: use tmp.XXX for temporary file-names instead of XXX.txt
truelight
parents: 9564
diff changeset
    64
diff -u tmp.in_regression tmp.in_api | grep -v '^+++' | grep '^+' | sed 's/^+//'
9564
cd02879048c9 (svn r9502) [NoAI] -Add: script to check the 'completeness' of the regression test
rubidium
parents:
diff changeset
    65
9565
7237786c6197 (svn r9503) [NoAI] -Fix r9502: use tmp.XXX for temporary file-names instead of XXX.txt
truelight
parents: 9564
diff changeset
    66
rm -f tmp.in_regression tmp.in_api
7237786c6197 (svn r9503) [NoAI] -Fix r9502: use tmp.XXX for temporary file-names instead of XXX.txt
truelight
parents: 9564
diff changeset
    67