1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-03 02:36:19 +02:00
Commit graph

2761 commits

Author SHA1 Message Date
Michael Gran
9ae3069437 In posix test, skip AT_SYMLINK_NOFOLLOW test if symlinks unsupported
* test-suite/tests/posix.test ("AT_SYMLINK_NOFOLLOW"): skip if unsupported
2025-03-30 18:40:55 -07:00
Michael Gran
7aa3b482fb In posix test, skip ttyname test if not supported
* test-suite/tests/posix.test ("ttyname"): skip if unsupported
2025-03-30 18:40:37 -07:00
Michael Gran
e33dd7bfd8 In i18n test, modify locale testing to focus on UTF-8
fr_FR was mostly being tested as an 8-bit locale.  This changes
the tests to focus on fr_FR.utf8.  But it adds a section for fr_FR 8-bit
currency.  Divergence in vendor-supplied locales often occurs
in currency.

MINGW, which only handles 8-bit locales when using MSVCRT, was being tested
as if its 8-bit CP1252 locale was UTF-8.  While the tests were included
as better than nothing, it is technically incorrect. These tests are
no longer run. Soon, Guile's MINGW build will link to UCRT, and it will
have UTF-8 locales.

The responses for some tests were modified to allow reasonable responses
from Cygwin/MSYS/MinGW locales and to skip on unreasonable responses.

* test-suite/tests/i18n.test (mingw?): rename to old-ms?
  (old-ms?): new helper
  (%french-locale-name): use platform's default 8-bit locale
  (%french-utf8-locale-name, %turkish-utf8-locale-name, %german-utf8-locale-name)
  (%greek-utf8-locale-name): don't use 8-bit locales on MINGW
  ("text collation (French)"): use utf-8
  ("locale-digit-grouping (French)"): use utf-8
  (french-number-string=?): modify to make symmetric and to handle
     U+2024 as a valid spacer
  ("French: integer", "negative integer" "fraction", "fraction, 1 digit"):
  ("French"): rename to "French UTF-8"
  ("French UTF-8: 12345.678", "Fraction"): use utf-8, allow U+2024
  ("French UTF-8: positive inexact zero"): expect euro sign
  ("French 8-bit"): new currency tests
2025-03-30 18:39:31 -07:00
Michael Gran
1e0cf93a0a handle different errors messages for unbound variables 2025-03-30 18:33:23 -07:00
Michael Gran
9bb8793a6c Allow read-line to handle "\r\n" as a line terminator
Adds CRLF as a line ending. %read-line will return
these. In the case of CRLF, %read-line will return a string "\r\n"
as the line ending.

* libguile/rdelim.c (scm_read_line): handle CRLF line delimiter
* module/ice-9/suspendable-ports.scm (%read-line): modify to handle CRLF
    line delimiter
  (read-line): use modified %read-line
* test-suite/tests/rdelim.test ("two lines, split, CRLF"): new test
   ("two long lines, split, CRLF"): new test
* doc/ref/api-io.texi: update read-line documentation
2025-03-30 18:31:36 -07:00
Michael Gran
8d388c97e7 Add option to disable time limit in eval-in-sandbox
On systems without SIGALRM, the other features of eval-in-sandbox
may still be useful.  This adds the option to set #:time-limit to
#f to indicate no timeout.

* NEWS: updated
* module/ice-9/sandbox.scm (eval-in-sandbox): allow #:time-limit key
    to be #f to disable time limit
* doc/ref/api-evaluation.texi (eval-in-sandbox): update documentation
* test-suite/tests/sandbox.scm ("eval-in-sandbox"): throw unsupported
    if no SIGALARM
  ("eval-in-sandbox no timeout"): new tests for eval-in-sandbox
2025-03-30 18:30:09 -07:00
Michael Gran
68af1c93e7 In i18n test, add more reasonable test passes for french currency
* test-suite/tests/i18n.test ("french utf-8: number" "fraction"):
  ("positive inexact zero", "one cent", "very little money"): more
    success and failure conditions
2025-03-30 18:27:47 -07:00
Michael Gran
c8e0454692 WIN32: new internal define %UCRT when compiled with UCRT C library
This variable will help indicate if, on Win32, the C library is
closer to C99 capable.

* libguile/posix.c (scm_init_posix): new define %UCRT
* test-suite/tests/i18n.test (old-ms?): use new define allow UTF-8
    tests on MINGW
2025-03-30 18:25:41 -07:00
Michael Gran
0f748b32aa Avoid writing nulls in check-guile.log
Null characters in check-guile.log confuse grep.

