From 34154c7c4d17d72f21c4bf8191c5c519f74ca77d Mon Sep 17 00:00:00 2001 From: philippe lhardy Date: Tue, 7 Oct 2025 11:18:33 +0200 Subject: [PATCH] temporary expected error : works only on my system (absolute directories) --- LISEZMOI.md | 2 +- README.md | 2 +- samples/expected/6.stderr | 16 ++++++++++++++++ samples/tests.sh | 15 ++++++++++++++- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 samples/expected/6.stderr diff --git a/LISEZMOI.md b/LISEZMOI.md index a405b83..22dfe97 100644 --- a/LISEZMOI.md +++ b/LISEZMOI.md @@ -29,7 +29,7 @@ C'est la description de wikipedia https://fr.wikipedia.org/wiki/Jugement_majorit (https://en.wikipedia.org/wiki/Majority_judgment) -L'implémentaion est très basique et miminale : +L'implémentation est très basique et miminale : |langage|code| |-----|---------------------| diff --git a/README.md b/README.md index 9d477ce..5962866 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Glue to use majortiy judgement algorithm in various polls applications +# Glue to use majority judgement algorithm in various polls applications Initial trigger of this project is implementation of this in Nextcloud poll app https://github.com/nextcloud/polls/issues/3472, project pushed by https://www.astrolabe.coop/ diff --git a/samples/expected/6.stderr b/samples/expected/6.stderr new file mode 100644 index 0000000..ba02cfb --- /dev/null +++ b/samples/expected/6.stderr @@ -0,0 +1,16 @@ +[WARN] No /.resources.var found +Traceback (most recent call last): + File "/home/plhardy/clients/astrolabe/nextcloud/poll/jugement_majoritaire/samples/../code/parse_sample.py", line 19, in + result = majority_judgment_run(poll) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/home/plhardy/clients/astrolabe/nextcloud/poll/jugement_majoritaire/code/majority_judgment_method/__init__.py", line 39, in majority_judgment_run + voters=poll['voters']['count'] + ~~~~^^^^^^^^^^ +KeyError: 'voters' +PHP Warning: Undefined array key "voters" in /home/plhardy/clients/astrolabe/nextcloud/poll/jugement_majoritaire/code/parse_sample.php on line 24 +PHP Warning: Trying to access array offset on null in /home/plhardy/clients/astrolabe/nextcloud/poll/jugement_majoritaire/code/parse_sample.php on line 24 +PHP Warning: Undefined array key "candidates" in /home/plhardy/clients/astrolabe/nextcloud/poll/jugement_majoritaire/code/parse_sample.php on line 25 +PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/plhardy/clients/astrolabe/nextcloud/poll/jugement_majoritaire/code/parse_sample.php:26 +Stack trace: +#0 {main} + thrown in /home/plhardy/clients/astrolabe/nextcloud/poll/jugement_majoritaire/code/parse_sample.php on line 26 diff --git a/samples/tests.sh b/samples/tests.sh index 1ca2705..0c822db 100755 --- a/samples/tests.sh +++ b/samples/tests.sh @@ -2,7 +2,20 @@ [[ -n $VIRTUAL_ENV ]] || source ../code/bin/activate -for (( i=0;i<7;i++ )) + +expect_error() +{ + sample=$1 + # error case on purpose + resultdir=tmp + [[ -d ${resultdir} ]] || mkdir ${resultdir} + ./check.sh $sample 2>${resultdir}/$sample.stderr + diff ${resultdir}/$sample.stderr expected/$sample.stderr +} + +for (( i=0;i<6;i++ )) do ./check.sh $i done + +expect_error 6