jed-users mailing list

[2025 Date Index] [2025 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [jed-users] Failing unit test for valid $HOME


Hi John,

Thanks for the patch. I am currently applying it to the Debian package for jed. [1]

If you are curious to know how I discovered the bug: it was not me, but rather Debian's reprotest. [2]

Rafael

 [1] https://salsa.debian.org/debian/jed/-/blob/debian/latest/debian/patches/test-expand-trailing-slash-in-home.patch?ref_type=heads
 [2] https://salsa.debian.org/debian/jed/-/pipelines/972482

* John E. Davis <jed@xxxxxxxxxxx> [2025-11-13 12:23]:

Hi Rafael,

Thanks for the bug report. The test_expand_filename function expands its first argument and compares it to the value of the second argument, which does not get expanded. The failed cases all involve the use of "HOME" in the second argument. When I wrote the tests, I assumed that $HOME would not contain a trailing slash. The attached patch enforces this assumption.

--John


Hi,

Some unit tests in the test_expand.sl file fail in this particular case:

     $ HOME="/home/rlaboiss/" make -C src runtests
     make: Entering directory '/var/data/rlaboiss/debian/PKGS/jed/jed/src'
     ./test/runtests.sh /var/data/rlaboiss/debian/PKGS/jed/jed/src/objs/jed
     Running /var/data/rlaboiss/debian/PKGS/jed/jed/src/objs/jed -script ./test/test_cmode.sl
     Running /var/data/rlaboiss/debian/PKGS/jed/jed/src/objs/jed -script ./test/test_expand.sl
     expand_filename (~/foo) -> /home/rlaboiss/foo, expected /home/rlaboiss//foo
     expand_filename (/foo/bar/~/xx/..) -> /home/rlaboiss/, expected /home/rlaboiss//
     expand_filename (/foo/bar/~/~/xx/..) -> /home/rlaboiss/, expected /home/rlaboiss//
     expand_filename (~/foo/bar/~/~/xx/..) -> /home/rlaboiss/, expected /home/rlaboiss//
     expand_filename (~/foo/bar/~/~xx) -> /home/rlaboiss/~xx, expected /home/rlaboiss//~xx
     expand_filename (~/foo/bar/~/xx~) -> /home/rlaboiss/xx~, expected /home/rlaboiss//xx~
     expand_filename (~/foo/bar/~) -> /home/rlaboiss/foo/bar/~, expected /home/rlaboiss//foo/bar/~
     Running /var/data/rlaboiss/debian/PKGS/jed/jed/src/objs/jed -script ./test/test_links.sl
     /tmp/jedtest19398.1448637/A/dev/hoo and /tmp/jedtest19398.1448637/A/dev/foo are the same
     Running /var/data/rlaboiss/debian/PKGS/jed/jed/src/objs/jed -script ./test/test_narrow.sl
     Running /var/data/rlaboiss/debian/PKGS/jed/jed/src/objs/jed -script ./test/test_region.sl
     Running /var/data/rlaboiss/debian/PKGS/jed/jed/src/objs/jed -script ./test/test_replace.sl
     Running /var/data/rlaboiss/debian/PKGS/jed/jed/src/objs/jed -script ./test/test_search.sl
     make: *** [Makefile:310: runtests] Error 1
     make: Leaving directory '/var/data/rlaboiss/debian/PKGS/jed/jed/src'

The problem arises because there is a trailing slash in the HOME
environment variable. This is one of the problematic unit tests:

     test_expand_filename ("~/foo", "$HOME/foo"$);

This happens because the expand_filename command sanitizes the resulting
path, by removing the multiple slashes, among other things.

This could, theoretically, be fixed as:

     test_expand_filename ("~/foo", jed_standardize_filename ("$HOME/foo"$));

However, the function jed_standardize_filename, defined in
src/sysdep.c is not exported in SLang.

Best,

Rafael Laboissi?re
_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.



diff --git a/src/test/test_expand.sl b/src/test/test_expand.sl index 9f39ef3..fef05e0 100644 --- a/src/test/test_expand.sl +++ b/src/test/test_expand.sl @@ -29,13 +29,19 @@ test_expand_filename ("//./bar//gamma/.", "/bar/gamma/"); test_expand_filename ("//./bar//gamma/..", "/bar/"); test_expand_filename ("/..", "/"); test_expand_filename ("/.", "/"); -test_expand_filename ("~/foo", "$HOME/foo"$); -test_expand_filename ("/foo/bar/~/xx/..", "$HOME/"$); -test_expand_filename ("/foo/bar/~/~/xx/..", "$HOME/"$); -test_expand_filename ("~/foo/bar/~/~/xx/..", "$HOME/"$); -test_expand_filename ("~/foo/bar/~/~xx", "$HOME/~xx"$); -test_expand_filename ("~/foo/bar/~/xx~", "$HOME/xx~"$); -test_expand_filename ("~/foo/bar/~", "$HOME/foo/bar/~"$); + +private variable HOME = getenv ("HOME"); +if (HOME != NULL) +{ + HOME = strtrim_end(HOME, "/"); + test_expand_filename ("~/foo", "$HOME/foo"$); + test_expand_filename ("/foo/bar/~/xx/..", "$HOME/"$); + test_expand_filename ("/foo/bar/~/~/xx/..", "$HOME/"$); + test_expand_filename ("~/foo/bar/~/~/xx/..", "$HOME/"$); + test_expand_filename ("~/foo/bar/~/~xx", "$HOME/~xx"$); + test_expand_filename ("~/foo/bar/~/xx~", "$HOME/xx~"$); + test_expand_filename ("~/foo/bar/~", "$HOME/foo/bar/~"$); +}

#ifntrue % Only for __QNX__
_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.


[2025 date index] [2025 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]