aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEllis KenyƑ <elken@users.noreply.github.com>2022-05-12 20:52:57 +0100
committerGitHub <noreply@github.com>2022-05-12 12:52:57 -0700
commitb5dbab53eadf64529a0bfe217c7750f1d7d85fce (patch)
tree934f0d154fe24df648043a7768a5739075830063 /test
parent982df5a2e0c1695e87069b1e4a54ed90d7b2026c (diff)
Add shfmt (#90)
* feat: add shfmt Add support for shfmt * Handle multiple architectures Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/formatters/install-common.bash2
-rw-r--r--test/formatters/installers/shfmt.bash21
-rw-r--r--test/formatters/samplecode/shfmt/in.bash2
-rw-r--r--test/formatters/samplecode/shfmt/out.bash3
4 files changed, 27 insertions, 1 deletions
diff --git a/test/formatters/install-common.bash b/test/formatters/install-common.bash
index 2e812a2..c073ffc 100755
--- a/test/formatters/install-common.bash
+++ b/test/formatters/install-common.bash
@@ -4,7 +4,7 @@ set -euxo pipefail
export DEBIAN_FRONTEND=noninteractive
apt-get update
-apt-get install -y curl gnupg lsb-release
+apt-get install -y ca-certificates curl gnupg lsb-release
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
diff --git a/test/formatters/installers/shfmt.bash b/test/formatters/installers/shfmt.bash
new file mode 100644
index 0000000..c42b030
--- /dev/null
+++ b/test/formatters/installers/shfmt.bash
@@ -0,0 +1,21 @@
+ver="$(latest_release mvdan/sh)"
+
+arch="$(uname -m)"
+case "${arch}" in
+ "x86_64")
+ arch="amd64"
+ ;;
+ "i386")
+ arch="386"
+ ;;
+ "aarch64")
+ arch="arm64"
+ ;;
+ *)
+ echo >&2 "unsupported architecture: ${arch}"
+ exit 1
+ ;;
+esac
+
+wget "https://github.com/mvdan/sh/releases/download/${ver}/shfmt_${ver}_linux_${arch}" -O /usr/local/bin/shfmt
+chmod +x /usr/local/bin/shfmt
diff --git a/test/formatters/samplecode/shfmt/in.bash b/test/formatters/samplecode/shfmt/in.bash
new file mode 100644
index 0000000..f2f768b
--- /dev/null
+++ b/test/formatters/samplecode/shfmt/in.bash
@@ -0,0 +1,2 @@
+function f(){
+ thing;}
diff --git a/test/formatters/samplecode/shfmt/out.bash b/test/formatters/samplecode/shfmt/out.bash
new file mode 100644
index 0000000..a5903da
--- /dev/null
+++ b/test/formatters/samplecode/shfmt/out.bash
@@ -0,0 +1,3 @@
+function f() {
+ thing
+}