* test-suite/tests/strings.test ("string-utf8-length"): add test names
* test-suite/tests/web-uri.test ("encode"): add test names
2025-03-30 18:20:36 -07:00
Michael Gran
153be2e6a5 In web-server test, skip server test if no threads provided
* test-suite/tests/web-server.test ("server is listening"): skip if no threads
2025-03-30 18:19:36 -07:00
Michael Gran
ba4939e31f MINGW: in ports test, use binary mode for line counter tests
The line counter tests presumes newline-only line endings.  Use binary
mode to avoid CRLF endings.

* test-suite/tests/ports.test ("line endings"): write test file in binary
    mode
2025-03-30 18:19:02 -07:00
Michael Gran
1838ef8ef6 In ports.test, convert some pass-if tests to pass-if-equal
* test-suite/tests/ports.test ("line counter"): convert several tests to
    use pass-if-equal
2025-03-30 18:18:20 -07:00
Michael Gran
2177f3f6c5 filesys.test: fixes for copy-file test on MinGW
In the copy-file test, is uses call-with-input-file and get-string-all
to retrieve file contents. Since the file is not opened in binary mode,
CRLF line ending may be added when writing and then reading the string
back from the filesystem.

* test-suite/tests/filesys.test (normalize-newlines): new helper function
  ("copy file: copy-file dest content"): pass even if CRLF line endings
  are added
  ("copy file: read only dest"): handle posibility of geteuid not
  being defined
2025-03-30 18:10:24 -07:00
Michael Gran
6b4d829d40 in filesys test, add helper function for deleting files and symlinks
On Windows, a file needs to have write permission to be deleted.
This adds a helper to handle that case, but, is used generally.

* test-suite/tests/filesys.test (%delete-file): new helper function
  Replace every delete-file call with %delete-file.
2025-03-30 18:10:16 -07:00
Michael Gran
cc1c79ae34 In test suite, ensure file ports are closed before deletion
On Windows, open file ports cannot be deleted.

* test-suite/tests/ports.test ("relative canonicalization with common prefixes"):
    close port before deletion
* test-suite/tests/posix.test (utime-unless-unsupported): take a port arg
  ("file port"): use new utime-unless-unsupported. Close port before deletion.
* test-suite/tests/filesys.test ("port representing a regular file"):
    throw unsupported before creating file
2025-03-30 18:10:07 -07:00
Michael Gran
1174e1eb9d Allows modification of shell used by open-pipe
open-pipe executes a shell command in a subprocess. This commit adds
the ability to modify the shell used for executing commands.
The default "/bin/sh -c" can be inspected and modified by the
new procedure-with-setter 'pipe-shell-command-transformer'.

This useful in MinGW since its "sh" is not in "/bin".

* module/ice-9/popen.scm (%command-transformer): new procedure
  (pipe-shell-command-transformer): new procedure-with-setter
  (open-pipe): use new command transformer
* doc/ref/posix.texi (open-pipe): mention pipe-shell-command-transformer
  (pipe-shell-command-transformer): document new procedure
* test-suite/tests/popen.test ("pipe-shell-command-transformer"): new tests
  Also, modify open-pipe shell for MinGW
* NEWS: updated
* test-suite/tests/ports.test (mingw?): new variable
    Also, modify open-pipe shell for MinGW
2025-03-30 18:09:37 -07:00
Michael Gran
9d625278f7 fixes for chmodat test
* test-suite/tests/filesys.test (chmodat): some chmodat tests don't test if it
   exists. Mark unwritable file writable before deleting.
  ("port representing a regular file"): reorder to avoid unclosed
     port on exception.
2025-03-30 18:02:21 -07:00
Michael Gran
7b41294049 Improve DLL search strategy for load-foreign-library
The new non-libltdl foreign library loading algorithm from 3.0.6
fails to cover common cases regarding how libtool names and installs
DLL files.  Notably, it fails to recognize when libtool has added the
major version number into the filename itself, such as libfoo-1.dll
Also, it does not search in binary directories and the PATH for DLL
files, where libtool is likely to install DLLs.

This adds the option to search for dlls with major version numbers
in the filename, and modifies the search strategy for DLL-using
OSs to check bindir and PATH.

For MSYS, libraries are installed with the 'msys-' prefix. So this
modifies load-foreign-library to handle that prefix as well.
It changes the #:rename-on-cygwin? option to #:host-type-rename? to
better reflect that is works on both Cygwin and MSYS.

Partially based on a patch by Hannes Müller.

