aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHerman Rimm <herman@rimm.ee>2024-09-02 20:58:05 +0200
committerLudovic Courtès <ludo@gnu.org>2024-09-03 13:59:33 +0200
commitc4ce31305258126e0f5809697e084bf97f31f77f (patch)
tree222f24899f6c27d665e2d0620b764693c5ce3753 /tests
parent52681a036a47168edc3380b89d3975ca70d54ab5 (diff)
downloadguix-c4ce31305258126e0f5809697e084bf97f31f77f.tar.gz
guix-c4ce31305258126e0f5809697e084bf97f31f77f.zip
scripts: style: Add 'alphabetical-sort' option.
* guix/scripts/style.scm (show-help): Describe option. (order-packages): Add procedure. (format-whole-file): Add 'order?' argument. (%options): Add 'alphabetical-sort' option. (guix-style): Alphabetically order packages in files. * tests/guix-style.sh: Test alphabetical ordering. * doc/guix.texi (Invoking guix style): Document option. Change-Id: I4aa7c0bd0b6d42529ae7d304587ffb10bf5f4006 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/guix-style.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/guix-style.sh b/tests/guix-style.sh
index 2de879d5e3..9333139435 100644
--- a/tests/guix-style.sh
+++ b/tests/guix-style.sh
@@ -58,6 +58,24 @@ cat > "$tmpfile" <<EOF
;; The services.
(services
(cons (service mcron-service-type) %base-services)))
+;; Incomplete package definitions in alphabetical order.
+
+(define-public pkg
+ (package
+ (name "bar")
+ (version "2")))
+
+;; The comment below belongs to the foo package.
+(define-public pkg
+ (package
+ (name "bar")
+ (version "1")))
+;; Incomplete package definitions in alphabetical order.
+
+(define-public pkg
+ (package
+ (name "foo")
+ (version "2")))
EOF
cp "$tmpfile" "$tmpfile.bak"
@@ -78,3 +96,11 @@ test "$initial_hash" != "$(guix hash "$tmpfile")"
guix style -f "$tmpfile"
test "$initial_hash" = "$(guix hash "$tmpfile")"
+
+# Swap foo and bar packages.
+sed -i "$tmpfile" -e 's/"foo"/"bar"/g'
+sed -i "$tmpfile" -e '0,/"bar"/{s//"foo"/}'
+test "$initial_hash" != "$(guix hash "$tmpfile")"
+
+guix style -fA "$tmpfile"
+test "$initial_hash" = "$(guix hash "$tmpfile")"