Add a shellcheck test, fix or ignore all warnings reported by shellcheck.

This commit is contained in:
Eric Hawicz committed 2026-10-18 20:42:14 -04:00
1 parent 5a79fb68c2
commit 8f191846d5
21 files changed
+157 -88

No files matched your search

+2
View File
@@ -24,6 +24,7 @@ jobs:
- name: Install packages - name: Install packages
run: | run: |
python3 -m pip install meson ninja python3 -m pip install meson ninja
sudo apt install shellcheck
- name: Compile and Test - name: Compile and Test
run: | run: |
@@ -42,6 +43,7 @@ jobs:
- name: Install packages - name: Install packages
run: | run: |
python3 -m pip install meson ninja python3 -m pip install meson ninja
sudo apt install shellcheck
- name: Compile and Test - name: Compile and Test
run: | run: |
+3
View File
@@ -0,0 +1,3 @@
external-sources=true
source-path=reltools
source-path=tests
+5 -1
View File
@@ -11,6 +11,7 @@ matrix:
apt: apt:
packages: packages:
- valgrind - valgrind
- shellcheck
- cppcheck - cppcheck
- doxygen - doxygen
- cmake - cmake
@@ -25,6 +26,7 @@ matrix:
apt: apt:
packages: packages:
- valgrind - valgrind
- shellcheck
- cppcheck - cppcheck
- doxygen - doxygen
- cmake - cmake
@@ -39,6 +41,7 @@ matrix:
apt: apt:
packages: packages:
- valgrind - valgrind
- shellcheck
- cppcheck - cppcheck
- doxygen - doxygen
- cmake - cmake
@@ -66,6 +69,7 @@ matrix:
apt: apt:
packages: packages:
- valgrind - valgrind
- shellcheck
- cppcheck - cppcheck
- doxygen - doxygen
- cmake - cmake
@@ -126,7 +130,7 @@ script:
# when using bionic, Travis seems to ignore the "addons" section, so installing the packages with apt-get... # when using bionic, Travis seems to ignore the "addons" section, so installing the packages with apt-get...
- if [ -n "$CHECK" ]; then - if [ -n "$CHECK" ]; then
if [ "$TRAVIS_DIST" = "bionic" ]; then if [ "$TRAVIS_DIST" = "bionic" ]; then
sudo apt-get install -y valgrind cppcheck doxygen; sudo apt-get install -y valgrind shellcheck cppcheck doxygen;
fi; fi;
make distcheck; make distcheck;
if type cppcheck &> /dev/null ; then cppcheck --error-exitcode=1 --quiet *.h *.c tests/ ; fi; if type cppcheck &> /dev/null ; then cppcheck --error-exitcode=1 --quiet *.h *.c tests/ ; fi;
+11 -11
View File
@@ -23,7 +23,7 @@ usage()
{ {
local exitval="$1" ; shift local exitval="$1" ; shift
local errmsg="$1" local errmsg="$1"
if [ $exitval -ne 0 ] ; then if [ "$exitval" -ne 0 ] ; then
exec 1>&2 exec 1>&2
fi fi
if [ -n "$errmsg" ] ; then if [ -n "$errmsg" ] ; then
@@ -117,9 +117,9 @@ build_new()
if [ ! -d "${BUILD_DEST}" ] || [ "${REBUILD_NEW}" -eq 1 ] ; then if [ ! -d "${BUILD_DEST}" ] || [ "${REBUILD_NEW}" -eq 1 ] ; then
echo "Building $(pwd) (${release}) into ${BUILD_DEST}" echo "Building $(pwd) (${release}) into ${BUILD_DEST}"
rm -rf build.abi-check rm -rf build.abi-check
mkdir -p build.abi-check/${release} mkdir -p "build.abi-check/${release}"
( (
cd build.abi-check/${release} cd "build.abi-check/${release}"
CFLAGS=-Og cmake -DCMAKE_INSTALL_PREFIX="${BUILD_DEST}" ../.. CFLAGS=-Og cmake -DCMAKE_INSTALL_PREFIX="${BUILD_DEST}" ../..
make && make test make && make test
rm -rf "${BUILD_DEST}" rm -rf "${BUILD_DEST}"
@@ -160,7 +160,7 @@ mkxml()
if [ ! -e "${INSTBASE}/json-c-${ver}/lib64" ] ; then if [ ! -e "${INSTBASE}/json-c-${ver}/lib64" ] ; then
ln -s lib "${INSTBASE}/json-c-${ver}/lib64" ln -s lib "${INSTBASE}/json-c-${ver}/lib64"
fi fi
cat <<EOF > json-c-${ver}.xml cat <<EOF > "json-c-${ver}.xml"
<foo> <foo>
<version> <version>
${ver} ${ver}
@@ -186,7 +186,7 @@ abidump()
rm -f "${dumppath}" rm -f "${dumppath}"
fi fi
if [ ! -e "${dumppath}" ] ; then if [ ! -e "${dumppath}" ] ; then
perl "${ACC}" -lib json-c -dump json-c-${libver}.xml -dump-path "${dumppath}" perl "${ACC}" -lib json-c -dump "json-c-${libver}.xml" -dump-path "${dumppath}"
else else
echo "ABI dump already exists at ${dumppath}" echo "ABI dump already exists at ${dumppath}"
fi fi
@@ -200,16 +200,16 @@ build_old
build_new build_new
cd "${REPORTDIR}" cd "${REPORTDIR}"
mkxml ${release} mkxml "${release}"
mkxml ${prev} mkxml "${prev}"
echo "=== Generating ABI dumps ===" echo "=== Generating ABI dumps ==="
abidump ${prev} abidump "${prev}"
abidump ${release} abidump "${release}"
echo "=== Comparing ABIs ===" echo "=== Comparing ABIs ==="
perl "${ACC}" -l json-c -old ABI-${prev}.dump -new ABI-${release}.dump perl "${ACC}" -l json-c -old "ABI-${prev}.dump" -new "ABI-${release}.dump"
perl "${ACC}" -l json-c -old ABI-${prev}.dump -new ABI-${release}.dump -report-format xml perl "${ACC}" -l json-c -old "ABI-${prev}.dump" -new "ABI-${release}.dump" -report-format xml
echo echo
echo "Look in $(pwd)/compat_reports/json-c/${prev}_to_${release}" echo "Look in $(pwd)/compat_reports/json-c/${prev}_to_${release}"
+6 -2
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash
# Cross-build json-c for Amiga systems across every multilib slot and install # Cross-build json-c for Amiga systems across every multilib slot and install
# the archives plus headers into an SDK tree. # the archives plus headers into an SDK tree.
# #
@@ -10,7 +11,7 @@ set -uo pipefail
SDK=${AMIGA_SDK:-/opt/amiga} SDK=${AMIGA_SDK:-/opt/amiga}
AMIGA_DIR=$(cd "$(dirname "$0")" && pwd) AMIGA_DIR=$(cd "$(dirname "$0")" && pwd)
ROOT=$(cd "$AMIGA_DIR/.." && pwd) ROOT=$(cd "$AMIGA_DIR/.." && pwd)
cd "$ROOT" cd "$ROOT" || exit 1
OSES=("$@"); [[ ${#OSES[@]} -eq 0 ]] && OSES=(AmigaOS3 AmigaOS4 MorphOS) OSES=("$@"); [[ ${#OSES[@]} -eq 0 ]] && OSES=(AmigaOS3 AmigaOS4 MorphOS)
# os | image tag | sdk subdir # os | image tag | sdk subdir
@@ -30,6 +31,7 @@ os_sdkdir() { case "$1" in
esac; } esac; }
# Per-OS variant table: "tree|slot|cmake args" # Per-OS variant table: "tree|slot|cmake args"
# shellcheck disable=SC2034 # used in vars nameref, below
variants_AmigaOS3=( variants_AmigaOS3=(
"libnix|.|-DM68K_CRT=nix20 -DM68K_CPU=68000 -DM68K_BASEREL=off" "libnix|.|-DM68K_CRT=nix20 -DM68K_CPU=68000 -DM68K_BASEREL=off"
"libnix|libm020|-DM68K_CRT=nix20 -DM68K_CPU=68020 -DM68K_BASEREL=off" "libnix|libm020|-DM68K_CRT=nix20 -DM68K_CPU=68020 -DM68K_BASEREL=off"
@@ -54,6 +56,7 @@ variants_AmigaOS3=(
# ppc-amigaos -mcrt=clib4 -> <target>/lib/clib4/ # ppc-amigaos -mcrt=clib4 -> <target>/lib/clib4/
# ppc-morphos -mclib=libnix-> <target>/lib/libnix/ # ppc-morphos -mclib=libnix-> <target>/lib/libnix/
# ppc-morphos -mbaserel32 -> <target>/lib/libb32/ # ppc-morphos -mbaserel32 -> <target>/lib/libb32/
# shellcheck disable=SC2034 # used in vars nameref, below
variants_AmigaOS4=( variants_AmigaOS4=(
".|.|-DPPC_CRT=newlib" ".|.|-DPPC_CRT=newlib"
".|clib2|-DPPC_CRT=clib2" ".|clib2|-DPPC_CRT=clib2"
@@ -61,6 +64,7 @@ variants_AmigaOS4=(
) )
# MORPHOS_CLIB=libnix (-mclib=libnix) and NOIXEMUL (-noixemul) select the same # MORPHOS_CLIB=libnix (-mclib=libnix) and NOIXEMUL (-noixemul) select the same
# multilib; it is the self-contained ABI, needing no ixemul.library on target. # multilib; it is the self-contained ABI, needing no ixemul.library on target.
# shellcheck disable=SC2034 # used in vars nameref, below
variants_MorphOS=( variants_MorphOS=(
".|.|" ".|.|"
".|libb32|-DMORPHOS_BASEREL32=ON" ".|libb32|-DMORPHOS_BASEREL32=ON"
@@ -79,7 +83,7 @@ for os in "${OSES[@]}"; do
elif [[ -d $SDK/$osdir/$sdksub ]]; then SDKROOT=$SDK/$osdir/$sdksub elif [[ -d $SDK/$osdir/$sdksub ]]; then SDKROOT=$SDK/$osdir/$sdksub
else echo "skip $os: neither $SDK/$sdksub nor $SDK/$osdir/$sdksub"; continue; fi else echo "skip $os: neither $SDK/$sdksub nor $SDK/$osdir/$sdksub"; continue; fi
eval "vars=(\"\${variants_$os[@]}\")" declare -n vars="variants_${os}" # nameref
for v in "${vars[@]}"; do for v in "${vars[@]}"; do
IFS='|' read -r tree slot cargs <<<"$v" IFS='|' read -r tree slot cargs <<<"$v"
bdir="bld-$os-$(echo "$tree$slot$cargs" | tr -c 'A-Za-z0-9' '-' | cut -c1-40)" bdir="bld-$os-$(echo "$tree$slot$cargs" | tr -c 'A-Za-z0-9' '-' | cut -c1-40)"
+3 -2
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash
# Build every json-c variant for the requested Amiga systems and package them # Build every json-c variant for the requested Amiga systems and package them
# into dist/json-c.lha. # into dist/json-c.lha.
# #
@@ -13,7 +14,7 @@ set -uo pipefail
AMIGA_DIR=$(cd "$(dirname "$0")" && pwd) AMIGA_DIR=$(cd "$(dirname "$0")" && pwd)
ROOT=$(cd "$AMIGA_DIR/.." && pwd) ROOT=$(cd "$AMIGA_DIR/.." && pwd)
cd "$ROOT" cd "$ROOT" || exit 1
DIST=$ROOT/dist DIST=$ROOT/dist
STAGE=$DIST/stage STAGE=$DIST/stage
OSES=("$@"); [[ ${#OSES[@]} -eq 0 ]] && OSES=(AmigaOS3 AmigaOS4 MorphOS) OSES=("$@"); [[ ${#OSES[@]} -eq 0 ]] && OSES=(AmigaOS3 AmigaOS4 MorphOS)
@@ -68,7 +69,7 @@ done
# to refresh a single entry (e.g. the readme) in an existing archive with # to refresh a single entry (e.g. the readme) in an existing archive with
# `lha u` -- it APPENDS a second entry with the same name rather than replacing # `lha u` -- it APPENDS a second entry with the same name rather than replacing
# it, and extraction then yields the stale copy. # it, and extraction then yields the stale copy.
( cd "$STAGE" && lha -aq2 "$DIST/json-c.lha" * >/dev/null ) ( cd "$STAGE" && lha -aq2 "$DIST/json-c.lha" ./* >/dev/null )
rm -rf "$STAGE" rm -rf "$STAGE"
echo echo
echo "packaged: ${built[*]}" echo "packaged: ${built[*]}"
+17 -17
View File
@@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Benchmarking harness for json-c # Benchmarking harness for json-c
# #
@@ -19,17 +19,17 @@ usage()
{ {
exitval=$1 exitval=$1
errmsg=$2 errmsg=$2
if [ $exitval -ne 0 ] ; then if [ "$exitval" -ne 0 ] ; then
exec 1>&2 exec 1>&2
fi fi
if [ ! -z "$errmsg" ] ; then if [ -n "$errmsg" ] ; then
echo "ERROR: $errmsg" 1>&2 echo "ERROR: $errmsg" 1>&2
fi fi
cat <<EOF cat <<EOF
Usage: $0 [-h] [-v] [--build] [--run] [--compare] ...XAX... Usage: $0 [-h] [-v] [--build] [--run] [--compare] ...XAX...
EOF EOF
exit $extival exit "$exitval"
} }
before_arg= before_arg=
@@ -90,18 +90,18 @@ done
echo echo
# Identify "after" commit hash, in order of preference # Identify "after" commit hash, in order of preference
if [ ! -z "$after_arg" -a -d "$after_arg" ] ; then if [ -n "$after_arg" ] && [ "$after_arg" ] ; then
# Use provided directory # Use provided directory
after_src_dir="$after_arg" after_src_dir="$after_arg"
after_commit= after_commit=
echo "Using provided directory [$after_arg] as 'after'" echo "Using provided directory [$after_arg] as 'after'"
else else
_commit= _commit=
if [ ! -z "$after_arg" ] ; then if [ -n "$after_arg" ] ; then
# Use provided commit hash # Use provided commit hash
_commit=$(git rev-parse --verify "$after_arg") _commit=$(git rev-parse --verify "$after_arg")
fi fi
if [ ! -z "$_commit" ] ;then if [ -n "$_commit" ] ;then
after_src_dir= # i.e. current tree after_src_dir= # i.e. current tree
after_commit="$_commit" after_commit="$_commit"
echo "Using provided commit [$after_arg => $_commit] as 'after'" echo "Using provided commit [$after_arg => $_commit] as 'after'"
@@ -115,18 +115,18 @@ else
fi fi
# Identify "before" commit hash, in order of preference # Identify "before" commit hash, in order of preference
if [ ! -z "$before_arg" -a -d "$before_arg" ] ; then if [ -n "$before_arg" ] && [ -d "$before_arg" ] ; then
# Use provided directory # Use provided directory
before_src_dir="$before_arg" before_src_dir="$before_arg"
before_commit= before_commit=
echo "Using provided directory [$before_arg] as 'before'" echo "Using provided directory [$before_arg] as 'before'"
else else
_commit= _commit=
if [ ! -z "$before_arg" ] ; then if [ -n "$before_arg" ] ; then
# Use provided commit hash # Use provided commit hash
_commit=$(git rev-parse --verify "$before_arg") _commit=$(git rev-parse --verify "$before_arg")
fi fi
if [ ! -z "$_commit" ] ;then if [ -n "$_commit" ] ;then
before_src_dir= # i.e. current tree before_src_dir= # i.e. current tree
before_commit="$_commit" before_commit="$_commit"
echo "Using provided commit [$before_arg => $_commit] as 'before'" echo "Using provided commit [$before_arg => $_commit] as 'before'"
@@ -134,7 +134,7 @@ else
# Use origin/${cur_branch}, if different from ${after_commit} # Use origin/${cur_branch}, if different from ${after_commit}
_cur_branch=$(git rev-parse --abbrev-ref HEAD) _cur_branch=$(git rev-parse --abbrev-ref HEAD)
_commit= _commit=
if [ ! -z "${_cur_branch}" ] ; then if [ -n "${_cur_branch}" ] ; then
_commit=$(git rev-parse --verify "origin/${_cur_branch}") _commit=$(git rev-parse --verify "origin/${_cur_branch}")
echo "Using origin/${_cur_branch} [$_commit] as 'before'" echo "Using origin/${_cur_branch} [$_commit] as 'before'"
fi fi
@@ -143,7 +143,7 @@ else
fi fi
fi fi
if [ ! -z "$_commit" ] ; then if [ -n "$_commit" ] ; then
before_src_dir= # i.e. current tree before_src_dir= # i.e. current tree
before_commit="$_commit" before_commit="$_commit"
else else
@@ -174,9 +174,9 @@ compile_benchmark()
mkdir -p "${inst_dir}" mkdir -p "${inst_dir}"
mkdir -p "${bench_dir}" mkdir -p "${bench_dir}"
if [ ! -z "$src_commit" ] ; then if [ -n "$src_commit" ] ; then
# Resolve the short hash, tag or branch name to full hash # Resolve the short hash, tag or branch name to full hash
src_commit=$(git rev-parse $src_commit) src_commit=$(git rev-parse "$src_commit")
fi fi
# No src dir specified, clone and checkout $src_commit # No src dir specified, clone and checkout $src_commit
@@ -213,7 +213,7 @@ compile_benchmark()
# XXX TODO: name "after" and "before" uniquely using the dir & commit # XXX TODO: name "after" and "before" uniquely using the dir & commit
if [ $do_all -ne 0 -o $do_build -ne 0 ] ; then if [ $do_all -ne 0 ] || [ $do_build -ne 0 ] ; then
sleep 5 # Wait slightly, to allow the human to read the message sleep 5 # Wait slightly, to allow the human to read the message
# about what exactly we're doing to benchmark. # about what exactly we're doing to benchmark.
compile_benchmark "after" "${after_src_dir}" "${after_commit}" compile_benchmark "after" "${after_src_dir}" "${after_commit}"
@@ -242,12 +242,12 @@ run_benchmark()
echo "DONE with $bname" echo "DONE with $bname"
} }
if [ $do_all -ne 0 -o $do_run -ne 0 ] ; then if [ "$do_all" -ne 0 ] || [ "$do_run" -ne 0 ] ; then
run_benchmark "after" run_benchmark "after"
run_benchmark "before" run_benchmark "before"
fi fi
if [ $do_compare -ne 0 ] ; then if [ "$do_compare" -ne 0 ] ; then
# XXX this needs better analysis # XXX this needs better analysis
cd "${WORK}" cd "${WORK}"
diff -udr before/bench/results after/bench/results || true diff -udr before/bench/results after/bench/results || true
+10 -10
View File
@@ -20,20 +20,20 @@
mkdir build mkdir build
cd build cd build
cmake -DBUILD_SHARED_LIBS=OFF .. cmake -DBUILD_SHARED_LIBS=OFF ..
make -j$(nproc) make -j"$(nproc)"
LIB=$(pwd)/libjson-c.a LIB=$(pwd)/libjson-c.a
cd .. cd ..
# These seem to be set externally, but let's assign defaults to # These seem to be set externally, but let's assign defaults to
# make it possible to at least partially test this standalone. # make it possible to at least partially test this standalone.
: ${SRC:=$(dirname "$0")} : "${SRC:=$(dirname "$0")}"
: ${OUT:=$SRC/out} : "${OUT:=$SRC/out}"
: ${CXX:=gcc} : "${CXX:=gcc}"
: ${CXXFLAGS:=} : "${CXXFLAGS:=}"
[ -d "$OUT" ] || mkdir "$OUT" [ -d "$OUT" ] || mkdir "$OUT"
cp $SRC/*.dict $OUT/. cp "$SRC/*.dict" "$OUT/."
# XXX this doesn't seem to make much sense, since $SRC is presumably # XXX this doesn't seem to make much sense, since $SRC is presumably
# the "fuzz" directory, which is _inside_ the json-c repo, rather than # the "fuzz" directory, which is _inside_ the json-c repo, rather than
@@ -44,9 +44,9 @@ INCS=$SRC/json-c
set -x set -x
set -v set -v
for f in $SRC/*_fuzzer.cc; do for f in "$SRC"/*_fuzzer.cc; do
fuzzer=$(basename "$f" _fuzzer.cc) fuzzer=$(basename "$f" _fuzzer.cc)
$CXX $CXXFLAGS -std=c++11 -I$INCS \ "$CXX" "$CXXFLAGS" -std=c++11 "-I$INCS" \
$SRC/${fuzzer}_fuzzer.cc -o $OUT/${fuzzer}_fuzzer \ "$SRC/${fuzzer}_fuzzer.cc" -o "$OUT/${fuzzer}_fuzzer" \
-lFuzzingEngine $LIB -lFuzzingEngine "$LIB"
done done
+9 -8
View File
@@ -35,18 +35,20 @@ bump_release_ver()
{ {
echo "ERROR: bump_release_ver() not yet implemented in $0" 1>&2 echo "ERROR: bump_release_ver() not yet implemented in $0" 1>&2
echo "See RELEASE_CHECKLIST.txt for steps to take" 1>&2 echo "See RELEASE_CHECKLIST.txt for steps to take" 1>&2
trap - EXIT return 1
exit 1
} }
bump_dev_ver() bump_dev_ver()
{ {
# Update the working directory to get it ready for the next release.
# This runs just _after_ a release has been done
# shellcheck disable=SC2143
if [ -n "$(git status --porcelain | grep -v reltools/bump_version.sh)" ] ; then if [ -n "$(git status --porcelain | grep -v reltools/bump_version.sh)" ] ; then
usage 1 "local changes in working directory, aborting" usage 1 "local changes in working directory, aborting"
fi fi
RELVER=$(get_most_recent_relver) RELVER=$(get_most_recent_relver)
DEVVER=${RELVER}.99
NEXTVER=$(get_next_relver) NEXTVER=$(get_next_relver)
if ! grep -q "^${NEXTVER}" ChangeLog ; then if ! grep -q "^${NEXTVER}" ChangeLog ; then
@@ -75,7 +77,7 @@ EOF
# Use ${release}.99 to indicate a version "newer" than anything on the branch: # Use ${release}.99 to indicate a version "newer" than anything on the branch:
if ! grep -q ${RELVER}.99 json_c_version.h ; then if ! grep -q "${RELVER}.99" json_c_version.h ; then
local MAJOR MINOR local MAJOR MINOR
MAJOR=${RELVER%%.*} MAJOR=${RELVER%%.*}
MINOR=${RELVER#*.} MINOR=${RELVER#*.}
@@ -100,11 +102,11 @@ EOF
fi fi
local RELTAG local RELTAG
RELTAG=$(get_most_recent_reltag) RELTAG=$(get_most_recent_reltag "")
echo "Extracting VERSION, SOVERSION from ${RELTAG}:CMakeLists.txt" echo "Extracting VERSION, SOVERSION from ${RELTAG}:CMakeLists.txt"
local REL_SOVER REL_SOVERNUM local REL_SOVER REL_SOVERNUM
REL_SOVER=$(git show ${RELTAG}:CMakeLists.txt | awk '/set_target_prop.*PROJECT_NAME/,/)/') REL_SOVER=$(git show "${RELTAG}:CMakeLists.txt" | awk '/set_target_prop.*PROJECT_NAME/,/)/')
REL_VERNUM=$(echo "${REL_SOVER}" | grep " VERSION " | sed -e's/ *VERSION *//' ) REL_VERNUM=$(echo "${REL_SOVER}" | grep " VERSION " | sed -e's/ *VERSION *//' )
REL_SOVERNUM=$(echo "${REL_SOVER}" | grep " SOVERSION " | sed -e's/ *SOVERSION *//' -e's/)//' ) REL_SOVERNUM=$(echo "${REL_SOVER}" | grep " SOVERSION " | sed -e's/ *SOVERSION *//' -e's/)//' )
echo " VERSION=${REL_VERNUM}" echo " VERSION=${REL_VERNUM}"
@@ -157,7 +159,7 @@ EOF
echo "Warning: json-c-sym already has JSONC_${NEXTVER}" 1>&2 echo "Warning: json-c-sym already has JSONC_${NEXTVER}" 1>&2
fi fi
git commit -a -m "Update the master branch to version ${release}.99" git commit -a -m "Update the master branch to version ${RELVER}.99"
} }
while [ $# -gt 0 ] ; do while [ $# -gt 0 ] ; do
@@ -177,7 +179,6 @@ while [ $# -gt 0 ] ; do
;; ;;
*) *)
usage 1 "Unknown args: $*" usage 1 "Unknown args: $*"
exit 1
;; ;;
esac esac
done done
+2
View File
@@ -10,6 +10,8 @@ exitval=0
XMLREPORT="$1" XMLREPORT="$1"
if [[ "${XMLREPORT}" = -* ]] || [ ! -r "${XMLREPORT}" ] ; then if [[ "${XMLREPORT}" = -* ]] || [ ! -r "${XMLREPORT}" ] ; then
echo "Usage: $0 <abireport.xml>" 1>&2
exit 1
fi fi
XSLTPROC=${XSLTPROC:-xsltproc} XSLTPROC=${XSLTPROC:-xsltproc}
+2 -1
View File
@@ -7,7 +7,8 @@ RUNDIR=$(dirname "$0")
NEXT_VER=$(get_next_relver) NEXT_VER=$(get_next_relver)
MOST_RECENT=$(ls ${RUNDIR}/../issues_closed*md | sort -V | tail -1) # shellcheck disable=SC2012 # Using find is overkill
MOST_RECENT=$(ls "${RUNDIR}"/../issues_closed*md | sort -V | tail -1)
PREV=$(grep 'NOW=' "${MOST_RECENT}" | sed -e's/.*=//') PREV=$(grep 'NOW=' "${MOST_RECENT}" | sed -e's/.*=//')
NOW=$(date +%Y-%m-%d) NOW=$(date +%Y-%m-%d)
set -x -v set -x -v
+8 -8
View File
@@ -25,8 +25,8 @@ if [ ! -d "json-c-${release}" ] ; then
git clone https://github.com/json-c/json-c "json-c-${release}" git clone https://github.com/json-c/json-c "json-c-${release}"
fi fi
cd json-c-${release} cd "json-c-${release}"
git checkout ${reltag} git checkout "${reltag}"
if [ ! -e doc/html/index.html ] ; then if [ ! -e doc/html/index.html ] ; then
echo "ERROR: unable to find doc/html/index.html on at version ${reltag} in $(pwd)" 1>&2 echo "ERROR: unable to find doc/html/index.html on at version ${reltag} in $(pwd)" 1>&2
exit 1 exit 1
@@ -38,11 +38,11 @@ if [ ! -d json-c-pages ] ; then
git clone -b gh-pages https://github.com/json-c/json-c json-c-pages git clone -b gh-pages https://github.com/json-c/json-c json-c-pages
fi fi
cd json-c-pages cd json-c-pages
mkdir -p json-c-${release} mkdir -p "json-c-${release}"
cp -R ../json-c-${release}/doc json-c-${release}/. cp -R "../json-c-${release}/doc" "json-c-${release}/."
git add json-c-${release} git add "json-c-${release}"
rm json-c-current-release rm json-c-current-release
ln -s json-c-${release} json-c-current-release ln -s "json-c-${release}" json-c-current-release
git commit -a -m "Add the ${release} docs." git commit -a -m "Add the ${release} docs."
# TODO: automate changes to index.html # TODO: automate changes to index.html
@@ -51,13 +51,13 @@ Steps to do:
* Add section with links to new json-c-${release} release. * Add section with links to new json-c-${release} release.
* Update versions in the "Current release" section * Update versions in the "Current release" section
EOF EOF
read -p "Press <enter> to run vi index.html: " read -r -p "Press <enter> to run vi index.html: "
vi index.html vi index.html
git commit -a -m "Update the doc links to point at ${release}" git commit -a -m "Update the doc links to point at ${release}"
cat <<EOF cat <<EOF
cd $(pwd) cd ${PWD@Q}
git log -n1 --name-status git log -n1 --name-status
git log -n1 -p git log -n1 -p
+5 -4
View File
@@ -1,11 +1,11 @@
rt_RUNDIR=$(dirname "${BASH_SOURCE[0]}") rt_RUNDIR=$(dirname "${BASH_SOURCE[0]}")
rt=RUNDIR=$(realpath "${rt_RUNDIR}") rt_RUNDIR=$(realpath "${rt_RUNDIR}")
JSON_C_TOP=${rt_RUNDIR}/.. JSON_C_TOP=${rt_RUNDIR}/..
get_most_recent_reltag() get_most_recent_reltag()
{ {
local PATTERN="json-c-${1}*" local PATTERN="json-c-${1:-}*"
local RELTAG local RELTAG
RELTAG=$(git tag --list "${PATTERN}" | tail -1) RELTAG=$(git tag --list "${PATTERN}" | tail -1)
echo "${RELTAG}" echo "${RELTAG}"
@@ -46,6 +46,7 @@ get_most_recent_relbase()
echo "${RELBASE}" echo "${RELBASE}"
} }
# shellcheck disable=SC2034
set_rel_vars() set_rel_vars()
{ {
# Set non-local variables for convenience # Set non-local variables for convenience
@@ -59,7 +60,7 @@ set_rel_vars()
# Extract the version from either a release tag, or the dev version + abbreviated commit hash # Extract the version from either a release tag, or the dev version + abbreviated commit hash
get_ver_descr() get_ver_descr()
{ {
local GITDESCR JSON_C_VERS local GIT_DESCR JSON_C_VERS
GIT_DESCR=$(git describe --tags --always) GIT_DESCR=$(git describe --tags --always)
if [[ "$GIT_DESCR" == json-c-* ]] ; then if [[ "$GIT_DESCR" == json-c-* ]] ; then
@@ -75,7 +76,7 @@ get_ver_descr()
update_authors() update_authors()
{ {
PREV=$(get_most_recent_reltag) PREV=$(get_most_recent_reltag)
NEW_AUTHORS=$( git log -r ${PREV}..HEAD | grep Author: | sed -e's/Author: //' ; cat "${JSON_C_TOP}/AUTHORS" ) NEW_AUTHORS=$(git log -r "${PREV}..HEAD" | grep Author: | sed -e's/Author: //' ; cat "${JSON_C_TOP}/AUTHORS" )
echo "${NEW_AUTHORS}" | sort -u > "${JSON_C_TOP}/AUTHORS" echo "${NEW_AUTHORS}" | sort -u > "${JSON_C_TOP}/AUTHORS"
} }
+2 -2
View File
@@ -8,7 +8,7 @@ TOP=${RUNDIR}/..
update_authors() update_authors()
{ {
PREV=$(get_most_recent_reltag) PREV=$(get_most_recent_reltag "")
NEW_AUTHORS=$( git log -r ${PREV}..HEAD | grep Author: | sed -e's/Author: //' ; cat "${TOP}/AUTHORS" ) NEW_AUTHORS=$( git log -r "${PREV}..HEAD" | grep Author: | sed -e's/Author: //' ; cat "${TOP}/AUTHORS" )
echo "${NEW_AUTHORS}" | sort -u > "${TOP}/AUTHORS" echo "${NEW_AUTHORS}" | sort -u > "${TOP}/AUTHORS"
} }
+3 -1
View File
@@ -39,7 +39,9 @@ set(ALL_TEST_NAMES
test_visit test_visit
test_object_iterator) test_object_iterator)
set(NOBUILD_TEST_NAMES "") set(NOBUILD_TEST_NAMES
shellcheck
)
if (BUILD_APPS) if (BUILD_APPS)
set(NOBUILD_TEST_NAMES ${NOBUILD_TEST_NAMES} test_json_parse_cli) set(NOBUILD_TEST_NAMES ${NOBUILD_TEST_NAMES} test_json_parse_cli)
endif() endif()
+15 -1
View File
@@ -8,6 +8,8 @@ test_lib = static_library(
install: false, install: false,
) )
fs = import('fs')
test_deps = declare_dependency( test_deps = declare_dependency(
include_directories: '..', include_directories: '..',
link_with: test_lib, link_with: test_lib,
@@ -15,6 +17,7 @@ test_deps = declare_dependency(
# List of test sources and expected output files # List of test sources and expected output files
test_cases = [ test_cases = [
['shellcheck.test'],
['test1', 'test1.expected'], ['test1', 'test1.expected'],
['test2', 'test2.expected'], ['test2', 'test2.expected'],
['test4', 'test4.expected'], ['test4', 'test4.expected'],
@@ -47,7 +50,9 @@ test_cases = [
# Copy expected files and test data # Copy expected files and test data
expected_files = [] expected_files = []
foreach t : test_cases foreach t : test_cases
if t.length() > 1
expected_files += t[1] expected_files += t[1]
endif
endforeach endforeach
foreach f : expected_files + ['valid.json', 'valid_nested.json', 'json_patch_spec_tests.json', 'json_patch_tests.json'] foreach f : expected_files + ['valid.json', 'valid_nested.json', 'json_patch_spec_tests.json', 'json_patch_tests.json']
@@ -65,15 +70,24 @@ message('Test data directory: ' + testdir)
foreach t : test_cases foreach t : test_cases
name = t[0] name = t[0]
env_expected = []
if t.length() > 1
expected = t[1] expected = t[1]
# XXX does this do anything?
env_expected = ['EXPECTED_FILE=' + meson.current_build_dir() / expected]
endif
if fs.exists(name + '.c')
exe = executable(name, name + '.c', exe = executable(name, name + '.c',
dependencies: test_deps, dependencies: test_deps,
build_by_default: false build_by_default: false
) )
else
exe = find_program(name)
endif
test(name, exe, test(name, exe,
args: special_args.get(name, []), args: special_args.get(name, []),
env: ['EXPECTED_FILE=' + meson.current_build_dir() / expected], env: env_expected,
workdir: testdir workdir: testdir
) )
endforeach endforeach
+33
View File
@@ -0,0 +1,33 @@
#!/bin/sh
#
# Run shellcheck on all shell scripts in the source tree
#
set -e
if ! type shellcheck > /dev/null ; then
echo "$0: SKIPPED, shellcheck not found"
exit 0
fi
if test -z "$srcdir"; then
srcdir="${0%/*}"
test "$srcdir" = "$0" && srcdir=.
test -z "$srcdir" && srcdir=.
fi
: "${VERBOSE:=1}"
. "$srcdir/test-defs.sh"
TOP="$srcdir/.."
cd "$TOP"
if find ./* -name \*.sh -o \
\( -name \*.test -type f \) -print0 | \
xargs -0 shellcheck ; then
echo "$0: SUCCESS"
exit 0
else
echo "$0: FAIL"
exit 1
fi
+18 -17
View File
@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
if [ ! -z "$JSONC_TEST_TRACE" ] ; then if [ -n "$JSONC_TEST_TRACE" ] ; then
VERBOSE=1 VERBOSE=1
set -x set -x
set -v set -v
@@ -10,7 +10,7 @@ fi
# stand-alone!! # stand-alone!!
# #
srcdir=${srcdir-.} srcdir=${srcdir-.}
if test ! -d $srcdir ; then if test ! -d "$srcdir" ; then
echo "test-defs.sh: installation error" 1>&2 echo "test-defs.sh: installation error" 1>&2
exit 1 exit 1
fi fi
@@ -18,18 +18,17 @@ fi
# Use absolute paths # Use absolute paths
case "$srcdir" in case "$srcdir" in
/* | [A-Za-z]:\\*) ;; /* | [A-Za-z]:\\*) ;;
*) srcdir=`\cd $srcdir && pwd` ;; *) srcdir=$(cd "$srcdir" && pwd) ;;
esac esac
case "$top_builddir" in case "$top_builddir" in
/* | [A-Za-z]:\\*) ;; /* | [A-Za-z]:\\*) ;;
*) top_builddir=`\cd ${top_builddir-..} && pwd` ;; *) top_builddir=$(cd "${top_builddir-..}" && pwd) ;;
esac esac
top_builddir=${top_builddir}/tests top_builddir=${top_builddir}/tests
progname=`echo "$0" | sed 's,^.*/,,'` progname=$(echo "$0" | sed 's,^.*/,,')
testname=`echo "$progname" | sed 's,-.*$,,'`
testsubdir=${testsubdir-testSubDir} testsubdir=${testsubdir-testSubDir}
testsubdir=${testsubdir}/${progname} testsubdir=${testsubdir}/${progname}
@@ -64,7 +63,7 @@ case "${use_valgrind}" in
;; ;;
esac esac
valgrind_path=$(which valgrind 2> /dev/null) valgrind_path=$(which valgrind 2> /dev/null)
if [ -z "${valgrind_path}" -o ! -x "${valgrind_path}" ] ; then if [ -z "${valgrind_path}" ] || [ ! -x "${valgrind_path}" ] ; then
use_valgrind=0 use_valgrind=0
fi fi
@@ -99,11 +98,12 @@ run_output_test()
fi fi
REDIR_OUTPUT="> \"${TEST_OUTPUT}.out\" 2>&1" REDIR_OUTPUT="> \"${TEST_OUTPUT}.out\" 2>&1"
if [ $VERBOSE -gt 1 ] ; then if [ "$VERBOSE" -gt 1 ] ; then
REDIR_OUTPUT="2>&1 | tee \"${TEST_OUTPUT}.out\"" REDIR_OUTPUT="2>&1 | tee \"${TEST_OUTPUT}.out\""
fi fi
if [ $use_valgrind -eq 1 ] ; then local exitval
if [ "$use_valgrind" -eq 1 ] ; then
eval valgrind --tool=memcheck \ eval valgrind --tool=memcheck \
--trace-children=yes \ --trace-children=yes \
--demangle=yes \ --demangle=yes \
@@ -111,20 +111,21 @@ run_output_test()
--leak-check=full \ --leak-check=full \
--show-reachable=yes \ --show-reachable=yes \
--run-libc-freeres=yes \ --run-libc-freeres=yes \
"\"${top_builddir}/${TEST_COMMAND}\"" \"\$@\" ${REDIR_OUTPUT} "\"${top_builddir}/${TEST_COMMAND}\" \"\$@\" ${REDIR_OUTPUT}"
exitval=$? exitval=$?
else else
eval "\"${top_builddir}/${TEST_COMMAND}"\" \"\$@\" ${REDIR_OUTPUT} eval "\"${top_builddir}/${TEST_COMMAND}\" \"\$@\" ${REDIR_OUTPUT}"
exitval=$? exitval=$?
fi fi
if [ $exitval -ne $EXPECTED_EXITVAL ] ; then local err=0
echo "ERROR: \"${TEST_COMMAND} $@\" exited with incorrect exit status: $err != $EXPECTED_EXITVAL" 1>&2 if [ "$exitval" -ne "$EXPECTED_EXITVAL" ] ; then
echo "ERROR: \"${TEST_COMMAND} $*\" exited with incorrect exit status: $err != $EXPECTED_EXITVAL" 1>&2
err=1 err=1
fi fi
if [ $use_valgrind -eq 1 ] ; then if [ "$use_valgrind" -eq 1 ] ; then
if ! tail -1 "${TEST_OUTPUT}.vg.out" | grep -q "ERROR SUMMARY: 0 errors" ; then if ! tail -1 "${TEST_OUTPUT}.vg.out" | grep -q "ERROR SUMMARY: 0 errors" ; then
echo "ERROR: valgrind found errors during execution:" 1>&2 echo "ERROR: valgrind found errors during execution:" 1>&2
cat "${TEST_OUTPUT}.vg.out" cat "${TEST_OUTPUT}.vg.out"
@@ -133,12 +134,12 @@ run_output_test()
fi fi
if ! "$CMP" -s "${srcdir}/${TEST_OUTPUT}.expected" "${TEST_OUTPUT}.out" ; then if ! "$CMP" -s "${srcdir}/${TEST_OUTPUT}.expected" "${TEST_OUTPUT}.out" ; then
echo "ERROR: \"${TEST_COMMAND} $@\" (${TEST_OUTPUT}) failed (set VERBOSE=1 to see full output):" 1>&2 echo "ERROR: \"${TEST_COMMAND} $*\" (${TEST_OUTPUT}) failed (set VERBOSE=1 to see full output):" 1>&2
(cd "${CURDIR}" ; set -x ; diff "${srcdir}/${TEST_OUTPUT}.expected" "$testsubdir/${TEST_OUTPUT}.out") (cd "${CURDIR}" && set -x && diff "${srcdir}/${TEST_OUTPUT}.expected" "$testsubdir/${TEST_OUTPUT}.out")
echo "cp \"$testsubdir/${TEST_OUTPUT}.out\" \"${srcdir}/${TEST_OUTPUT}.expected\"" 1>&2 echo "cp \"$testsubdir/${TEST_OUTPUT}.out\" \"${srcdir}/${TEST_OUTPUT}.expected\"" 1>&2
err=1 err=1
fi fi
return $err return "$err"
} }
+1 -1
View File
@@ -17,5 +17,5 @@ filename="${filename%.*}"
# more stuff could be extended # more stuff could be extended
cp -f "$srcdir/valid.json" . cp -f "$srcdir/valid.json" .
run_output_test $filename "$srcdir" run_output_test "$filename" "$srcdir"
exit $? exit $?
+1 -1
View File
@@ -13,5 +13,5 @@ fi
filename=$(basename "$0") filename=$(basename "$0")
filename="${filename%.*}" filename="${filename%.*}"
run_output_test $filename "$srcdir" run_output_test "$filename" "$srcdir"
exit $? exit $?
+1 -1
View File
@@ -11,5 +11,5 @@ fi
filename=$(basename "$0") filename=$(basename "$0")
filename="${filename%.*}" filename="${filename%.*}"
run_output_test $filename run_output_test "$filename"
exit $? exit $?