* NEWS: updated
* doc/ref/api-foreign.texi: document updates to load-foreign-library
  and system-dll-path
* module/system/foreign-library.scm (is-integer-string?): new utility function
  (dll-name-match?): new utility function
  (find-best-dll-from-matches): new utility function
  (dll-exists-with-version): new function that implements new dll search logic
  (file-exists-with-extension): add flag argument to allow new dll search
  (file-exists-in-path-with-extension): add flag argument to all new dll search
  (system-dll-path): new parameter
  (lib->msys): new helper function
  (load-foreign-library): add new optarg flag #:allow-dll-version-suffix?
    Pass new flag to library search functions.
    Implement new search strategy for #:search-system-paths? on DLL systems'
    replace #:rename-on-cygwin? with #:host-type-rename?
        Use that option to rename both MSYS and Cygwin libraries.
  (guile-system-extensions-path): prefer bindir to libdir on DLL systems
* test-suite/tests/foreign.test ("dll-name-match?"): new test category
  ("find-best-dll-from-matches"): new test category
  ("lib->msys"): new unit tests
2025-03-22 07:05:31 -07:00
Michael Gran
c9a19a03f8 Cygwin/MSYS: 00-socket.test: abstract sockets are unsupported
Binding to AF_UNIX abstract sockets is not supported on Cygwin and
presumably MSYS as well.

* test-suite/tests/00-socket.text ("AF_UNIX abstract"): throw unsupported
  on Cygwin and MSYS
2025-03-22 06:42:21 -07:00
Michael Gran
73a8ca88fb ports.test: catch pipe errors
Refactors a couple of the ports tests to catch errors in the test runner,
so that the test suite will print ERROR on failure.

* test-suite/tests/ports.test (pipe:write, pipe:read): modified
2025-03-22 06:27:51 -07:00
Michael Gran
b572f187af version.test: incorrect test logic
Since string-contains returns an integer on success, this test
was reporting unresolved instead of pass on success.

* test-suite/tests/version.test ("version reporting works"): fix
  boolean check logic
2025-03-22 05:57:27 -07:00
Rob Browning
4527371d1b filesys.test: skip copy-file EACCES test when root
Accidentally omitted from b3b7477128.

* test-suite/tests/filesys.test: skip copy-file EACCES test when root.
2025-03-20 13:21:56 -05:00
Rob Browning
b3b7477128 Add missing, read-only, and typical copy-file tests
* test-suite/guile-test: add call-with-temp-dir and exception-errno.
* test-suite/tests/filesys.test: add further copy-file tests.
2025-03-19 21:25:40 -05:00
Rob Browning
5012581745 r6rs-ports.test: don't race with gc close in custom port tests
The tests share a "log" for custom port events and didn't always
explicitly close the test ports, so the close might come later, during
another test.  Change the tests to always close their ports immediately,
and clear the log after checking for expected "inter-test" events.

test-suite/tests/r6rs-ports.test: don't race with gc close in custom
port tests.
2025-03-02 14:44:53 -06:00
Dale P. Smith
29c27afe96 Allow trailing "." in urls
Fixes https://debbugs.gnu.org/53201

* module/web/uri.scm (valid-host?): Allow trailing "." in URLs
* test-suite/tests/web-uri.test: Add tests for trailing "."
2025-03-02 21:18:19 +01:00
Tomas Volf
c1353972ee srfi-19: Fix ~V converter in date->string.
The ~V is supposed to print ISO week number, not a week number.  This
commit fixes that.

* module/srfi/srfi-19.scm (date-week-number-iso): New procedure taken
  from the reference implementation.
  (directives)<#\V>: Use it.
* test-suite/tests/srfi-19.test ("date->string ~V"): Add tests taken
  from the reference test suite.
* doc/ref/srfi-modules.texi (SRFI-19 Date to string): Mention ISO-8601
  in description for ~V.

Fixes <https://bugs.gnu.org/74841>.
Edited by lloda <lloda@sarc.name>.
2025-02-28 10:28:06 +01:00
Daniel Llorens
bf3c632b82 Fix bug in srfi-111 box printer
* module/srfi/srfi-111.scm: Add missing port.
* test-suite/tests/srfi-111.test: Test.
2025-01-16 15:47:03 +01:00
Ekaitz Zarraga
6750f6cc80
PEG: string-peg: Add HTML5 grammar test.
* test-suite/tests/peg.test (comment-grammar): Z can be anything.
("simple comment with forbidden char"): Remove.
(html-grammar, html-example): New variables.
("parsing with complex grammars"): New test.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-22 22:17:39 +01:00
Adam Faiz
c2829e4a86 New line or field iteration procedures in (ice-9 rdelim)
* NEWS: Update
* module/ice-9/rdelim (for-rdelim-from-port, for-delimited-from-port,
  for-line-in-file): New procedures.
