exercism / prolog

Exercism exercises in Prolog.
https://exercism.org/tracks/prolog
MIT License
29 stars 39 forks source link

Submissions not accepted for Anagram #170

Closed sudhackar closed 2 years ago

sudhackar commented 2 years ago

Anagram exercise has some UTF-8 characters which causes even valid submissions to fail. image

Code here https://github.com/exercism/prolog/blob/4e07c03713e0873a8f9349254675643d24766bc2/exercises/practice/anagram/anagram_tests.plt#L55-L59

I root caused this to the runner where we need to fix the locale.

$ docker run -it --rm --entrypoint /bin/sh --name test -v /home/sudhakar/tools/exercism/prolog/anagram/:/solution -v /tmp/out:/output exercism/prolog-test-runner
# bash
root@e1a4478f3dcd:/opt/test-runner# locale -a
C
C.UTF-8
POSIX
root@e1a4478f3dcd:/opt/test-runner# cd /solution
root@e1a4478f3dcd:/solution# swipl -f *.pl -s *.plt -g run_tests,halt -t 'halt(1)'
Warning: /solution/anagram_tests.plt:55:
Warning:    '/solution/anagram_tests.plt':56:80: Illegal multibyte Sequence
Warning: /solution/anagram_tests.plt:58:
Warning:    '/solution/anagram_tests.plt':59:40: Illegal multibyte Sequence
% PL-Unit: anagram ...............
ERROR:
    [[ EXCEPTION while printing message url('/solution/anagram_tests.plt':55)
       with arguments []:
       raised: type_error(text,url('/solution/anagram_tests.plt':55))
    ]]
:
        test detects_unicode_anagrams: failed

.. done
% 1 test failed
% 17 tests passed
ERROR: -g run_tests,halt: false
root@e1a4478f3dcd:/solution# export LANG=C.UTF-8
root@e1a4478f3dcd:/solution# swipl -f *.pl -s *.plt -g run_tests,halt -t 'halt(1)'
% PL-Unit: anagram .................. done
% All 18 tests passed
root@e1a4478f3dcd:/solution#

Additionally we should add

:- encoding(utf8).

to any file that has unicode characters to get rid of the warning we see earlier. I'll raise a couple of PRs.

ErikSchierboom commented 2 years ago

Great, thanks!

sudhackar commented 2 years ago

Passes now 💥 image