Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit 52f5d68e authored by Ryan Thompson's avatar Ryan Thompson

Merge pull request #635 from DarwinAwardWinner/test-improvements

Test improvements
parents 8f32acb5 4ce49b07
......@@ -7,20 +7,67 @@ Like, yes, we have some! :)
Tries to cover some known issues, example that will allow building a
regression test suite some day.
Typical run:
Typical run (in bash):
mkdir -p /tmp/test/.emacs.d
rm -rf /tmp/test/.emacs.d/el-get/
HOME=/tmp/test /usr/bin/emacs-snapshot-gtk -Q -batch -L . -l test/el-get-issue-303.el
HOME=/tmp/test /usr/bin/emacs-snapshot-gtk -Q -batch -L . -l el-get \
-l test/el-get-issue-303.el
At the moment you need to run the el-get-issue scripts with some known
working el-get version to know what to expect, and you probably need to have
el-get installed at +~/dev/emacs/el-get/+ for this to work as-is.
working el-get version to know what to expect, and you probably need
to have el-get installed at +~/dev/emacs/el-get/+ for this to work
as-is.
Yet it might be useful.
== el-get automated tests
=== Simple script-based automation
In the test directory, there is a simple bash script called
+run-test.sh+ that attempts to automate the manual steps detailed
above. The script creates a temporary home directory and runs emacs in
batch mode, first loading el-get and then the specified test file. An invocation equivalent to the above would look like this (starting from the main el-get directory):
test/run-test.sh el-get-issue-303.el
or even just
test/run-test.sh 303
The script takes care of cleaning up the temporary directory after the
test, so you can run tests one after the other without previous tests
causing problems for later ones. The bahavior of the +run-test.sh+ script can be customized with a few environment variables:
- +TMPDIR+ and +TEST_HOME+, for controlling where the temporary home
directory is created;
- +EL_GET_LIB_DIR+, the directory where the el-get code resides;
- +EMACS+, which can be used to override the copy of emacs found in
your +PATH+, or to provide one if there is no emacs in your +PATH+
or it is installed under a nonstandard name.
You can run multiple tests by simply providing multiple test files to +run-test.sh+:
test/run-test.sh 200 303 310
When running multiple tests, the script will wait 5 seconds between
tests, since many tests involve downloading files from the same few
servers (Github, emacswiki, marmalade, etc.), and it is impolite to
download a large number of files in rapid succession just for
testing. There is a script called +run-all-tests.sh+ that acts as a
shortcut for running all the available tests.
Sometimes you may want to run a test in an interactive emacs session
so that you can use Emacs' debugging facilities to investigate what
went wrong. To do this, use +run-test-interactive.sh+ instead of
+run-test.sh+.
If simply want to test installation, updating, and removal of one or
more recipes, you can use the +test-recipe.sh+ script.
=== ERT-based automation
See +test.el+ in this directory, and see the el-get-devel mailing list for a
promising patch to port the effort to +ert+. This has yet to happen,
though.
......@@ -4,7 +4,6 @@
(let ((debug-on-error t)
(debug-ignored-errors '()))
(add-to-list 'load-path "/Users/dim/dev/emacs/el-get")
(setq el-get-default-process-sync t
el-get-verbose t)
(el-get-install "mailq"))
......@@ -19,12 +19,21 @@ set_default TEST_HOME "$TMPDIR/el-get-test-home"
set_default EMACS "$(which emacs)"
run_test () {
testfile="$1"
echo "*** Running el-get test $testfile interactively ***"
mkdir -p "$TEST_HOME"/.emacs.d
rm -rf "$TEST_HOME"/.emacs.d/el-get/
HOME="$TEST_HOME" "$EMACS" -Q -L "$EL_GET_LIB_DIR" \
-l "$EL_GET_LIB_DIR/el-get.el" -l "$testfile"
for x in "$1" "$TEST_DIR/$1" "$TEST_DIR/$1.el" "$TEST_DIR/el-get-issue-$1.el"; do
if [ -f "$x" ]; then
testfile="$x"
fi
done
if [ -z "$testfile" ]; then
echo "*** ERROR $1: Could not find test file ***"
else
echo "*** Running el-get test $testfile interactively ***"
mkdir -p "$TEST_HOME"/.emacs.d
rm -rf "$TEST_HOME"/.emacs.d/el-get/
HOME="$TEST_HOME" "$EMACS" -Q -L "$EL_GET_LIB_DIR" \
-f toggle-debug-on-error -l "$EL_GET_LIB_DIR/el-get.el" \
-l "$testfile"
fi
}
for t in "$@"; do
......
......@@ -15,25 +15,34 @@ fi
set_default EL_GET_LIB_DIR "$(dirname "$(dirname "$(readlink -f "$0")")")"
set_default TMPDIR "$(dirname "$(mktemp --dry-run)")"
set_default TEST_HOME "$TMPDIR/el-get-test-home"
set_default TEMP_HOME "$TMPDIR/el-get-test-home"
set_default EMACS "$(which emacs)"
set_default TEST_DIR "$(dirname $0)"
# 5 seconds in between tests to avoid accidental DoS from running too
# many tests in a short time
set_default DELAY_BETWEEN_TESTS 5
run_test () {
testfile="$1"
echo "*** Running el-get test $testfile ***"
mkdir -p "$TEST_HOME"/.emacs.d
rm -rf "$TEST_HOME"/.emacs.d/el-get/
HOME="$TEST_HOME" "$EMACS" -Q -batch -L "$EL_GET_LIB_DIR" \
-l "$EL_GET_LIB_DIR/el-get.el" -l "$testfile"
result="$?"
if [ "$result" = 0 ]; then
echo "*** SUCCESS $testfile ***"
for x in "$1" "$TEST_DIR/$1" "$TEST_DIR/$1.el" "$TEST_DIR/el-get-issue-$1.el"; do
if [ -f "$x" ]; then
testfile="$x"
fi
done
if [ -z "$testfile" ]; then
echo "*** ERROR $1: Could not find test file ***"
else
echo "*** FAILED $testfile ***"
echo "*** Running el-get test $testfile ***"
mkdir -p "$TEMP_HOME"/.emacs.d
rm -rf "$TEMP_HOME"/.emacs.d/el-get/
HOME="$TEMP_HOME" "$EMACS" -Q -batch -L "$EL_GET_LIB_DIR" \
-l "$EL_GET_LIB_DIR/el-get.el" -l "$testfile"
result="$?"
if [ "$result" = 0 ]; then
echo "*** SUCCESS $testfile ***"
else
echo "*** FAILED $testfile ***"
fi
fi
}
......
......@@ -3,4 +3,4 @@
cd "$(dirname "$0")"
echo "If you are sure you want to test ALL the recipes, run the following command:"
echo "exec $PWD/test-recipe.sh $PWD/../recipes/*.rcp 2>/dev/null"
echo "$PWD/test-recipe.sh $PWD/../recipes/*.rcp 2>/dev/null"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment