Add spacefmt test to CI
This commit is contained in:
parent
bb70793c75
commit
ca1d3c141a
|
@ -17,6 +17,7 @@ if [ $USER != "travis" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make sure that PR doesn't target master branch
|
||||||
if [ $TRAVIS_SECURE_ENV_VARS = false ] &&
|
if [ $TRAVIS_SECURE_ENV_VARS = false ] &&
|
||||||
[ $TRAVIS_PULL_REQUEST != false ] &&
|
[ $TRAVIS_PULL_REQUEST != false ] &&
|
||||||
[ $TRAVIS_BRANCH = "master" ]; then
|
[ $TRAVIS_BRANCH = "master" ]; then
|
||||||
|
@ -28,12 +29,15 @@ if [ $TRAVIS_SECURE_ENV_VARS = false ] &&
|
||||||
echo "https://github.com/syl20bnr/spacemacs/blob/develop/CONTRIBUTING.org"
|
echo "https://github.com/syl20bnr/spacemacs/blob/develop/CONTRIBUTING.org"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
# Formatting conventions tests
|
||||||
if [ "${FORMATTING}" = "space-test" ]; then
|
if [ ! -z "$FORMATTING" ]; then
|
||||||
cd "${TRAVIS_BUILD_DIR}"
|
cd "${TRAVIS_BUILD_DIR}"
|
||||||
echo "Testing for trailing and all sorts of broken white spaces"
|
|
||||||
echo "TRAVIS_COMMIT_RANGE: ${TRAVIS_COMMIT_RANGE}"
|
echo "TRAVIS_COMMIT_RANGE: ${TRAVIS_COMMIT_RANGE}"
|
||||||
first_commit=`echo ${TRAVIS_COMMIT_RANGE} | sed -r 's/\..*//'`
|
first_commit=`echo ${TRAVIS_COMMIT_RANGE} | sed -r 's/\..*//'`
|
||||||
|
git diff --name-only "${first_commit}" HEAD > /tmp/changed_files
|
||||||
|
case "${FORMATTING}" in
|
||||||
|
space-test)
|
||||||
|
echo "Testing for trailing and all sorts of broken white spaces"
|
||||||
git reset -q "${first_commit}"
|
git reset -q "${first_commit}"
|
||||||
git diff --check --color > space_test_result
|
git diff --check --color > space_test_result
|
||||||
if [[ -s space_test_result ]]; then
|
if [[ -s space_test_result ]]; then
|
||||||
|
@ -42,8 +46,33 @@ if [ "${FORMATTING}" = "space-test" ]; then
|
||||||
fi
|
fi
|
||||||
echo "No bad spaces detected"
|
echo "No bad spaces detected"
|
||||||
exit 0
|
exit 0
|
||||||
|
;;
|
||||||
|
spacefmt)
|
||||||
|
echo "Testing changed files with spacefmt"
|
||||||
|
rm -rf ~/.emacs.d
|
||||||
|
ln -sf `pwd` ~/.emacs.d
|
||||||
|
cp ~/.emacs.d/core/templates/.spacemacs.template ~/
|
||||||
|
mv ~/.spacemacs.template ~/.spacemacs
|
||||||
|
while read p
|
||||||
|
do
|
||||||
|
echo "Checking $p file"
|
||||||
|
./core/tools/spacefmt/spacefmt -f "$p"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "spacefmt exited with $?"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
done </tmp/changed_files
|
||||||
|
git diff --color HEAD > spacefmt_result
|
||||||
|
if [[ -s spacefmt_result ]]; then
|
||||||
|
echo "Please apply these changes:"
|
||||||
|
cat spacefmt_result
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "All changed files comply with spacefmt"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Emacs tests
|
# Emacs tests
|
||||||
|
|
||||||
echo "Pwd $(pwd)"
|
echo "Pwd $(pwd)"
|
||||||
|
|
|
@ -20,6 +20,7 @@ env:
|
||||||
- TESTS=doc EVM_EMACS=emacs-25.1-travis
|
- TESTS=doc EVM_EMACS=emacs-25.1-travis
|
||||||
- TESTS=doc EVM_EMACS=emacs-git-snapshot-travis
|
- TESTS=doc EVM_EMACS=emacs-git-snapshot-travis
|
||||||
- FORMATTING=space-test
|
- FORMATTING=space-test
|
||||||
|
- FORMATTING=spacefmt EVM_EMACS=emacs-25.1-travis
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
# Authors: Eugene Yaremenko and Sylvain Benner
|
# Authors: Eugene Yaremenko and Sylvain Benner
|
||||||
#
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# $1: action name can be `all`, `doc`, `config`
|
# $1: action name can be `all`, `doc`, `config` `-f`
|
||||||
# `doc` formats documentation files
|
# `doc` formats documentation files
|
||||||
# `config` format configuration files
|
# `config` format configuration files
|
||||||
# `all` performs all actions
|
# `all` performs all actions
|
||||||
|
# `-f <FILEPATH>` process FILEPATH file
|
||||||
# $2: if equal to `test` then use test files as input
|
# $2: if equal to `test` then use test files as input
|
||||||
|
|
||||||
# TODO a function to add headers to config.el, packages.el etc...
|
# TODO a function to add headers to config.el, packages.el etc...
|
||||||
|
@ -37,6 +38,38 @@ if hash md5 2>/dev/null; then
|
||||||
mdfive="md5"
|
mdfive="md5"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $1 = "-f" ]]
|
||||||
|
then
|
||||||
|
before_md5="foo"
|
||||||
|
after_md5="bar"
|
||||||
|
while ! [ "$before_md5" = "$after_md5" ]
|
||||||
|
do
|
||||||
|
before_md5=$($mdfive "$2")
|
||||||
|
if [ ${2: -4} == ".org" ]
|
||||||
|
then
|
||||||
|
# Remove trailing delimiters in headlines
|
||||||
|
$seder -i 's/^\(*\+\s\+.*\)[;,.]$/\1/g' "$2"
|
||||||
|
# Remove trailing spaces
|
||||||
|
$seder -i 's/[ \t]*$//' "$2"
|
||||||
|
# Remove #+HTML_HEAD_EXTRA: ... readtheorg.css" />
|
||||||
|
$seder -i '/#+HTML_HEAD_EXTRA.*readtheorg.css.*/d' "$2"
|
||||||
|
# Replace multiply empty lines with a single empty line
|
||||||
|
$seder -i '/^$/N;/^\n$/D' "$2"
|
||||||
|
# Replace :TOC_4_org: with :TOC_4_gh:
|
||||||
|
$seder -i 's/:TOC_4_org:/:TOC_4_gh:/' "$2"
|
||||||
|
# apply toc-org
|
||||||
|
emacs -batch -l ./core/tools/spacefmt/spacefmt.el "$2" -f apply-all
|
||||||
|
fi
|
||||||
|
if [ ${2: -3} == ".el" ]
|
||||||
|
then
|
||||||
|
# migrate packages lists to config.el
|
||||||
|
emacs -batch -l ./core/tools/spacefmt/spacefmt.el "$2" -f move-packages-to-config
|
||||||
|
fi
|
||||||
|
# Calculate md5 of the files in $place after formating
|
||||||
|
after_md5=$($mdfive "$2")
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $2 = "test" ]]
|
if [[ $2 = "test" ]]
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in a new issue