1
#!/bin/bash
2
3
result_root="/tmp/layout-test-results"
4
5
6
if [ $# != 1 ]; then
7
    echo "usage: $0 layout-test|-A"
8
    exit 1
9
fi
10
11
if [ ! -d ${result_root} ]; then
12
    echo "Could not find any test results in '${result_root}'!"
13
    exit 2    
14
fi
15
16
if [ ! -d "LayoutTests" ]; then
17
    echo "Please call this script from the root of your WebKit checkout."
18
    exit 4
19
fi
20
21
run_auto_mode() {
22
    echo "The script will now open a konqueror window for each test that failed."
23
    echo "Closing the window will signal that the test should be updated, while"
24
    echo "killing the konqueror process will skip that test."
25
    echo
26
    echo "Press any key to continue, or Ctrl+C to exit."
27
    echo
28
    read -n1 any_key
29
    
30
    for test in `find ${result_root} | grep ".diff"`; do
31
        ((`konqueror ${test} > /dev/null 2>&1`) && update_test ${test}) || (echo "Skipped '${test}'...")
32
    done
33
}
34
35
36
update_test() {
37
38
    # Strip file-spesific stuff if present
39
    if [ -z "$1" ]; then
40
        return 1;
41
    fi
42
43
    test=${1}
44
    test=${test%-diffs.txt}
45
    test=${test%-expected.txt}
46
    test=${test%-actual.txt}
47
    test=${test%.html}
48
49
    # Strip location of results
50
51
    test=${test#/tmp/layout-test-results/} 
52
53
    if [ ! -f "/tmp/layout-test-results/${test}-actual.txt" ]; then
54
        echo "Could not find results for layout-test '${test}', skipping..."
55
    else    
56
        echo "Updating '${test}'..."
57
        cp "/tmp/layout-test-results/${test}-actual.txt" "LayoutTests/platform/qt/${test}-expected.txt"
58
    fi
59
}
60
61
if [ "$1" == "-A" ]; then
62
    run_auto_mode
63
else
64
    update_test ${1}
65
fi