* doc/ref/api-io.texi: Documentation of `for-rdelim-for-port`-related
  procedures.
* test-suite/tests/rdelim.test: Tests for `for-rdelim-for-port`-related
  procedures.

Signed-off-by: Mikael Djurfeldt <mikael@djurfeldt.com>
2024-12-19 22:36:38 +01:00
Mikael Djurfeldt
a9c079b13b goops.test: Add tests for define-method* 2024-12-11 22:43:17 +01:00
Ekaitz Zarraga
25504ba216
PEG: Add support for not-in-range and [^...]
Modern PEG supports inversed class like `[^a-z]` that would get any
character not in the `a-z` range. This commit adds support for that and
also for a new `not-in-range` PEG pattern for scheme.

* module/ice-9/peg/codegen.scm (cg-not-in-range): New function.
* module/ice-9/peg/string-peg.scm: Add support for `[^...]`
* test-suite/tests/peg.test: Test it.
* doc/ref/api-peg.texi: Document accordingly.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-09 18:15:01 +01:00
Ekaitz Zarraga
ff11753df1
PEG: Add full support for PEG + some extensions
This commit adds support for PEG as described in:

    <https://bford.info/pub/lang/peg.pdf>

It adds support for the missing features (comments, underscores in
identifiers and escaping) while keeping the extensions (dashes in
identifiers, < and <--).

The naming system tries to be as close as possible to the one proposed
in the paper.

* module/ice-9/peg/string-peg.scm: Rewrite PEG parser.
* test-suite/tests/peg.test: Fix import

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-09 18:13:08 +01:00
Mikael Djurfeldt
20405089de test-suite: Canonicalize path in test directory
* test-suite/tests/filesys.test: Canonicalize path in the chdir tests to
avoid false differences due to following links.
2024-11-27 14:59:04 +01:00
Tomas Volf
ff256c356b
Do not depend on tmpnam in posix.test.
`tmpnam' is a deprecated procedure that can be excluded during a
configure (`--disable-tmpnam').  There currently was a single test
relying on it, and therefore failing is such configuration.  This commit
switches to mkstemp instead.

* test-suite/tests/posix.test ("system*"): Use mkstemp instead of
tmpnam.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:23 +02:00
Tomas Volf
58a722d883
tests: Fix spawn if file not found with Gnulib.
On Darwin posix_spawnp is not considered secured and therefore we
fallback to Gnulib's version.  That one however does not return ENOENT
when the file does not exist, but PID of the child process.  This seems
to be allowed by the standard.

* test-suite/tests/posix.test (skip-on-darwin): New procedure.
("spawn")["file not file"]: Skip on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:23 +02:00
Tomas Volf
1746dbbe4d
tests: Fix spawn with #:environment on MacOS.
MacOS adds __CF_USER_TEXT_ENCODING to every program, in similar way GNU
Hurd prepends LD_ORIGIN_PATH (based on the comment).  So extend the
logic to do similar stripping on MacOS.

* test-suite/tests/posix.test ("spawn")
["env with #:environment and #:output"]: Strip trailing
__CF_USER_TEXT_ENCODING environment variable when on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:23 +02:00
Tomas Volf
8579b73aba
tests: Skip mkdtemp test for invalid template on Darwin.
Darwin accepts any template, as demonstrated here:

    #include <stdio.h>
    #include <unistd.h>

    int
    main(void)
    {
    	char template[] = {'T', '-', 'A', 'A', 'A', 'A', 'A', 'A', '\0'};
    	char *res = mkdtemp(template);
    	puts(res ? res : "(null)");
    	perror("mkdtemp");
    }

Outputs:

    T-AAAAAA
    mkdtemp: Undefined error: 0

This does not match prescribed POSIX behavior, but it is what it is.

* test-suite/tests/filesys.test (skip-on-darwin): New procedure.
("mkdtemp")["invalid template"]: Skip on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:23 +02:00
Tomas Volf
21e3e1c420
tests: Skip hole-related port tests on Darwin.
Hole are itself a file-system specific feature and they are not
mandated.  While APFS does support sparse files, they do not behave like
on Linux.  I did not discover exact rules, but the file needs to be
large (100s of kB at least) and the holes are not aligned as the test
code expects.  So just disable them.

