Skip to content

Commit

Permalink
GitHub Action setup (#15)
Browse files Browse the repository at this point in the history
* GitHub Action setup
* Undo variable substitution that got into ".in"
* Add message to assertion to debug failing tests
* Run unit tests in isolation to avoid side-effects
* Don't compare unstable highlighting of Pygments, but only the file locations
  • Loading branch information
jansorg authored Feb 14, 2024
1 parent b4cd90c commit edea0ef
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 21 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "bashdb CI"
on:
push:

jobs:
linux:
name: "Linux"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Packages
shell: bash
run: |+
sudo apt -y update
sudo apt -y install autoconf automake texinfo
- name: Configure
shell: bash
run: sh ./autogen.sh

- name: Test
shell: bash
env:
VERBOSE: 1
run: make -e -j3 check
2 changes: 1 addition & 1 deletion test/example/bug-loc.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Bug is that file cache highlight isn't updated when when
# Bug is that file cache highlight isn't updated when
# it is already cached so it continues to refer to a line in the source'd file
# rather than file it was source'd from (here it is this file).
dirname=${BASH_SOURCE%/*} # equivalent to dirname($0)
Expand Down
16 changes: 15 additions & 1 deletion test/integration/test-bug-loc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@ debugged_script="$top_srcdir/test/example/bug-loc.sh"

if ( pygmentize --version || pygmentize -V ) 2>/dev/null 1>/dev/null ; then
run_debugger_opts="-B -q --no-init --highlight=light"
run_test_check $TEST_NAME $TEST_NAME $debugged_script
(cd $srcdir && run_debugger "$debugged_script" 2>&1 >"$TEST_FILE" </dev/null)

# We're removing highlighted lines because Pygments is often changing the highlighting
/usr/bin/grep -v -E "^[0-9]+:"$'\t' "$TEST_FILE" >"${TEST_FILTERED_FILE}"
/usr/bin/grep -v -E "^[0-9]+:"$'\t' "$RIGHT_FILE" >"${RIGHT_FILTERED_FILE}"

check_output "$TEST_FILTERED_FILE" "$RIGHT_FILTERED_FILE"
rc=$?
if ((0 == rc)) ; then
rm -f $TEST_FILTERED_FILE
rm -f $RIGHT_FILTERED_FILE
fi

# Return code tells testing mechanism whether passed or not.
exit $rc
else
exit 77
fi
2 changes: 2 additions & 0 deletions test/unit/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*~
/*.trs
/*.log
/Makefile
/Makefile.in
/require_me.sh
Expand Down
49 changes: 37 additions & 12 deletions test/unit/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,27 +1,52 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
COMBINED_TESTS = $(wildcard test-*.sh)
tests_sources = $(notdir $(COMBINED_TESTS:=.in))

# Don't forget to add the *.in files of new tests to configure.ac in the root folder
TESTS = test-action.sh \
test-alias.sh \
test-bashdb-trace.sh \
test-break.sh \
test-cmd-complete.sh \
test-cmd-eval.sh \
test-cmd-info-variables.sh \
test-columns.sh \
test-filecache.sh \
test-file.sh \
test-fns.sh \
test-frame.sh \
test-get-sourceline.sh \
test-io.sh \
test-lib-eval.sh \
test-lib-list.sh \
test-logging.sh \
test-msg.sh \
test-pre.sh \
test-require.sh \
test-run.sh \
test-save-restore.sh \
test-sort.sh \
test-validate.sh

tests_sources = $(notdir $(TESTS:=.in))

abs_srcdir=@abs_srcdir@
abs_builddir=@abs_builddir@

TESTS_ENVIRONMENT = \
srcdir="$(abs_srcdir)" \
builddir="$(abs_builddir)"
AM_TESTS_ENVIRONMENT = \
srcdir="$(abs_srcdir)"; \
builddir="$(abs_builddir)"; \
export srcdir builddir;
LOG_COMPILER = $(SH_PROG)
AM_LOG_FLAGS = $(abs_srcdir)/shunit2 \
$(abs_srcdir)/helper.sh $(abs_srcdir)/mock-cmd.sh \
$(abs_srcdir)/require_me.sh

EXTRA_DIST = \
helper.sh \
mock-cmd.sh \
require_me.sh \
require_me.sh.in $(COMBINED_TESTS) shunit2 $(tests_sources)
require_me.sh.in $(TESTS) shunit2 $(tests_sources)

test: check
test-unit: check

check: $(COMBINED_TESTS)
$(SH_PROG) $(abs_srcdir)/shunit2 \
$(abs_srcdir)/helper.sh $(abs_srcdir)/mock-cmd.sh \
$(abs_srcdir)/require_me.sh \
$(COMBINED_TESTS)

MOSTLYCLEANFILES = *.orig *.rej
15 changes: 8 additions & 7 deletions test/unit/test-cmd-info-variables.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ test_cmd_info_variables()
fi
done

assertEquals "1" "$found"
assertEquals "0" "$too_permissive"
assertEquals "Filtering with -i must show integer variables" "1" "$found"
assertEquals "Filtering with -i must hide non-integer variables" "0" "$too_permissive"

found=0
too_permissive=0
Expand All @@ -27,16 +27,17 @@ test_cmd_info_variables()
fi
done

assertEquals "1" "$found"
assertEquals "0" "$too_permissive"
assertEquals "Filtering with -x must show exported variables" "1" "$found"
assertEquals "Filtering with -x must hide unexported variables" "0" "$too_permissive"
# FIXME try -x -i, and no options. try invalid opts
}

if [ '/src/external-vcs/sourceforge/bashdb' = '' ] ; then
echo "Something is wrong: abs_top_srcdir is not set."
abs_top_srcdir=@abs_top_srcdir@
if [ ! -d $abs_top_scrdir ] ; then
>&2 echo "Something is wrong in configuation: abs_top_srcdir is not set properly."
exit 1
fi
abs_top_srcdir=/src/external-vcs/sourceforge/bashdb

# Make sure $abs_top_src has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
Expand Down

0 comments on commit edea0ef

Please sign in to comment.