From 86ed0039908e45c44d32c82192414735566f1cd0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 6 Nov 2021 23:00:05 +0100 Subject: tests: Avoid literal strings for invalid Texinfo markup. This is a followup to e171182a20962c4119e12439b92bbbfd59b1495e. * tests/lint.scm ("description: invalid Texinfo markup") ("synopsis: valid Texinfo markup"): Add call to 'identity' to avoid triggering a syntax error. --- tests/lint.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/lint.scm b/tests/lint.scm index 6a7eed02e0..9a91dd5426 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -107,7 +107,7 @@ "Texinfo markup in description is invalid" (single-lint-warning-message (check-description-style - (dummy-package "x" (description "f{oo}b@r"))))) + (dummy-package "x" (description (identity "f{oo}b@r")))))) (test-equal "description: does not start with an upper-case letter" "description should start with an upper-case letter or digit" @@ -209,7 +209,7 @@ "Texinfo markup in synopsis is invalid" (single-lint-warning-message (check-synopsis-style - (dummy-package "x" (synopsis "Bad $@ texinfo"))))) + (dummy-package "x" (synopsis (identity "Bad $@ texinfo")))))) (test-equal "synopsis: does not start with an upper-case letter" "synopsis should start with an upper-case letter or digit" -- cgit 1.4.1 From b0519cc4b04d29ea9327a117eb6c8c21547e6159 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Wed, 14 Jul 2021 13:12:49 +0200 Subject: utils: Define a target-x86-32? and target-x86-64? predicate. * 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 --- guix/utils.scm | 20 ++++++++++++++++++++ tests/utils.scm | 23 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'tests') diff --git a/guix/utils.scm b/guix/utils.scm index 2920fa7684..7a00640d85 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -79,6 +79,8 @@ %current-target-system package-name->name+version target-mingw? + target-x86-32? + target-x86-64? target-arm32? target-aarch64? target-arm? @@ -535,6 +537,24 @@ a character other than '@'." (and target (string-suffix? "-mingw32" target))) +(define* (target-x86-32? #:optional (target (or (%current-target-system) + (%current-system)))) + "Is the architecture of TARGET a variant of Intel's 32-bit architecture +(IA32)?" + ;; Intel also has a 16-bit architecture in the iN86 series, i286 + ;; (see, e.g. https://en.wikipedia.org/wiki/Intel/808286) so this + ;; procedure is not named target-x86?. + (or (string-prefix? "i386-" target) + (string-prefix? "i486-" target) + (string-prefix? "i586-" target) + (string-prefix? "i686-" target))) + +(define* (target-x86-64? #:optional (target (or (%current-target-system) + (%current-system)))) + "Is the architecture of TARGET a variant of Intel/AMD's 64-bit +architecture (x86_64)?" + (string-prefix? "x86_64-" target)) + (define* (target-arm32? #:optional (target (or (%current-target-system) (%current-system)))) (string-prefix? "arm" target)) diff --git a/tests/utils.scm b/tests/utils.scm index 7fcbb25552..2b7db73905 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -289,6 +289,29 @@ skip these tests." (string-closest "hello" '("kikoo" "helo" "hihihi" "halo")) (string-closest "hello" '("aaaaa" "12345" "hellohello" "h")))) +(test-equal "target-x86-32?" + '(#f #f #f #t #t #t #t #f) + ;; These are (according to Wikipedia) two RISC architectures + ;; by Intel and presumably not compatible with the x86-32 series. + (map target-x86-32? + '("i860-gnu" "i960-gnu" + ;; This is a 16-bit architecture + "i286-gnu" + ;; These are part of the x86-32 series. + "i386-gnu" "i486-gnu" "i586-gnu" "i686-gnu" + ;; Maybe this one will exist some day, but not yet. + "i786-gnu"))) + +(test-equal "target-x86-64?" + '(#t #f #f #f) + (map target-x86-64? + `("x86_64-linux-gnu" "i386-linux-gnu" + ;; Just because it includes "64" doesn't make it 64-bit. + "aarch64-linux-gnu" + ;; Note that (expt 2 109) in decimal notation starts with 64. + ;; However, it isn't 32-bit. + ,(format #f "x86_~a-linux-gnu" (expt 2 109))))) + (test-end) (false-if-exception (delete-file temp-file)) -- cgit 1.4.1 From 4d59596a1c5f6b20870e619cbf67068ac7dd64ff Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 7 Nov 2021 15:56:19 +0100 Subject: ui: 'load*' correctly reports 'read-error' in all cases. Previously, 'read-error' exceptions other than "missing closing paren" would not be reported; instead, we'd directly call (exit 1) without printing anything. Fixes . Reported by Alice BRENON . * guix/ui.scm (report-load-error): Report the error without re-throwing upon 'read-error'. * tests/guix-build.sh: Add test. --- guix/ui.scm | 3 ++- tests/guix-build.sh | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/guix/ui.scm b/guix/ui.scm index b01bb3d587..bd999103ff 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -377,7 +377,8 @@ ARGS is the list of arguments received by the 'throw' handler." (+ 2 (string-contains message ": "))))) (format (current-error-port) (G_ "~amissing closing parenthesis~%") location)) - (apply throw args))) + (report-error (G_ "read error while loading '~a': ~a~%") + file (apply format #f message args)))) (('syntax-error proc message properties form subform . rest) (let ((loc (source-properties->location properties))) (report-error loc (G_ "~s: ~a~%") diff --git a/tests/guix-build.sh b/tests/guix-build.sh index e20702c521..46c8afc901 100644 --- a/tests/guix-build.sh +++ b/tests/guix-build.sh @@ -1,5 +1,5 @@ # GNU Guix --- Functional package management for GNU -# Copyright © 2012, 2013, 2014, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès +# Copyright © 2012, 2013, 2014, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès # Copyright © 2020 Marius Bakke # Copyright © 2021 Chris Marusich # @@ -77,6 +77,16 @@ module_dir="t-guix-build-$$" mkdir "$module_dir" trap "rm -rf $module_dir" EXIT +# Check error reporting for '-f'. +cat > "$module_dir/foo.scm" < "$module_dir/stderr" +grep "read error" "$module_dir/stderr" +rm "$module_dir/stderr" "$module_dir/foo.scm" + +# Check 'GUIX_PACKAGE_PATH' & co. cat > "$module_dir/foo.scm"<