aboutsummaryrefslogtreecommitdiffstats
path: root/tests/runjacks/runjacks.sh
blob: 7d0f2874d87060be1a66ebb47f79d373b5ae0caf (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/sh
# run jacks against javac and ajc (with and without usejavac)
# @process-test ajc runjacks.sh # run jacks tests against javac and ajc (with and without usejavac)

[ -n "$DEBUG" ] && set -vx

errMssg() {
    [ -n "$1" ] && echo "## $0 $1"
    [ -n "$2" ] && exit "$2"
}

toJavaPath() {
    echo "$1" | sed 's|/cygdrive/\([a-zA-Z]\)/|\1:/|'
}

toDosPath() {
    toJavaPath "$1" | sed 's|/|\\|g'
}

emit_ajcbat() {
cat<<EOF
$jhomeDos\bin\java -classpath "$ajlibDos\aspectjtools.jar;$ajlibDos\aspectjrt.jar;$jhomeDos\lib\tools.jar" org.aspectj.tools.ajc.Main %1 %2 %3 %4 %5 %6 %7 %8
EOF
}

emit_ajcsetup() {
cat<<EOF
# Set the paths for your tools in this file
set JAVA_HOME $jhomeJ
set JAVA_CLASSPATH ""
set JAVAC $jacksDirJ/ajc.bat
set JAVAC_FLAGS "$javacFlags"

# To test the assert statement, use this setup
#set JAVAC_FLAGS "-source 1.4"
set JAVA ${JDKDIR}/jre/bin/java.exe
set JAVA_FLAGS ""

# This activates encoding support.
set JAVAC_ENCODING_FLAG "-encoding "
set tcltest::testConstraints(encoding) 1

# Activate javac only test cases
set tcltest::testConstraints(javac) 1

# Uncomment this to test the assert statement
#set tcltest::testConstraints(assert) 1

EOF
}

compareJacksResults() {
  [ -f javac.out ] || exit 2
  sc='/^==== [^ ][^ ]* FAILED/s|^==== \([^ ][^ ]*\) .*|\1 '
  for ajc in ajc usejavac ; do
    [ -f $ajc.out ] || exit 2
    for i in $ajc javac ; do 
        sed -n "$sc$i|p" "$i.out" | sort > "$i.join"
    done 
    join -a 1 -a 2 $ajc.join javac.join \
       | sed "/$ajc javac/d" \
       | sort > compare.javac.$ajc.out
    rm $ajc.join javac.join
    
    ajcCount=`sed -n "/ $ajc/p" compare.javac.$ajc.out | wc -l`
    javacCount=`sed -n "/ javac/p" compare.javac.$ajc.out | wc -l`
    
    echo "## $ajcCount $ajc failures unmatched by javac" 
    echo "## $javacCount javac failures unmatched by $ajc"
  done
  wc -l *.out 
}



#############################################
SKIP_USEJAVAC=skippingUseJavac
#pattern='*abrupt*'  # use this to test script w/o running all
if [ ! "$1" = "compare" ] ; then
tclDir=/cygdrive/c/home/apps/tcl # XXX crosscut only
case `uname` in 
    CYGWIN* ) ;;
    * ) errMssg "only cygwin supported" 4 ;;
esac

[ -z "$JDKDIR" -o -x "$JDKDIR/bin/java" ] \
  || errMssg "requires valid JDKDIR=$JDKDIR" 5

[ -z "$tclDir" -o -x "$tclDir/bin/tclsh" ] \
  || errMssg "requires valid tclDir=$tclDir" 5

cvsroot=":pserver:anoncvs@oss.software.ibm.com:/usr/cvs/jikes"
scriptDir=`dirname "$0"`
scriptDir=`cd "$scriptDir";pwd`
toBaseDir=../../..
jacksDir="${jacksDir:-`cd "$scriptDir/$toBaseDir";pwd`/jacks}"
ajlibDir="${ajlibDir:-`cd "$scriptDir/$toBaseDir";pwd`/aj-build-modules/jars}"
outDir="${outDir:-${1:-.}}"
[ -d "$outDir" ] || exit 3

jacksDirJ=`toJavaPath "$jacksDir"`
jhomeJ=`toJavaPath "$JDKDIR"`
ajlibDos=`toDosPath "$ajlibDir"`
jhomeDos=`toDosPath "$JDKDIR"`

[ -f "$ajlibDir/aspectjtools.jar" ] \
  || errMssg "bad ajlibDir=$ajlibDir" 4

## get jacks if necessary
if [ -d "$jacksDir" ] ; then
  [ -f "$jacksDir/jacks.tcl" ] || errMssg "bad jacksDir" 4
  echo "## using existing jacks dir at $jacksDir"
else
  cd `dirname "$jacksDir"` || errMssg "bad path to $jacksDir" 5
  echo anoncvs | cvs -d "$cvsroot" login 
  cvs -d "$cvsroot" co jacks 
fi

## setup our stuff
cd "$jacksDir" || errMssg "jacks dir failed" 6

# comment unix, uncomment cygwin
sc='/ulimit/s|^|#|'
sc="$sc;"'/^exec tclsh8*/s|^|#|'
sc="$sc;"'/^##* *exec tclsh.*cygpath/s|^##* *e|e|'
sed "$sc" jacks > ff \
  && mv ff jacks || errMssg "unable to setup jacks for cygwin" 2

export PATH="$tclDir/bin:$JDKDIR/bin:$jacksDir:$PATH"

## javac should work in any case
if [ -f javac.out ] ; then
    echo "using existing javac.out"
    ls -ald javac.out
else 
    ## need to setup JAVA_HOME, JAVAC, JAVA
    sc='/^set JAVA_HOME /s|.*|set JAVA_HOME '"$JDKDIR|" 
    sc="$sc;"'/^set JAVAC /s|.*|set JAVAC $JAVA_HOME/bin/javac.exe|' 
    sc="$sc;"'/^set JAVA /s|.*|set JAVA $JAVA_HOME/bin/java.exe|' 
    sed "$sc" javac_setup > ff && mv ff javac_setup
    echo "## starting javac at `date`"
    jacks javac $pattern > "$outDir/"javac.out || errMssg "javac failed " "$?"
    echo "##   ending javac at `date`"
fi

if [ -f "$outDir/"ajc.out ] ; then
    echo "using existing ajc.out"
    ls -ald "$outDir/"ajc.out
else 
    ## setup and run  ajc
    emit_ajcbat > ajc.bat
    emit_ajcsetup > ajc_setup
    echo "## starting ajc at `date`"
    jacks ajc $pattern > "$outDir/"ajc.out || errMssg "ajc failed " "$?"
    echo "##   ending ajc at `date`"
fi

if [ -f "$outDir/"usejavac.out ] ; then
    echo "using existing usejavac.out"
    ls -ald "$outDir/"usejavac.out
elif [ -n "$SKIP_USEJAVAC" ] ; then 
    echo "skipping usejavac"
else 
    ## setup -usejavac
    javacFlags="-usejavac"
    emit_ajcsetup > ajc_setup
    echo "## starting ajc -usejavac at `date`"
    jacks ajc $pattern > "$outDir/"usejavac.out || errMssg "usejavac failed " "$?"
    echo "##   ending ajc -usejavac at `date`"
fi

fi ## not only comparing

compareJacksResults