[coreboot-gerrit] Change in coreboot[master]: util/gitconfig/test: Add shellcheck test

Alex Thiessen (Code Review) gerrit at coreboot.org
Tue Jan 16 00:47:01 CET 2018


Alex Thiessen has uploaded this change for review. ( https://review.coreboot.org/23283


Change subject: util/gitconfig/test: Add shellcheck test
......................................................................

util/gitconfig/test: Add shellcheck test

Add a test that runs `shellcheck` on `util/gitconfig/gitconfig.sh`.

ShellCheck (https://www.shellcheck.net) is a GPLv3 tool that gives
warnings and suggestions for bash/sh shell scripts.

Change-Id: I2792f28e1ce14bb0b3097924eedfe520780ddc49
Signed-off-by: Alex Thiessen <alex.thiessen.de+coreboot at gmail.com>
---
A util/gitconfig/test/shellcheck.sh
1 file changed, 53 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/83/23283/1

diff --git a/util/gitconfig/test/shellcheck.sh b/util/gitconfig/test/shellcheck.sh
new file mode 100755
index 0000000..983ea44
--- /dev/null
+++ b/util/gitconfig/test/shellcheck.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2003-2018 Alex Thiessen <alex.thiessen.de+coreboot at gmail.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; version 3 or later of the License.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## SPDX-License-Identifier: GPL-3.0-or-later
+## <https://spdx.org/licenses/GPL-3.0-or-later.html>
+##
+
+set -o errexit
+set -o nounset
+
+# statical analysis
+if command -v shellcheck 1>/dev/null; then
+	shellcheck --exclude=1090,1091 \
+		"${BASH_SOURCE[0]}" \
+		"$(dirname "${BASH_SOURCE[0]}")/helpers.sh"
+else
+	echo "shellcheck not found, running unchecked" >&2
+fi
+
+# dependency check
+dependencies=(shellcheck)
+for dependency in "${dependencies[@]}"; do
+	if ! command -v "${dependency}" 1>/dev/null; then
+		echo "missing ${dependency}, test skipped" >&2
+		exit 0
+	fi
+done
+
+source "$(dirname "${BASH_SOURCE[0]}")/helpers.sh"
+
+# setup
+log_file=$(mktemp --tmpdir "test-$(basename "${BASH_SOURCE[0]}" .sh)-XXXXXXXX")
+shellcheck --version >"${log_file}" 2>&1
+
+# test
+shellcheck util/gitconfig/gitconfig.sh >>"${log_file}" 2>&1 \
+	|| check_exit_code positive "${log_file}"
+
+# teardown
+rm "${log_file}"

-- 
To view, visit https://review.coreboot.org/23283
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2792f28e1ce14bb0b3097924eedfe520780ddc49
Gerrit-Change-Number: 23283
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Thiessen <alex.thiessen.de+coreboot at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180115/cc7e3351/attachment-0001.html>


More information about the coreboot-gerrit mailing list