Skip to content

Commit ba6a9c6

Browse files
author
George Adams
committed
tools: add download testing
This script will take an environment variable (NODE_VERSION) and download all of the files from `http://nodejs.org/dist/v<NODE_VERSION>/` It will then loop through the `SHASUMS256.txt` file to check if the SHA256SUMS match up. Initial issue here: #513
1 parent 5aea8f0 commit ba6a9c6

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tools/download-test.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
while [[ $# -gt 1 ]]
4+
do
5+
key="$1"
6+
7+
case $key in
8+
-t|--tap)
9+
TAP="$2"
10+
shift # past argument
11+
;;
12+
*) # unknown option
13+
;;
14+
esac
15+
shift # past argument or value
16+
done
17+
18+
if [ -z ${NODE_VERSION} ]; then
19+
echo "NODE_VERSION is undefined! Please declare NODE_VERSION"
20+
exit 1
21+
fi
22+
# Remove old files
23+
[ ! -z ${TAP} ]; rm -r ${TAP} || true
24+
#rm -r nodejs.org || true
25+
26+
# Scrape the download server
27+
#wget -r --no-parent http://nodejs.org/dist/v${NODE_VERSION}/
28+
29+
num=1
30+
cat nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt | { while read line
31+
do
32+
sha=$(echo "${line}" | awk '{print $1}')
33+
file=$(echo "${line}" | awk '{print $2}')
34+
echo "Checking shasum for $file"
35+
remoteSHA=$(shasum -a 256 "nodejs.org/dist/v${NODE_VERSION}/${file}" | awk '{print $1}')
36+
if [ ${remoteSHA} != ${sha} ]; then
37+
echo "Error - SHASUMS256 does not match for ${file}"
38+
echo "Expected - ${sha}"
39+
echo "Found - ${remoteSHA}"
40+
[ ! -z ${TAP} ]; echo "not ok ${num} SHASUMS256 does not match for ${file}" >> ${TAP}
41+
return 1
42+
else
43+
echo "Pass - SHASUMS256 for ${file} is correct"
44+
[ ! -z ${TAP} ]; echo "ok ${num} SHASUMS256 for ${file} is correct" >> ${TAP}
45+
fi
46+
let num++
47+
done
48+
let num--
49+
[ ! -z ${TAP} ]; echo "1..${num}" >> ${TAP}
50+
}

0 commit comments

Comments
 (0)