-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgen_tests.sh
More file actions
executable file
·50 lines (38 loc) · 871 Bytes
/
gen_tests.sh
File metadata and controls
executable file
·50 lines (38 loc) · 871 Bytes
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
#!/usr/bin/env bash
set -o errexit
set -o pipefail
#set -o xtrace
url="http://packs.download.atmel.com"
atpacks="Atmel.ATmega_DFP.1.2.203 Atmel.ATtiny_DFP.1.3.169"
outdir=tests/data
testfile="tests/data/suite.rs"
function get_pack {
atpack=$1
outdir="${outdir}/${atpack}"
mkdir -p "$outdir"
pushd "$outdir" >/dev/null
echo "Fetching ${atpack}..."
curl --silent "${url}/${atpack}.atpack" > "${atpack}.zip"
yes | unzip "${atpack}.zip" "atdf/*" 2>/dev/null
rm "${atpack}.zip"
popd >/dev/null
}
for pack in $atpacks; do
( get_pack "$pack" ) &
done
wait
function gen_test {
ident=${1##*/}
cat >>${testfile} <<-EOF
#[test]
fn ${ident%.*}() {
parse("$1");
}
EOF
}
echo "Generating tests..."
mkdir -p `dirname ${testfile}`
echo -n "" > ${testfile}
for f in ${outdir}/*/atdf/*.atdf; do
gen_test $f
done