My 1billion row challenge solutions in various languages
at main 1.7 kB view raw
1#!/bin/bash 2# 3# Copyright 2023 The original authors 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17 18set -euo pipefail 19 20DEFAULT_INPUT="src/test/resources/samples/*.txt" 21FORK=${1:-""} 22INPUT=${2:-$DEFAULT_INPUT} 23 24if [ "$#" -eq 0 ] || [ "$#" -gt 2 ] || [ "$FORK" = "-h" ]; then 25 echo "Usage: ./test.sh <fork name> [input file pattern]" 26 echo 27 echo "For each test sample matching <input file pattern> (default '$DEFAULT_INPUT')" 28 echo "runs <fork name> implementation and diffs the result with the expected output." 29 echo "Note that optional <input file pattern> should be quoted if contains wild cards." 30 echo 31 echo "Examples:" 32 echo "./test.sh baseline" 33 echo "./test.sh baseline src/test/resources/samples/measurements-1.txt" 34 echo "./test.sh baseline 'src/test/resources/samples/measurements-*.txt'" 35 exit 1 36fi 37 38if [ -f "./prepare_$FORK.sh" ]; then 39 "./prepare_$FORK.sh" 40fi 41 42for sample in $(ls $INPUT); do 43 echo "Validating calculate_average_$FORK.sh -- $sample" 44 45 rm -f measurements.txt 46 ln -s $sample measurements.txt 47 48 diff --color=always <("./calculate_average_$FORK.sh" | ./tocsv.sh) <(./tocsv.sh < ${sample%.txt}.out) 49done 50 51rm measurements.txt