diff --git a/Dockerfile b/Dockerfile index 5ecfd08..ce50460 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,8 @@ COPY LICENSE Setup.hs shellcheck.hs ./ COPY src src RUN cabal build Paths_ShellCheck && \ ghc -optl-static -optl-pthread -isrc -idist/build/autogen --make shellcheck -split-sections -optc-Wl,--gc-sections -optlo-Os && \ - strip --strip-all shellcheck + strip --strip-all shellcheck && \ + ls -l shellcheck RUN mkdir -p /out/bin && \ cp shellcheck /out/bin/ diff --git a/striptests b/striptests index 78c5220..cef3f49 100755 --- a/striptests +++ b/striptests @@ -1,57 +1,12 @@ #!/usr/bin/env bash -# This file strips all unit tests from ShellCheck, removing +# This file *stripped* all unit tests from ShellCheck, removing # the dependency on QuickCheck and Template Haskell and # reduces the binary size considerably. +# +# Currently it only checks that run from right directory and +# there aren't local git changes set -o pipefail -sponge() { - data="$(cat)" - printf '%s\n' "$data" > "$1" -} - -modify() { - if ! "${@:2}" < "$1" | sponge "$1" - then - { - printf 'Failed to modify %s: ' "$1" - printf '%q ' "${@:2}" - printf '\n' - } >&2 - exit 1 - fi -} - -detestify() { - echo "-- AUTOGENERATED from ShellCheck by striptests. Do not modify." - awk ' - BEGIN { - state = 0; - } - - /LANGUAGE TemplateHaskell/ { next; } - /^import.*Test\./ { next; } - - /^module/ { - sub(/,[^,)]*runTests/, ""); - } - - # Delete tests - /^prop_/ { state = 1; next; } - - # ..and any blank lines following them. - state == 1 && /^ / { next; } - - # Template Haskell marker - /^return / { - exit; - } - - { state = 0; print; } - ' -} - - - if [[ ! -e ShellCheck.cabal ]] then echo "Run me from the ShellCheck directory." >&2 @@ -63,15 +18,3 @@ then echo "You have local changes! These may be overwritten." >&2 exit 2 fi - -modify ShellCheck.cabal sed -e ' - /QuickCheck/d - /^test-suite/{ s/.*//; q; } - ' - -find . -name '.git' -prune -o -type f -name '*.hs' -print | - while IFS= read -r file - do - modify "$file" detestify - done -