File: compact-tests

package info (click to toggle)
cod-tools 3.11.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 159,136 kB
  • sloc: perl: 58,707; sh: 41,323; ansic: 7,268; xml: 1,982; yacc: 1,117; makefile: 731; python: 166
file content (64 lines) | stat: -rwxr-xr-x 2,066 bytes parent folder | download | duplicates (2)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/bash

# Renumber test cases sequentially, without gaps.

# USAGE:

#    $0
#    $0 tests/cases
#    $0 tests/subdirs/*

if [ $# -eq 0 ]
then
    set tests/cases tests/outputs
fi

for CASE_DIR in "$@"
do
    for TESTED in $(ls -1 ${CASE_DIR}/*_[0-9]*.* | sed 's/_[0-9][0-9]*\..*//' | sort -u)
    do
        echo "${TESTED}"
        CURRENT_CASE=1 # The current renumbered test case
        PROCESSED=0
        for CASE in $(ls ${TESTED}_[0-9]*.*)
        do
            if [[ ${CASE} =~ \.diff$ ]]; then
                # The *.diff files do not signify existing test cases;
                # they can be a leftover from the previous test
                # runs. They will be copied when the corresponding
                # test case is indeed found. Therefore, we just skip
                # them here:
                continue
            fi
            NAME=$(echo "${CASE}" | sed 's/_[0-9][0-9]*\..*//')
            SUFX=$(echo "${CASE}" | sed 's/^.*\.//')
            NUMBER=$(echo "${CASE}" | sed 's/^.*_//; s/\..*$//; s/^00*//')
            if [ "$NUMBER" -eq $PROCESSED ]; then
                continue
            fi
            PROCESSED=$NUMBER;
            echo '#' case: "$CASE"
            ## echo $NUMBER
            if [ $CURRENT_CASE -ne "$NUMBER" ]
            then
                NEW_BASE=${NAME}_$(printf "%03d" $CURRENT_CASE)
                OLD_BASE=${NAME}_$(printf "%03d" "$NUMBER")
                for EXT in sh opt env inp chk tst out diff
                do
                    OLD_FILE=${OLD_BASE}.${EXT}
                    if [ -f "${OLD_FILE}" ]
                    then
                        NEW_FILE=${NEW_BASE}.${EXT}
                        if [[ ${OLD_FILE} =~ \.diff$ ]]
                        then
                            mv -v "${OLD_FILE}" "${NEW_FILE}"
                        else
                            svn mv "${OLD_FILE}" "${NEW_FILE}"
                        fi
                    fi
                done
            fi
            CURRENT_CASE=$(expr $CURRENT_CASE + 1)
        done
    done
done