* test-suite/tests/ports.test (skip-on-darwin): New procedure.
("size of sparse file", "SEEK_DATA while on data")
("SEEK_DATA while in hole", "SEEK_HOLE while in hole"): Skip on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:22 +02:00
Tomas Volf
478f139d77
tests: Skip tests of abstract Unix sockets on Darwin.
Darwin does not support abstract Unix sockets, so mark the tests as
skipped.

* test-suite/tests/00-socket.test (skip-on-darwin): New procedure.
("bind abstract", "listen abstract", "connect abstract")
("accept abstract"): Skip on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:22 +02:00
Tomas Volf
a8ce7f1f92
tests: Check TCP_NODELAY for non-zero instead of 1.
POSIX does not explicitly say that stored value using setsockopt will be
returned by getsockopt.  At least for TCP_NODELAY on Darwin they do
differ.  Darwin returns internal define TF_NODELAY (4) instead of 1 the
test expected.  Since for boolean flags "non-zero is true", rewrite the
test to check just that.

* test-suite/tests/00-socket.test ("setsockopt AF_INET")
["IPPROTO_TCP TCP_NODELAY"]: Check for non-zero value from getsockopt.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:22 +02:00
Tomas Volf
ad90f45a8c
Replace SRFI-64 with a new implementation.
The bundled (reference) implementation was of somewhat mixed quality and
it failed to follow standard in multiple places.  This commit replaces
it with a new one, written from scratch to follow the standard as close
as possible.

* module/srfi/srfi-64/testing.scm: Delete file.
* module/srfi/srfi-64.scm: Replace with new implementation.
* am/bootstrap.am (srfi/srfi-64.go): Remove extra dependencies.
(NOCOMP_SOURCES): Remove srfi/srfi-64/testing.scm.
* test-suite/tests/srfi-64-test.scm
("8.6.1. Simple (form 1) test-apply")
("8.6.2. Simple (form 2) test-apply"): Adjust tests to follow the
specification.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 19:11:42 +02:00
Rob Browning
c03115c39d basename: check suffix against basename, not full argument
* libguile/filesys: check suffix against basename, not full argument.

Closes: 69437
2024-08-03 14:39:26 -05:00
Rob Browning
945c97b14d srfi-1 lset-difference!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_lset-difference_x): delete.
* libguile/srfi-1.h (scm_srfi1_lset-difference_x): delete.
* module/srfi/srfi-1.scm: add lset-difference!.
* test-suite/tests/srfi-1.test: extend lset-difference! tests to cover
lset-difference.
2024-07-30 19:28:37 -05:00
Rob Browning
372a52e6aa srfi-1 length+: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_length_plus): delete.
* libguile/srfi-1.h (scm_srfi1_length_plus): delete.
* module/srfi/srfi-1.scm: add length+.
2024-07-30 19:28:37 -05:00
Rob Browning
c62d2962d4 srfi-1 concatenate concatenate!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_concatenate, scm_srfi1_concatenate_x): delete.
* libguile/srfi-1.h (scm_srfi1_concatenate, scm_srfi1_concatenate_x): delete.
* module/srfi/srfi-1.scm: add concatenate and concatenate!.
2024-07-30 18:54:45 -05:00
Rob Browning
aa44035ee8 srfi-1 list-copy: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_list_copy): delete.
* libguile/srfi-1.h (scm_srfi1_list_copy): delete.
* module/srfi/srfi-1.scm: add list-copy.
* test-suite/tests/srfi-1.test: ensure copied spine is independent.
2024-07-30 18:54:45 -05:00
Rob Browning
ad1f56675b test-hashing: support 32-bit
* test-suite/standalone/test-hashing.c (test_hashing): add expected
value for 32-bit architectures.
2024-07-12 17:49:45 -05:00
Andy Wingo
b2cc237a02 Fix distcheck problems with parallel tests
* test-suite/Makefile.am (EXTRA_DIST): Add (test-lib lib automake)
(TEST_LOG_DRIVER): Use srcdir.
2024-06-23 23:26:47 +02:00
Andy Wingo
b93dc62e03 Fix parallel test bug in r6rs-ports.test
* test-suite/tests/r6rs-ports.test (test-file): Use different file from
ports.test, to avoid problems during parallel tests.
2024-06-23 21:43:05 +02:00
Andy Wingo
2a4c095f79 Avoid stompling user TESTS_ENVIRONMENT var
* test-suite/standalone/Makefile.am (top_srcdir): Use
AM_TESTS_ENVIRONMENT.
2024-06-20 15:54:53 +02:00