Commit b77bcfc6 authored by Matthias Simon's avatar Matthias Simon
Browse files

Simplify scripts

parent c17c419c
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ before_script:
format-check:
  stage: test
  script:
    - ./build-aux/check-consistency
    - ./build-aux/tidy-tests
    - if ! git diff --quiet; echo "ATS is not tidied. Please run ./build-aux/tidy-tests locally and verify. Thanks."; exit 1; fi
    - |
      if ! ./build-aux/format-and-check || ! git diff --quiet; then
        echo "Please run ./build-aux/format-and-check locally and fix issues. Thanks."
        exit 1
      fi
+22 −2
Original line number Diff line number Diff line
#!/bin/bash -e
#
# check-consistency verifies that ATS is consistent and well formed. It does
# not modify any files.
# format-and-check perform various cleanup and checks on the ATS.

errors=0

@@ -11,6 +10,26 @@ function error() {
	echo 1>&2 "error: $@"
}


echo "Removing dot-files..."
find ATS -name ".*" | xargs rm -rfv

echo "Fixing permissions..."
find ATS -type f | xargs chmod 664
find ATS -type d | xargs chmod 775

echo "Looking for unknown file types..."
while IFS= read -r -d $'\0' file; do
	error "unknown file type: $file"
done < <(find ATS -type f ! -name "*.xml" -a ! -name "*.xsd" -a ! -name "*.ttcn" -a -name "*.json" -a -name "NOTES")

echo "Converting Windows line endings to Unix..."
find ATS -type f -name \*.ttcn | xargs dos2unix -q

echo "Removing trailing whitespace"
find ATS -type f -name \*.ttcn | xargs sed -i 's/[[:space:]]*$//'

echo "Linting TTCN-3 files..."
while IFS= read -r -d $'\0' file; do
	name=$(basename $file .ttcn)

@@ -30,6 +49,7 @@ while IFS= read -r -d $'\0' file; do

done < <(find ATS -type f -name \*.ttcn -print0)

echo "Done."
if [[ $errors -gt 0 ]]; then
	echo "Found $errors errors"
	exit 1

build-aux/tidy-tests

deleted100755 → 0
+0 −18
Original line number Diff line number Diff line
#!/bin/bash -e
# tidy-tests performs various cleanups on the test suite.

: "Remove dot-files"
find ATS -name ".*" | xargs rm -rfv

: "Fix permissions"
find ATS -type f | xargs chmod 664
find ATS -type d | xargs chmod 775

: "Warn about unknown file types"
find ATS -type f ! -name "*.xml" -a ! -name "*.xsd" -a ! -name "*.ttcn" -a -name "*.json" -a -name "NOTES"

: "TTCN-3: Convert Windows line endings to Unix"
find ATS -type f -name \*.ttcn | xargs dos2unix -q

: "TTCN-3: Remove trailing whitespace"
find ATS -type f -name \*.ttcn | xargs sed -i 's/[[:space:]]*$//'