<p>Alex Thiessen has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/23283">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">util/gitconfig/test: Add shellcheck test<br><br>Add a test that runs `shellcheck` on `util/gitconfig/gitconfig.sh`.<br><br>ShellCheck (https://www.shellcheck.net) is a GPLv3 tool that gives<br>warnings and suggestions for bash/sh shell scripts.<br><br>Change-Id: I2792f28e1ce14bb0b3097924eedfe520780ddc49<br>Signed-off-by: Alex Thiessen <alex.thiessen.de+coreboot@gmail.com><br>---<br>A util/gitconfig/test/shellcheck.sh<br>1 file changed, 53 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/83/23283/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/util/gitconfig/test/shellcheck.sh b/util/gitconfig/test/shellcheck.sh</span><br><span>new file mode 100755</span><br><span>index 0000000..983ea44</span><br><span>--- /dev/null</span><br><span>+++ b/util/gitconfig/test/shellcheck.sh</span><br><span>@@ -0,0 +1,53 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/bin/bash</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+## This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+## Copyright (C) 2003-2018 Alex Thiessen <alex.thiessen.de+coreboot@gmail.com></span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+## This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+## it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+## the Free Software Foundation; version 3 or later of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+## This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+## but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+## GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+## SPDX-License-Identifier: GPL-3.0-or-later</span><br><span style="color: hsl(120, 100%, 40%);">+## <https://spdx.org/licenses/GPL-3.0-or-later.html></span><br><span style="color: hsl(120, 100%, 40%);">+##</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+set -o errexit</span><br><span style="color: hsl(120, 100%, 40%);">+set -o nounset</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# statical analysis</span><br><span style="color: hsl(120, 100%, 40%);">+if command -v shellcheck 1>/dev/null; then</span><br><span style="color: hsl(120, 100%, 40%);">+       shellcheck --exclude=1090,1091 \</span><br><span style="color: hsl(120, 100%, 40%);">+              "${BASH_SOURCE[0]}" \</span><br><span style="color: hsl(120, 100%, 40%);">+               "$(dirname "${BASH_SOURCE[0]}")/helpers.sh"</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+ echo "shellcheck not found, running unchecked" >&2</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# dependency check</span><br><span style="color: hsl(120, 100%, 40%);">+dependencies=(shellcheck)</span><br><span style="color: hsl(120, 100%, 40%);">+for dependency in "${dependencies[@]}"; do</span><br><span style="color: hsl(120, 100%, 40%);">+        if ! command -v "${dependency}" 1>/dev/null; then</span><br><span style="color: hsl(120, 100%, 40%);">+                echo "missing ${dependency}, test skipped" >&2</span><br><span style="color: hsl(120, 100%, 40%);">+               exit 0</span><br><span style="color: hsl(120, 100%, 40%);">+        fi</span><br><span style="color: hsl(120, 100%, 40%);">+done</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+source "$(dirname "${BASH_SOURCE[0]}")/helpers.sh"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# setup</span><br><span style="color: hsl(120, 100%, 40%);">+log_file=$(mktemp --tmpdir "test-$(basename "${BASH_SOURCE[0]}" .sh)-XXXXXXXX")</span><br><span style="color: hsl(120, 100%, 40%);">+shellcheck --version >"${log_file}" 2>&1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# test</span><br><span style="color: hsl(120, 100%, 40%);">+shellcheck util/gitconfig/gitconfig.sh >>"${log_file}" 2>&1 \</span><br><span style="color: hsl(120, 100%, 40%);">+      || check_exit_code positive "${log_file}"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# teardown</span><br><span style="color: hsl(120, 100%, 40%);">+rm "${log_file}"</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/23283">change 23283</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/23283"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I2792f28e1ce14bb0b3097924eedfe520780ddc49 </div>
<div style="display:none"> Gerrit-Change-Number: 23283 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alex Thiessen <alex.thiessen.de+coreboot@gmail.com> </div>