pytest is not correctly auto-installed
[WebKit-https.git] / Tools / Scripts / run-layout-jsc
1 #! /bin/sh
2
3 # Copyright (C) 2012 Apple Inc. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
18 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
25
26 # Script to run selected LayoutTests/{js,fast/regex} tests using jsc
27
28 jscCmd="/System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc"
29 testRoot=/tmp/LayoutTests
30 resultsRoot=`date \+/tmp/results-%Y-%m-%d-%H-%M-%S`
31
32 cmdName=`basename $0`
33
34 usage()
35 {
36     echo "usage: $cmdName [[--jsc | -j] <path-to-jsc>] [[--results-dir | -r] <results-path>]"
37     echo "                    [[--test-root | -t] <test-root-path>]"
38     exit 1
39 }
40
41 while [ $# -gt 1 ]
42 do
43     case $1 in
44     --jsc|-j)
45         jscCmd=$2
46         ;;
47     --results-dir|-r)
48         resultsRoot=$2
49         ;;
50     --test-root|-t)
51         testRoot=$2
52         ;;
53     *)
54         echo "Unrecognized option \"$1\""
55         usage
56         ;;
57     esac
58
59     shift 2
60 done
61
62 if [ $# -gt 0 ]
63 then
64     echo "Extra argument \"$1\""
65     usage
66 fi
67
68 preScript=$testRoot/resources/standalone-pre.js
69 postScript=$testRoot/resources/standalone-post.js
70 passList=$resultsRoot/passed
71 failList=$resultsRoot/failed
72 crashList=$resultsRoot/crashed
73
74 numTestsRun=0
75 numPassed=0
76 numFailed=0
77 numCrashed=0
78
79 rm -rf $resultsRoot
80 rm -f jsc-tests-passed jsc-tests-failed
81
82 for testHTMLFile in `(cd $testRoot && ls -1 js/*.html fast/regex/*.html)`
83 do
84     testPassed=0
85     testCrashed=0
86     testName=`basename $testHTMLFile .html`
87     dirName=`dirname $testHTMLFile`
88     test=$dirName/$testName
89      
90     expectedOut="$testRoot/$dirName/${testName}-expected.txt"
91     actualOut="$resultsRoot/$dirName/${testName}-out.txt"
92     actualErr="$resultsRoot/$dirName/${testName}-err.txt"
93     diffOut="$resultsRoot/$dirName/${testName}-diff.txt"
94     jsTest="$testRoot/$dirName/script-tests/${testName}.js"
95
96     if [ ! -d "$resultsRoot/$dirName" ]
97     then
98         mkdir -p "$resultsRoot/$dirName"
99     fi
100
101     if [ -f $jsTest ]
102     then
103         if [ `uname` = 'Darwin' ]; then
104             echo "Testing $test ... \c"
105         else
106             echo -n "Testing $test ..."
107         fi
108         numTestsRun=$(($numTestsRun+1))
109         $jscCmd $preScript $jsTest $postScript 2>$actualErr > $actualOut
110         JSC_RES=$?
111         
112         if [ $JSC_RES -eq 0 ]
113         then
114             diff $actualOut $expectedOut > $diffOut
115             if [ $? -eq 0 ]
116             then
117                 testPassed=1
118                 echo "PASSED"
119             else
120                 testPassed=0
121                 echo "FAILED"
122             fi
123         else
124             testPassed=0
125             if [ $JSC_RES -gt 128 ]
126             then
127                 testCrashed=1
128                 echo "CRASHED"
129             else
130                 echo "ERROR: $JSC_RES"
131             fi
132         fi
133
134         if [ $testPassed -eq 1 ]
135         then
136             echo "$test" >> $passList
137             numPassed=$(($numPassed+1))
138         else
139             echo "$test" >> $failList
140             numFailed=$(($numFailed+1))
141             if [ $testCrashed -eq 1 ]
142             then
143                 echo "$test" >> $crashList
144                 numCrashed=$(($numCrashed+1))
145             fi
146         fi
147     fi
148 done
149
150 if [ $numPassed -eq $numTestsRun ]
151 then
152     echo "All $numTestsRun tests passed!" | tee $resultsRoot/summary
153 else
154     echo "$numPassed tests passed, $numFailed tests failed, $numCrashed tests crashed." | tee $resultsRoot/summary
155 fi
156
157 echo "Test results in $resultsRoot"