Skip to content

Commit

Permalink
Add bash intro test
Browse files Browse the repository at this point in the history
Signed-off-by: Bolun Thompson <[email protected]>
  • Loading branch information
BolunThompson committed Jan 27, 2025
1 parent c6dbe32 commit 16bf931
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions evaluation/intro/hello-world-bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# uses bashisms to demonstrate pa.sh bash support

[[ $(uname) = 'Darwin' ]] && a=/usr/share/dict/web2 || a=/usr/share/dict/words

pattern=('\(.\).*\1\(.\).*\2\(.\).*\3\(.\).*\4')

if [[ -f $a ]]; then
cat "$a"{,,,,,,,,} | grep "${pattern[@]}" | wc -l
else
echo "Dictionary file $a not found.."
fi

4 changes: 3 additions & 1 deletion evaluation/intro/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ mkdir -p "$output_dir"
run_test()
{
local test=$1
local args="$2"
echo -n "Running $test..."
TIMEFORMAT="${test%%.*}:%3R" # %3U %3S"
{ time $bash "$test" > "$output_dir/$test.bash.out"; } 2> >(tee -a $output_dir/results.time_bash)
test_bash_ec=$?
TIMEFORMAT="%3R" # %3U %3S"
{ time $pash "$test" > "$output_dir/$test.pash.out"; } 2> >(tee -a $output_dir/results.time_pash)
{ time $pash $args "$test" > "$output_dir/$test.pash.out"; } 2> >(tee -a $output_dir/results.time_pash)
test_pash_ec=$?
diff "$output_dir/$test.bash.out" "$output_dir/$test.pash.out"
test_diff_ec=$?
Expand Down Expand Up @@ -59,6 +60,7 @@ run_test()

run_test "demo-spell.sh"
run_test "hello-world.sh"
run_test "hello-world-bash.sh" "--bash"

if type lsb_release >/dev/null 2>&1 ; then
distro=$(lsb_release -i -s)
Expand Down

0 comments on commit 16bf931

Please sign in to comment.