[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 7a3a5f6 169/468: Add script to facilitate indenta
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 7a3a5f6 169/468: Add script to facilitate indentation testing |
Date: |
Thu, 5 Aug 2021 04:58:29 -0400 (EDT) |
branch: elpa/lua-mode
commit 7a3a5f6dbe1f20b034a981f97e02e68c701f75be
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
Add script to facilitate indentation testing
---
test/indentation/test_indentation.sh | 77 ++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/test/indentation/test_indentation.sh
b/test/indentation/test_indentation.sh
new file mode 100755
index 0000000..799c98e
--- /dev/null
+++ b/test/indentation/test_indentation.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+
+# This script can be used to test lua-mode indentation engine. For a slightly
+# longer description, run it without parameters and consult the output.
+
+# Need to preserve input arguments, because subshells overwrite them
+declare -a PARAMS
+PARAMS=( "$@" )
+
+set ${EMACS=emacs}
+set ${LUA_MODE=$(dirname $0)/../lua-mode.el}
+
+if [ ${#PARAMS[@]} -eq 0 ]; then
+ cat <<EOF
+Usage: `basename $0` <FILE> [ <FILE> ... ]
+
+Test lua-mode indentation: each FILE is checked to be indented as FILE.etalon.
+The following environment variables are considered:
+
+ - EMACS (default value: emacs)
+ specify emacs version to be run
+
+ - LUA_MODE (default value: $(readlink -m $(dirname $0)/../lua-mode.el))
+ specify location where tested lua-mode.el resides
+EOF
+ exit 1
+fi
+
+# All output will be redirected into ERROR_LOG temporary file to make sure
+# that if everything goes ok, the script will remain silent. In case of an
+# error, ERROR_LOG contents may be retrieved and printed onto the screen.
+ERROR_LOG=`mktemp` || { echo "can't create tempfile"; exit 1; }
+exec 6<>"$ERROR_LOG"
+unlink "$ERROR_LOG"
+ERROR_LOG=/proc/$$/fd/6
+
+OUTPUT=`mktemp` || { echo "can't create temporary output file"; exit 1; }
+exec 7<>"$OUTPUT"
+unlink "$OUTPUT"
+OUTPUT=/proc/$$/fd/7
+
+test_file_indentation() {
+ INPUT="$1"
+ ETALON="$INPUT.etalon"
+
+ echo -n "Testing $INPUT... "
+
+ test -f "$INPUT" || { echo "input file '$INPUT' not exists or not a
file"; return 1; }
+ test -f "$ETALON" || { echo "etalon file '$ETALON' not exists or not a
file"; return 1; }
+
+# run emacs with lua-mode and indent input file
+# disable backup file creation to prevent emacs from trying to write to procfs
+ $EMACS --quick --batch \
+ --load $LUA_MODE \
+ --eval "(setq make-backup-files nil)" \
+ --eval "\
+(progn
+ (find-file \"$INPUT\")
+ (lua-mode)
+ (indent-region (point-min) (point-max))
+ (write-file \"$OUTPUT\"))" \
+ > $ERROR_LOG 2>&1 \
+ || { echo "indentation failed (Emacs log):"; cat <$ERROR_LOG ; return 1;
}
+
+ diff -u $ETALON $OUTPUT >$ERROR_LOG 2>&1 \
+ || { echo "indentation mismatch:"; cat <$ERROR_LOG; return 1; }
+
+ echo OK
+}
+
+FAILED=no
+
+for INPUT in "${PARAMS[@]}"; do
+ test_file_indentation "$INPUT" || FAILED=yes
+done
+
+test "$FAILED" = "no" || exit 1
- [nongnu] elpa/lua-mode 918f297 072/468: rename: lua-calculate-indentation-left-shift -> lua-calculate-unindentation, (continued)
- [nongnu] elpa/lua-mode 918f297 072/468: rename: lua-calculate-indentation-left-shift -> lua-calculate-unindentation, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode cf2f42a 076/468: .gitignore: ignore emacs backups, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9384855 093/468: lua-mark-all-multiline-literals: run when during lua-mode initialization, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6de08c0 090/468: Update TODO, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e3a8282 099/468: Make URL/Version fields in lua-mode.el prettier, update parse expression in Makefile, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1c37d0d 114/468: Bump version, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e17a48c 126/468: Give credit to people participated recently, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode dcf5fc1 138/468: Indentation fixes and tidy up., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3c8cfe6 160/468: Add credit, reformat new code to fit into 77 cols, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6b48a94 165/468: Second part of the fix for #34, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7a3a5f6 169/468: Add script to facilitate indentation testing,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 7f8e519 178/468: Add backward compatibility aliases for cl-assert & cl-labels functions, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e6a46ee 182/468: Update README.md, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4b407cc 203/468: Print 'Prefix key set to ...' only when setting via interactive function, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 88b0ec3 209/468: Fix indentation for blocks starting on continued lines, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 32b5639 210/468: Fix wrong imenu generic expression, add one more regexp to match 'x = function(...)' definitions, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 57d3e46 212/468: lua-mode.el: bump "Version:" field, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c7c8d0c 179/468: Fix bug with lua-mode-syntax-table initialization, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0b4ae97 184/468: Merge branch 'fix-36' of git://github.com/vhallac/lua-mode, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 562540e 073/468: Fix lua-calculate-indentation: indent to 0 when inside string literal, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0f6048d 082/468: Implement lua-mark-all-multiline-literals function, Philip Kaludercic, 2021/08/05