summaryrefslogtreecommitdiff
path: root/tests/utils.scm
AgeCommit message (Collapse)Author
2021-11-07utils: Define a target-x86-32? and target-x86-64? predicate.Maxime Devos
* guix/utils.scm (target-x86-32?, target-x86-64?): New predicates. * tests/utils.scm ("target-x86-32?", "target-x86-64?"): New tests. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
2021-02-03utils: Add string distance.zimoun
* guix/utils.scm (string-distance): New procedure. (string-closest): New procedure. * tests/utils.scm ("string-distance", "string-closest"): New tests. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-02-01utils: Add 'version-unique-prefix'.Ludovic Courtès
* guix/utils.scm (version-unique-prefix): New procedure. * tests/utils.scm ("version-unique-prefix"): New test.
2021-01-13utils: Support zstd compression via Guile-zstd.Ludovic Courtès
* guix/utils.scm (lzip-port): Return a single value. (zstd-port): New procedure. (decompressed-port, compressed-output-port): Add 'zstd' case. * tests/utils.scm (test-compression/decompression): Test 'zstd' when the (zstd) module is available.
2021-01-13utils: Remove 'compressed-output-port'.Ludovic Courtès
This procedure was unused except in one test. * guix/utils.scm (compressed-port): Remove. * tests/utils.scm (test-compression/decompression): Rewrite to use 'compressed-output-port' instead.
2020-08-24Use "guile-zlib" and "guile-lzlib" instead of (guix config).Mathieu Othacehe
* Makefile.am (MODULES): Remove guix/zlib.scm and guix/lzlib.scm, (SCM_TESTS): remove tests/zlib.scm, tests/lzlib.scm. * build-aux/build-self.scm (make-config.scm): Remove unused %libz variable. * configure.ac: Remove LIBZ and LIBLZ variables and check instead for Guile-zlib and Guile-lzlib. * doc/guix.texi ("Requirements"): Remove zlib requirement and add Guile-zlib and Guile-lzlib instead. * gnu/packages/package-management.scm (guix)[native-inputs]: Add "guile-zlib" and "guile-lzlib", [inputs]: remove "zlib" and "lzlib", [propagated-inputs]: ditto, [arguments]: add "guile-zlib" and "guile-lzlib" to Guile load path. * guix/config.scm.in (%libz, %liblz): Remove them. * guix/lzlib.scm: Remove it. * guix/man-db.scm: Use (zlib) instead of (guix zlib). * guix/profiles.scm (manual-database): Do not stub (guix config) in imported modules list, instead add "guile-zlib" to the extension list. * guix/scripts/publish.scm: Use (zlib) instead of (guix zlib) and (lzlib) instead of (guix lzlib), (string->compression-type, effective-compression): do not check for zlib and lzlib availability. * guix/scripts/substitute.scm (%compression-methods): Do not check for lzlib availability. * guix/self.scm (specification->package): Add "guile-zlib" and "guile-lzlib" and remove "zlib" and "lzlib", (compiled-guix): remove "zlib" and "lzlib" arguments and add guile-zlib and guile-lzlib to the dependencies, also do not pass "zlib" and "lzlib" to "make-config.scm" procedure, (make-config.scm): remove "zlib" and "lzlib" arguments as well as %libz and %liblz variables. * guix/utils.scm (lzip-port): Use (lzlib) instead of (guix lzlib) and do not check for lzlib availability. * guix/zlib.scm: Remove it. * m4/guix.m4 (GUIX_LIBZ_LIBDIR, GUIX_LIBLZ_FILE_NAME): Remove them. * tests/lzlib.scm: Use (zlib) instead of (guix zlib) and (lzlib) instead of (guix lzlib), and do not check for zlib and lzlib availability. * tests/publish.scm: Ditto. * tests/substitute.scm: Do not check for lzlib availability. * tests/utils.scm: Ditto. * tests/zlib.scm: Remove it.
2019-06-20utils: canonical-newline-port: Fix handling of carriage return at buffer end.Robert Vollmert
Prior to this change the added test fails for me locally at byte 1024. It might depend on some default buffer sizes. Fixes <https://bugs.gnu.org/35863>. * tests/utils.scm ("canonical-newline-port-1024"): Add test. * guix/utils.scm (canonical-newline-port): Correct comments on CR/LF. Remove CR even when they're at the end of the buffer. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2019-05-27utils: Support compression and decompression with lzip.Ludovic Courtès
* guix/utils.scm (lzip-port): New procedure. (decompressed-port, compressed-port, compressed-output-port): Add 'lzip case. * tests/utils.scm <top level>: Call 'test-compression/decompression' for 'lzip as well.
2019-05-27utils: Test 'compressed-port' and 'decompressed-port' for both gzip and xz.Ludovic Courtès
* tests/utils.scm (test-compression/decompression): New procedure. <top level>: Call it for both 'xz and 'gzip.
2018-05-13utils: Add 'version-prefix?'.Ludovic Courtès
* guix/utils.scm (version-prefix?): New procedure. * tests/utils.scm ("version-prefix?"): New test.
2018-05-10union: Add 'relative-file-name'.Ludovic Courtès
* guix/build/union.scm (%not-slash): New variable. (relative-file-name): New procedure. * tests/union.scm (test-relative-file-name): New macro and tests.
2017-03-16utils: Move base16 procedures to (guix base16).Ludovic Courtès
* guix/utils.scm (bytevector->base16-string, base16-string->bytevector): Move to... * guix/base16.scm: ... here. New file. * tests/utils.scm ("bytevector->base16-string->bytevector"): Move to... * tests/base16.scm: ... here. New file. * Makefile.am (MODULES): Add guix/base16.scm. (SCM_TESTS): Add tests/base16.scm. * build-aux/download.scm, guix/derivations.scm, guix/docker.scm, guix/import/snix.scm, guix/pk-crypto.scm, guix/scripts/authenticate.scm, guix/scripts/download.scm, guix/scripts/hash.scm, guix/store.scm, tests/hash.scm, tests/pk-crypto.scm: Adjust imports accordingly.
2016-10-07utils: Support defaults in substitute-keyword-arguments.Eric Bavier
* guix/utils.scm (collect-default-args, expand-default-args): New syntax. (substitute-keyword-arguments): Allow default value declarations. * tests/utils.scm (substitute-keyword-arguments): New test.
2016-10-07utils: Fix default-keyword-arguments.Eric Bavier
* guix/utils.scm (default-keyword-arguments): Properly test for present keywords. * tests/utils.scm (default-keyword-arguments): New test.
2016-05-06utils: Move 'fcntl-flock' to (guix build syscalls).Ludovic Courtès
* guix/utils.scm (%struct-flock, F_SETLKW, F_SETLK, F_xxLCK) (fcntl-flock): Move to... * guix/build/syscalls.scm: ... here. New variables. * guix/nar.scm: Adjust imports accordingly. * tests/utils.scm ("fcntl-flock wait", "fcntl-flock non-blocking"): Move to... * tests/syscalls.scm: ... here. New tests. (temp-file): New variable.
2016-05-04utils: Move combinators to (guix combinators).Ludovic Courtès
* guix/utils.scm (compile-time-value, memoize, fold2) (fold-tree, fold-tree-leaves): Move to... * guix/combinators: ... here. New file. * tests/utils.scm ("fold2, 1 list", "fold2, 2 lists") (fold-tree tests): Move to... * tests/combinators.scm: ... here. New file. * Makefile.am (MODULES, SCM_TESTS): Add them. * gnu/packages.scm, gnu/packages/bootstrap.scm, gnu/services/herd.scm, guix/build-system/gnu.scm, guix/build-system/python.scm, guix/derivations.scm, guix/gnu-maintenance.scm, guix/import/elpa.scm, guix/scripts/archive.scm, guix/scripts/build.scm, guix/scripts/graph.scm, guix/scripts/lint.scm, guix/scripts/size.scm, guix/scripts/substitute.scm, guix/serialization.scm, guix/store.scm, guix/ui.scm: Adjust imports accordingly.
2016-05-04utils: Remove 'split'.Ludovic Courtès
This procedure was redundant with SRFI-1's 'break'. * guix/utils.scm (split): Remove. * tests/utils.scm ("split, element is in list") ("split, element is not in list"): Remove.
2016-04-13utils: Add 'edit-expression'.宋文武
* guix/utils.scm (edit-expression): New procedure. * tests/utils.scm (edit-expression): New test.
2016-04-03build: Add a Guile custom test driver using SRFI-64.Mathieu Lirzin
Before that '.log' files for scheme tests were fragmented and not included in test-suite.log. This unifies the semantics of SRFI-64 API with Automake test suite. * build-aux/test-driver.scm: New file. * Makefile.am (SCM_LOG_DRIVER, AM_SCM_LOG_DRIVER_FLAGS): New variables. (SCM_LOG_COMPILER, AM_SCM_LOG_FLAGS): Delete variables. (AM_TESTS_ENVIRONMENT): Set GUILE_AUTO_COMPILE to 0. * test-env.in: Silence guix-daemon. * doc/guix.texi (Running the Test Suite): Describe how to display the detailed results. Bug reports require only 'test-suite.log' file. * tests/base32.scm, tests/build-utils.scm, tests/builders.scm, tests/challenge.scm, tests/cpan.scm, tests/cpio.scm, tests/cran.scm, tests/cve.scm, tests/derivations.scm, tests/elpa.scm, tests/file-systems.scm, tests/gem.scm, tests/gexp.scm, tests/gnu-maintenance.scm, tests/grafts.scm, tests/graph.scm, tests/gremlin.scm, tests/hackage.scm, tests/hash.scm, tests/import-utils.scm, tests/lint.scm, tests/monads.scm, tests/nar.scm, tests/packages.scm, tests/pk-crypto.scm, tests/pki.scm, tests/profiles.scm, tests/publish.scm, tests/pypi.scm, tests/records.scm, tests/scripts-build.scm, tests/scripts.scm, tests/services.scm, tests/sets.scm, tests/size.scm, tests/snix.scm, tests/store.scm, tests/substitute.scm, tests/syscalls.scm, tests/system.scm, tests/ui.scm, tests/union.scm, tests/upstream.scm, tests/utils.scm: Don't exit at the end of test groups. * tests/containers.scm: Likewise. Use 'test-skip' instead of exiting with error code 77.
2016-03-02utils: Use '@' for separating package names and version numbers.Mathieu Lirzin
This provides the ability to use numbers in package names. Fixes <http://bugs.gnu.org/19219>. * guix/utils.scm (package-name->name+version): New procedure. * gnu/packages.scm (%find-package): Add a FALLBACK? keyword argument. Use the previous method when no package is found. (specification->package+output, specification->package): Adapt documentation to new syntax. * doc/guix.texi (Invoking guix package, Invoking guix import): Likewise. * guix/ui.scm (package-specification->name+version+output): Likewise. * guix/scripts/import/hackage.scm (show-help): Likewise. * tests/guix-build.sh: Adapt to new syntax. * tests/guix-lint.sh: Likewise. * tests/guix-package.sh: Likewise. * tests/ui.scm ("package-specification->name+version+output"): Likewise. * tests/utils.scm ("package-name->name+version"): Likewise. * NEWS: Mention new syntax.
2016-01-06utils: Add 'ensure-keyword-arguments'.Ludovic Courtès
* guix/utils.scm (delkw, ensure-keyword-arguments): New procedures. * tests/utils.scm ("ensure-keyword-arguments"): New test.
2015-11-26utils: Add 'canonical-newline-port'.Federico Beffa
* guix/utils.scm (canonical-newline-port): New procedure. * tests/utils.scm ("canonical-newline-port"): New test.
2015-10-09utils: Add split procedure.David Thompson
* guix/utils.scm (split): New procedure. * tests/utils.scm: Add tests.
2015-05-06search-paths: Export 'string-tokenize*'.Ludovic Courtès
* guix/search-paths.scm (string-tokenize*): Export. * tests/utils.scm ("string-tokenize*"): Adjust accordingly.
2015-05-04search-paths: Add 'evaluate-search-paths', from (guix scripts package).Ludovic Courtès
* guix/scripts/package.scm (with-null-error-port, evaluate-search-paths): Move to... * guix/search-paths.scm: ... here. * guix/utils.scm (string-tokenize*): Move to... * guix/search-paths.scm: ... here. * tests/utils.scm ("string-tokenize*"): Adjust accordingly.
2014-10-05utils: Add 'strip-keyword-arguments'.Ludovic Courtès
* guix/utils.scm (strip-keyword-arguments): New procedure. * tests/utils.scm ("strip-keyword-arguments"): New test.
2014-07-20guix: utils: Add fold-tree and fold-tree-leaves.Eric Bavier
* guix/utils.scm (fold-tree, fold-tree-leaves): New functions. * tests/utils.scm: Add tests for them.
2014-04-14offload: '{send,receive}-files' wait for completion of the transfer.Ludovic Courtès
Fixes situations where the remote 'guix build' is invoked before the .drv has been completely copied, as reported at <https://lists.gnu.org/archive/html/guix-devel/2014-04/msg00174.html>. In some cases 'send-files' would return before the other end is done importing the files, and so the subsequent 'guix build' invocation would just miss the .drv file it refers to. * guix/utils.scm (call-with-decompressed-port): Don't close PORT. (call-with-compressed-output-port): Likewise. * tests/utils.scm ("compressed-output-port + decompressed-port"): Adjust accordingly. * guix/scripts/offload.scm (send-files): Add explicit (close-pipe pipe) call. (retrieve-files): Likewise.
2014-04-07tests: Avoid buffering in 'fcntl-flock' tests.Ludovic Courtès
Partially fixes <http://bugs.gnu.org/17212>. * tests/utils.scm ("fcntl-flock wait", "fcntl-flock non-blocking"): Open files in binary mode, with no buffering.
2014-03-24utils: Add 'call-with-decompressed-port' and 'call-with-compressed-output-port'.Ludovic Courtès
* guix/utils.scm (call-with-decompressed-port, call-with-compressed-output-port): New procedures. * tests/utils.scm ("compressed-output-port + decompressed-port"): Rewrite to use them.
2014-03-24utils: Add 'filtered-output-port' and 'compressed-output-port'.Ludovic Courtès
* guix/utils.scm (filtered-output-port, compressed-output-port): New procedures. * tests/utils.scm ("compressed-output-port + decompressed-port"): New test.
2014-03-22utils: Add 'decompressed-port' and 'compressed-port'.Ludovic Courtès
* guix/utils.scm (decompressed-port, compressed-port): New procedures. * guix/scripts/substitute-binary.scm (decompressed-port): Remove. (guix-substitute-binary): Pass a symbol or #f as the first argument to 'decompress-port'. * tests/utils.scm ("compressed-port, decompressed-port, non-file"): New test.
2014-03-22utils: 'filtered-port' doesn't leave dangling processes behind.Ludovic Courtès
* guix/utils.scm (filtered-port): Make sure the 'execl' child process always exits, and does (primitive-_exit 1) upon execution failure. Use 'primitive-_exit' in the 'dump-port' child process. * tests/utils.scm ("filtered-port, does not exist"): New test.
2014-03-08utils: Add a non-blocking option for 'fcntl-flock'.Ludovic Courtès
* guix/utils.scm (F_SETLK): New variable. (fcntl-flock): Add 'wait?' keyword parameter; honor it. * tests/utils.scm ("fcntl-flock non-blocking"): New test.
2014-03-06tests: Rewrite 'fcntl-lock' test.Ludovic Courtès
* tests/utils.scm (temp-file): New variable. ("fcntl-flock"): Rewrite to actually test whether the child process waits for the lock to be released. The previous test was wrong because (1) it expected F_SETLK semantics, not F_SETLKW, and (2) it got EBADF because of a mismatch between the open mode and the lock style.
2014-01-24utils: Add 'fcntl-flock'.Ludovic Courtès
* guix/utils.scm (%struct-flock, F_SETLKW, F_xxLCK): New variables. (fcntl-flock): New procedure. * tests/utils.scm ("fcntl-flock"): New test.
2013-11-13utils: Add 'string-replace-substring'.Ludovic Courtès
* guix/utils.scm (string-replace-substring): New procedure. Based on code by Mark H. Weaver. * tests/utils.scm ("string-replace-substring"): New test.
2013-08-23utils: Add `guile-version>?', and use it.Ludovic Courtès
This fixes Guile version comparisons when (version) has a vendor-specific suffix. Reported by Andreas Enge <andreas@enge.fr>. * guix/utils.scm (guile-version>?): New procedure. * tests/utils.scm ("guile-version>? 1.8", "guile-version>? 10.5"): New tests. * guix/scripts/substitute-binary.scm (fetch, progress-report-port): Use `guile-version>?' instead of `version>?'. * guix/http-client.scm (when-guile<=2.0.5, http-fetch): Likewise.
2013-08-22substitute-binary: Try hard to avoid port buffering.Ludovic Courtès
* guix/scripts/substitute-binary.scm (fetch): In the `file' case, open with the `b' flag, so that the coding cookie reading thing doesn't lead to buffering some of the data (on 2.0.5). * tests/utils.scm ("filtered-port, file"): Open with `r0b'. Fixes a test failure with Guile 2.0.5 whereby the first byte of FILE would be missing from DECOMPRESSED.
2013-05-15substitute-binary: Pass `filtered-port' an unbuffered port.Ludovic Courtès
This fixes a bug whereby `read-response' would read more than just the response, with the extra data going into the port's buffer; the "bzip2 -dc" process spawned by `filtered-port' would not see the those buffered data, which are definitely lost, and would bail out with "bzip2: (stdin) is not a bzip2 file." * guix/utils.scm (filtered-port): Document that INPUT must be unbuffered. * guix/web.scm (http-fetch): Add `buffered?' parameter. Call `open-socket-for-uri' explicitly, and call `setvbuf' when BUFFERED? is false. Pass the port to `http-get'. Close it upon 301/302. * guix/scripts/substitute-binary.scm (fetch): Add `buffered?' parameter. Pass it to `http-fetch'; honor it for `file' URIs. (guix-substitute-binary): Call `fetch' with #:buffered? #f for port RAW. * tests/utils.scm ("filtered-port, file"): Open FILE as unbuffered.
2013-05-12Move record utilities to (guix records).Ludovic Courtès
* guix/utils.scm (define-record-type*): Move to... * guix/records.scm: ... here. New file. * guix/build-system.scm, guix/packages.scm: Use it. * guix/gnu-maintenance.scm: Likewise. (official-gnu-packages)[alist->record]: Remove. * guix/scripts/substitute-binary.scm: Likewise. (alist->record, object->fields): Remove. * tests/utils.scm ("define-record-type*", "define-record-type* with letrec* behavior", "define-record-type* & inherit", "define-record-type* & inherit & letrec* behavior", "define-record-type* & thunked", "define-record-type* & thunked & default", "define-record-type* & thunked & inherited"): Move to... * tests/records.scm: ... here. New file.
2013-04-30Merge branch 'core-updates'Ludovic Courtès
2013-04-29substitute-binary: Support decompression from non-file ports.Ludovic Courtès
* guix/scripts/substitute-binary.scm (filtered-port): Move to utils.scm. (decompressed-port): Upon "none", return '() as the second value. (guix-substitute-binary): Expect `decompressed-port' to return a list of PIDs as its second value. * guix/utils.scm (filtered-port): New procedure. Add case for when INPUT is not `file-port?'. * tests/utils.scm ("filtered-port, file", "filtered-port, non-file"): New tests.
2013-04-28utils: Add `string-tokenize*'.Ludovic Courtès
* guix/utils.scm (string-tokenize*): New procedure. * tests/utils.scm ("string-tokenize*"): New test.
2013-04-14utils: Add `fold2'.Ludovic Courtès
* gnu/packages.scm (fold2): Remove. * guix/utils.scm (fold2): New procedure. Generalization of the above to one and two lists. * tests/utils.scm ("fold2, 1 list", "fold2, 2 lists"): New tests.
2013-02-01Augment `.dir-locals.el'.Ludovic Courtès
* .dir-locals.el: Add more Scheme settings. * guix-build.in, tests/base32.scm, tests/build-utils.scm, tests/builders.scm, tests/derivations.scm, tests/packages.scm, tests/snix.scm, tests/store.scm, tests/union.scm, tests/utils.scm: Remove redundant Emacs local variable settings.
2013-01-23define-record-type*: Add the `thunked' field definition keyword.Ludovic Courtès
* guix/utils.scm (define-record-type*)[make-syntactic-constructor]: Add a `thunked' parameter. (thunked-field?, field-bindings): New procedures. Use the latter when generating `letrec*' bindings. [thunked-field?, thunked-field-accessor-name, field-spec->srfi-9, thunked-field-accessor-name]: New procedures. Use them when generating the `define-record-type' form, and to generated thunk field accessors, along call to `make-syntactic-constructor' with the new argument. * tests/utils.scm ("define-record-type* & thunked", "define-record-type* & thunked & default", "define-record-type* & thunked & inherited"): New tests.
2013-01-06Update license headers.Ludovic Courtès
Change all license headers, except guix/build/* and ld-wrapper.scm, with this code: (use-modules (guix build utils) (srfi srfi-1)) (fluid-set! %default-port-encoding "UTF-8") (substitute* (remove (lambda (f) (or (string-contains f ".tar.") (string-contains f ".git/") (string-contains f ".so") (string-suffix? ".o" f) (string-suffix? ".a" f) (string-suffix? ".go" f) (string-suffix? ".pdf" f) (string-suffix? ".png" f) (string-suffix? ".info" f) (equal? (basename f) "guix-daemon") (equal? (basename f) "nix-setuid-helper") (string-contains f "nix-upstream/") (string-contains f "distro/packages/bootstrap/"))) (find-files "." "\\.[a-z]+$")) (("^([[:graph:]]+) This file is part of Guix." _ comment-start) (string-append comment-start " This file is part of GNU Guix.")) (("^([[:graph:]]+) Guix --- Nix package management.*" _ comment-start) (string-append comment-start " GNU Guix --- Functional package management for GNU\n")) (("^([[:graph:]]+) Guix is " _ comment-start) (string-append comment-start " GNU Guix is ")) (("^([[:graph:]]+) along with Guix." _ comment-start) (string-append comment-start " along with GNU Guix.")) (("^([[:graph:]]+) Copyright \\(C\\)" _ comment-start) (string-append comment-start " Copyright ©"))) Change headers using C-style comments manually.
2012-12-05tests: Remove hard-coded /nix/store.Ludovic Courtès
* tests/utils.scm ("store-path-package-name"): Use (%store-prefix) instead of a hard-coded "/nix/store".
2012-11-11Move base32 code to (guix base32).Ludovic Courtès
* guix/utils.scm (bytevector-quintet-ref, bytevector-quintet-ref-right, bytevector-quintet-length, bytevector-quintet-fold, bytevector-quintet-fold-right, make-bytevector->base32-string, %nix-base32-chars, %rfc4648-base32-chars, bytevector->base32-string, bytevector->nix-base32-string, bytevector-quintet-set!, bytevector-quintet-set-right!, base32-string-unfold, base32-string-unfold-right, make-base32-string->bytevector, base32-string->bytevector, nix-base32-string->bytevector): Move to... * guix/base32.scm: ... here. New file. * tests/utils.scm (%nix-hash, "bytevector->base32-string", "base32-string->bytevector", "nix-base32-string->bytevector", "sha256 & bytevector->base32-string"): Move to... * tests/base32.scm: ... here. New file * guix-download.in, guix/derivations.scm, guix/packages.scm, guix/snix.scm, tests/builders.scm, tests/derivations.scm: Adjust accordingly. * guix.scm (%public-modules): Add `base32'.