2 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 while [ "$stop" = false
]; do
19 -v
) verbose
=true
; shift;;
25 echo "Usage: search_test.sh [-v] prog/res/testname..."
26 echo "Search program paths of tests for given nit files, res files, and test names"
27 echo " -v Try to find something and display it when a test is not found."
33 # Build the full list once to filter results
34 .
/listfull.sh
> listfull.out
35 find zzz_tests
>> listfull.out
41 if test -f
"$ff"; then
45 b
=`basename -- "$f" .nit`
48 b
=`basename -- "$f" .res`
56 c
="$(printf '%s\n' "$b" | sed '
57 # POSIX BRE metacharacters -> .
60 # Escape the apostrophe the same way than `listfull.sh`,
61 # then re-escape in POSIX BRE.
62 # x -> x\\xx (where `x` is the apostrophe)
63 s/'\''/'\''\\\\'\'\''/g
66 # Remove alts of args test variations
67 c
=`echo "$c" | sed 's/\(_[0-9]*alt[0-9][0-9]*\)/\\\\(\1\\\\)\\\\?/g;s/\(_args[0-9][0-9]*\)/\\\\(\1\\\\)\\\\?/'`
68 b
=`echo "$b" | sed 's/_[0-9]*alt[0-9][0-9]*//g;s/_args[0-9][0-9]*//'`
69 # Search the orig nit file in the list
71 grep -- "\(^'\|/\)$c.nit" listfull.out |
xargs -E
'' -- printf '%s\n'
74 echo >&2 "No test $b.nit found for $f"
75 test "$verbose" == "true" ||
continue
76 # Search the nit file outside the list...
77 find ..
/..
/nit
* -name
"$b.nit" >&2
78 # Search the nit file in the git history...
79 git log
-1 -- "$b.nit" >&2
80 # Search the orig file in the git history...
81 git log
-1 -- "$f" >&2