guix: lint: Check for misplaced argument flags.

* guix/lint.scm (check-misplaced-flags): New procedure.
(%local-checkers): Register new lint-checker.
* doc/guix.texi (Invoking guix lint): Add entry for misplaced-flags.
* tests/lint.scm (misplaced-flags: make-flag is incorrect,
misplaced-flags: configure-flag is incorrect, misplaced-flags: cargo
feature flags, misplaced-flags: flags without g-exp is incorrect,
misplaced-flags: build-type set correctly): New tests.

Change-Id: Ia8abbe787e26bffc65ee5c763326c7e271c189a4
This commit is contained in:
Efraim Flashner 2025-07-09 09:58:46 +03:00
parent fb8574b148
commit 54717bb5b3
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351
3 changed files with 128 additions and 1 deletions

View file

@ -414,6 +414,50 @@
(list #:target #false
#:make-flags #~(list "CC=gcc"))))))
(test-equal "misplaced-flags: make-flag is incorrect"
"'CMAKE_BUILD_TYPE' should be set with the 'build-type' flag"
(single-lint-warning-message
(check-misplaced-flags
(dummy-package "x"
(arguments
(list #:make-flags #~(list "-DCMAKE_BUILD_TYPE=RELEASE"
"-DTESTS=ON")))))))
(test-equal "misplaced-flags: configure-flag is incorrect"
"'buildtype' should be set with the 'build-type' flag"
(single-lint-warning-message
(check-misplaced-flags
(dummy-package "x"
(arguments
(list #:configure-flags #~(list "--buildtype=release"
"--with-tests")))))))
(test-equal "misplaced-flags: cargo feature flags"
"'features' should be set with the 'features' flag"
(single-lint-warning-message
(check-misplaced-flags
(dummy-package "x"
(arguments
'(#:cargo-test-flags
'("--features" "force_system_lib")))))))
(test-equal "misplaced-flags: flags without g-exp is incorrect"
"'CMAKE_BUILD_TYPE' should be set with the 'build-type' flag"
(single-lint-warning-message
(check-misplaced-flags
(dummy-package "x"
(arguments
'(#:make-flags '("-DCMAKE_BUILD_TYPE=RELEASE"
"-DTESTS=ON")))))))
(test-equal "misplaced-flags: build-type set correctly"
'()
(check-misplaced-flags
(dummy-package "x"
(arguments
(list #:build-type "RELEASE"
#:make-flags #~(list "-DTESTS=ON"))))))
;; The emacs-build-system sets #:tests? #f by default.
(test-equal "tests-true: #:tests? #t acceptable for emacs packages"
'()