Skip to content

Commit

Permalink
tools: add download testing
Browse files Browse the repository at this point in the history
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
  • Loading branch information
George Adams committed Jul 19, 2017
1 parent 5aea8f0 commit ba6a9c6
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tools/download-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

while [[ $# -gt 1 ]]
do
key="$1"

case $key in
-t|--tap)
TAP="$2"
shift # past argument
;;
*) # unknown option
;;
esac
shift # past argument or value
done

if [ -z ${NODE_VERSION} ]; then
echo "NODE_VERSION is undefined! Please declare NODE_VERSION"
exit 1
fi
# Remove old files
[ ! -z ${TAP} ]; rm -r ${TAP} || true
#rm -r nodejs.org || true

# Scrape the download server
#wget -r --no-parent http://nodejs.org/dist/v${NODE_VERSION}/

num=1
cat nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt | { while read line
do
sha=$(echo "${line}" | awk '{print $1}')
file=$(echo "${line}" | awk '{print $2}')
echo "Checking shasum for $file"
remoteSHA=$(shasum -a 256 "nodejs.org/dist/v${NODE_VERSION}/${file}" | awk '{print $1}')
if [ ${remoteSHA} != ${sha} ]; then
echo "Error - SHASUMS256 does not match for ${file}"
echo "Expected - ${sha}"
echo "Found - ${remoteSHA}"
[ ! -z ${TAP} ]; echo "not ok ${num} SHASUMS256 does not match for ${file}" >> ${TAP}
return 1
else
echo "Pass - SHASUMS256 for ${file} is correct"
[ ! -z ${TAP} ]; echo "ok ${num} SHASUMS256 for ${file} is correct" >> ${TAP}
fi
let num++
done
let num--
[ ! -z ${TAP} ]; echo "1..${num}" >> ${TAP}
}

0 comments on commit ba6a9c6

Please sign in to comment.