1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # devtools/release-history.sh <function name>
|
5 |
|
6 | set -o nounset
|
7 | set -o pipefail
|
8 | set -o errexit
|
9 |
|
10 | source build/dev-shell.sh # R_LIBS_USER
|
11 |
|
12 | readonly ROOT=../oilshell.org__deploy
|
13 | readonly BASE_DIR=_tmp/release-history
|
14 |
|
15 | wwz-tsv() {
|
16 | mkdir -p $BASE_DIR
|
17 |
|
18 | find $ROOT/release/ -mindepth 1 -maxdepth 1 -type d \
|
19 | | sort \
|
20 | | devtools/release_history.py > $BASE_DIR/wwz.tsv
|
21 |
|
22 | wc -l $BASE_DIR/wwz.tsv
|
23 |
|
24 | # TODO:
|
25 | # - Have to sync the .wwz files for some releases. I really want "vat" here.
|
26 | }
|
27 |
|
28 | print-row() {
|
29 | local i=0
|
30 | for cell in "$@"; do
|
31 | if test $i -ne 0; then
|
32 | echo -n $'\t'
|
33 | fi
|
34 | echo -n "$cell"
|
35 | i=$((i + 1))
|
36 | done
|
37 | echo
|
38 | }
|
39 |
|
40 | extract-totals() {
|
41 | local base_dir=$1
|
42 |
|
43 | local -a header=()
|
44 | local -a row=()
|
45 |
|
46 | IFS=$'\t' read -a header
|
47 | #argv "${header[@]}"
|
48 |
|
49 | print-row release_date version osh_py_passing osh_cc_passing
|
50 |
|
51 | while IFS=$'\t' read -a row; do
|
52 | local release_date=${row[0]}
|
53 | local version=${row[1]}
|
54 | local spec_wwz=${row[2]}
|
55 | local survey_path=${row[3]}
|
56 | local cpp_summary_path=${row[4]}
|
57 |
|
58 | if test $spec_wwz = '-'; then
|
59 | continue
|
60 | fi
|
61 |
|
62 | spec_wwz=$PWD/$spec_wwz
|
63 |
|
64 | local d=$base_dir/tmp/$version
|
65 | mkdir -p $d
|
66 |
|
67 | pushd $d > /dev/null
|
68 |
|
69 | # -o: overwrite without prompting
|
70 |
|
71 | local osh_py_passing='NA'
|
72 | if test $survey_path != '-'; then
|
73 | unzip -q -o $spec_wwz $survey_path
|
74 | osh_py_passing=$(osh-py-passing $survey_path) # strip trailing newline
|
75 | fi
|
76 |
|
77 | local osh_cpp_passing='NA'
|
78 | if test $cpp_summary_path != '-'; then
|
79 | unzip -q -o $spec_wwz $cpp_summary_path
|
80 | osh_cpp_passing=$(osh-cc-passing $cpp_summary_path)
|
81 | fi
|
82 |
|
83 | popd > /dev/null
|
84 |
|
85 | print-row "$release_date" "$version" "$osh_py_passing" "$osh_cpp_passing"
|
86 |
|
87 | #argv "${row[@]}"
|
88 | done
|
89 | }
|
90 |
|
91 | normalize() {
|
92 | local path=$1
|
93 |
|
94 | # hxselect requires a well-formed XML document
|
95 | # NOTE: syntax error on "<tr class=>", but it correctly ignores it
|
96 | hxnormalize -x $path > $path.xml || true
|
97 | }
|
98 |
|
99 | osh-py-passing() {
|
100 | ### Given a file, print the Python total to stdout
|
101 |
|
102 | local path=$1
|
103 |
|
104 | normalize $path
|
105 | # This works for recent ones, with header at the top
|
106 | #hxselect -s $'\n' -c '.totals:nth-child(1) td:nth-child(3)' < $path.xml | head -n 1
|
107 |
|
108 | # Older ones: total is in footer
|
109 | #hxselect -s $'\n' -c 'tfoot td:nth-child(3)' < $path.xml
|
110 |
|
111 | log "path = $path"
|
112 | local name
|
113 | name=$(basename $path)
|
114 |
|
115 |
|
116 | # TODO:
|
117 | # - Extract tfoot cells 3 and 5
|
118 | # - Extract head cells 3 and 5 -- description
|
119 | # - And then in R, select the right one for osh_py_passing
|
120 |
|
121 | if test "$name" = 'index.html'; then
|
122 | # It might be 3 or 5 -- I moved the columns around
|
123 | local count
|
124 |
|
125 | count=$(hxselect -s $'\n' -c 'tfoot td:nth-child(5)' < $path.xml)
|
126 |
|
127 | # Differing format
|
128 | if test "$count" -lt 100; then
|
129 | count=$(hxselect -s $'\n' -c 'tfoot td:nth-child(3)' < $path.xml)
|
130 | fi
|
131 | echo "$count"
|
132 |
|
133 | else
|
134 | hxselect -s $'\n' -c '.totals:nth-child(1) td:nth-child(3)' < $path.xml | head -n 1
|
135 | fi
|
136 | }
|
137 |
|
138 | osh-cc-passing() {
|
139 | ### Given a file, print the C++ total to stdout
|
140 |
|
141 | local path=$1
|
142 | normalize $path
|
143 |
|
144 | # Change 1,137 -> 1137
|
145 | < $path.xml hxselect -s $'\n' -c '#summary thead tr:nth-child(2) td:nth-child(5)' | sed 's/,//'
|
146 | }
|
147 |
|
148 | spec-tsv() {
|
149 | rm -r -f -v $BASE_DIR/tmp # extract-totals writes to this dir
|
150 |
|
151 | < $BASE_DIR/wwz.tsv extract-totals $BASE_DIR | tee $BASE_DIR/spec.tsv
|
152 |
|
153 | echo
|
154 | wc -l $BASE_DIR/*.tsv
|
155 | }
|
156 |
|
157 | tsv-preview() {
|
158 | cat $BASE_DIR/wwz.tsv | pretty-tsv
|
159 | echo
|
160 | cat $BASE_DIR/spec.tsv | pretty-tsv
|
161 | }
|
162 |
|
163 | report() {
|
164 | devtools/release-history.R $BASE_DIR $BASE_DIR
|
165 | }
|
166 |
|
167 | copy() {
|
168 | cp -v $BASE_DIR/spec-test-history-2.png ../oilshell.org__deploy/blog/2022/03
|
169 | }
|
170 |
|
171 | deps-apt() {
|
172 | # https://superuser.com/questions/528709/command-line-css-selector-tool
|
173 | sudo apt-get install html-xml-utils
|
174 | }
|
175 |
|
176 | # MEH these tools have bad error messages.
|
177 | test-parsing() {
|
178 | unzip -l $ROOT/release/0.9.8/test/spec.wwz || echo status=$?
|
179 |
|
180 | unzip -p $ROOT/release/0.9.8/test/spec.wwz 'cpp/osh-summary.html' > _tmp/osh-summary.html
|
181 |
|
182 | local tmp=_tmp
|
183 |
|
184 | # hxnormalize makes it XML.
|
185 | # NOTE: syntax error on "<tr class=>", but it correctly ignores it
|
186 | echo
|
187 | echo 'NEW PYTHON'
|
188 | # Annoying syntax for this command
|
189 | unzip -p $ROOT/release/0.9.8/test/spec.wwz 'survey/osh.html' > _tmp/osh.html
|
190 | osh-py-passing _tmp/osh.html
|
191 |
|
192 | echo
|
193 | echo 'OLD PYTHON 0.7.pre3'
|
194 | unzip -p $ROOT/release/0.7.pre3/test/spec.wwz 'index.html' > _tmp/index.html
|
195 | osh-py-passing _tmp/index.html
|
196 |
|
197 | echo
|
198 | echo 'OLD PYTHON 0.2.0'
|
199 | unzip -p $ROOT/release/0.2.0/test/spec.wwz 'index.html' > _tmp/index.html
|
200 | osh-py-passing _tmp/index.html
|
201 |
|
202 | echo
|
203 | echo 'CPP'
|
204 | osh-cc-passing _tmp/osh-summary.html
|
205 | }
|
206 |
|
207 | "$@"
|