mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
Add a makefile defining some common tasks.
This makefile makes it easier to run things like unit tests and pylint against the code. Especially before doing a commit. It also helps ensure unit tests are not affected by local config files (e.g., ~/.xonshrc).
This commit is contained in:
parent
0762ff5433
commit
27132bb999
2 changed files with 71 additions and 0 deletions
47
Makefile
Normal file
47
Makefile
Normal file
|
@ -0,0 +1,47 @@
|
|||
SHELL = /bin/sh
|
||||
|
||||
all:
|
||||
@echo "You must specifiy a make target."
|
||||
@echo "Targets are:"
|
||||
@echo " clean"
|
||||
@echo " lint"
|
||||
@echo " lint-all"
|
||||
@echo " test"
|
||||
@echo " test-all"
|
||||
@echo " build-tables"
|
||||
|
||||
clean:
|
||||
rm -f xonsh/lexer_table.py xonsh/parser_table.py
|
||||
rm -f xonsh/lexer_test_table.py xonsh/parser_test_table.py
|
||||
rm -f xonsh/*.pyc tests/*.pyc
|
||||
rm -f xonsh/*.rej tests/*.rej
|
||||
rm -fr build
|
||||
|
||||
# Line just the changed python files. It doesn't matter if "git add" has
|
||||
# already been done but obviously if you've already done "git commit" then
|
||||
# they're no longer consider changed. This should be run (along with "make
|
||||
# test") before commiting a set of changes.
|
||||
lint:
|
||||
pylint $$(git status -s | awk '/\.py$$/ { print $$2 }' | sort)
|
||||
|
||||
# Lint all the python files.
|
||||
lint-all:
|
||||
make clean
|
||||
pylint $$(find tests xonsh -name \*.py | sort)
|
||||
|
||||
# Test just the changed python files. It doesn't matter if "git add" has
|
||||
# already been done but obviously if you've already done "git commit" then
|
||||
# they're no longer consider changed. This should be run (along with "make
|
||||
# lint") before commiting a set of changes.
|
||||
test:
|
||||
scripts/run_tests.sh -e
|
||||
|
||||
# Test all the python files.
|
||||
test-all:
|
||||
scripts/run_tests.sh
|
||||
|
||||
# Build the parser_table.py module. This is normally done by setup.py at
|
||||
# install time. This just makes it easy to create the parser module on the fly
|
||||
# to facilitate development.
|
||||
build-tables:
|
||||
python3 -c 'import setup; setup.build_tables()'
|
24
scripts/run_tests.sh
Normal file
24
scripts/run_tests.sh
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Run all the nosetests or just the ones relevant for the edited files.
|
||||
#
|
||||
if [[ $1 == "-e" ]]; then
|
||||
tmp_file=$(mktemp /tmp/nose_tests_XXXXXX)
|
||||
git status -s |
|
||||
awk '/\.py$/ { print $2 }' |
|
||||
while read f; do
|
||||
if [[ $f == xonsh/* ]]; then
|
||||
f="tests/test_$(basename $f)"
|
||||
if [[ -f $f ]]; then
|
||||
echo $f
|
||||
fi
|
||||
else
|
||||
echo $f
|
||||
fi
|
||||
done |
|
||||
sort -u > $tmp_file
|
||||
XONSHRC=/dev/null nosetests -v $(< $tmp_file)
|
||||
rm $tmp_file
|
||||
else
|
||||
XONSHRC=/dev/null nosetests
|
||||
fi
|
Loading…
Add table
Reference in a new issue