Skip to content

Commit

Permalink
Script to validate test cases against the problem specifications. (#450)
Browse files Browse the repository at this point in the history
* Script to validate test cases against the problem specifications.
Identifies test cases from the problem spec canonical data that are unimplemented.

* No need to reimplement what the canonical-data-syncer does

* canonical-data-syncer requires config.json to be in good shape
  • Loading branch information
glennj authored Oct 20, 2020
1 parent 77051b2 commit 6371ed9
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin/configlet
bin/configlet.exe
bin/canonical_data_syncer
10 changes: 10 additions & 0 deletions bin/check_test_cases
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
die() { echo "$*" >&2; exit 1; }

cd "$(dirname "$0")"/.. || die "cannot cd"

bin/fetch_configlet || die "cannot fetch configlet"
bin/configlet lint . || die "resolve config.json problems first"

bin/fetch-canonical_data_syncer || die "cannot fetch canonical_data_syncer"
bin/canonical_data_syncer --check "$@"
52 changes: 52 additions & 0 deletions bin/fetch-canonical_data_syncer
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

set -eo pipefail

readonly LATEST='https://api.github.com/repos/exercism/canonical-data-syncer/releases/latest'

case "$(uname)" in
(Darwin*) OS='mac' ;;
(Linux*) OS='linux' ;;
(Windows*) OS='windows' ;;
(MINGW*) OS='windows' ;;
(MSYS_NT-*) OS='windows' ;;
(*) OS='linux' ;;
esac

case "$OS" in
(windows*) EXT='zip' ;;
(*) EXT='tgz' ;;
esac

case "$(uname -m)" in
(*64*) ARCH='64bit' ;;
(*686*) ARCH='32bit' ;;
(*386*) ARCH='32bit' ;;
(*) ARCH='64bit' ;;
esac

if [ -z "${GITHUB_TOKEN}" ]
then
HEADER=''
else
HEADER="authorization: Bearer ${GITHUB_TOKEN}"
fi

FILENAME="canonical_data_syncer-${OS}-${ARCH}.${EXT}"

get_url () {
curl --header "$HEADER" -s "$LATEST" |
awk -v filename=$FILENAME '$1 ~ /browser_download_url/ && $2 ~ filename { print $2 }' |
tr -d '"'
}

URL=$(get_url)

case "$EXT" in
(*zip)
curl --header "$HEADER" -s --location "$URL" -o bin/latest-canonical_data_syncer.zip
unzip bin/latest-canonical_data_syncer.zip -d bin/
rm bin/latest-canonical_data_syncer.zip
;;
(*) curl --header "$HEADER" -s --location "$URL" | tar xz -C bin/ ;;
esac

0 comments on commit 6371ed9

Please sign in to comment.