[carton] 351/472: sort snapshot formats

Lucas Kanashiro kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:39:23 UTC 2015


This is an automated email from the git hooks/post-receive script.

kanashiro-guest pushed a commit to branch master
in repository carton.

commit ae4439531dc573e4d2a7ccd920cf8ea561c1574e
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date:   Tue Jul 23 18:40:21 2013 -0700

    sort snapshot formats
---
 lib/Carton/Lockfile.pm         |  2 +-
 lib/Carton/Lockfile/Emitter.pm |  4 ++--
 xt/cli/snapshot.t              | 23 +++++++++++++++++++++++
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lib/Carton/Lockfile.pm b/lib/Carton/Lockfile.pm
index e95568f..19dee70 100644
--- a/lib/Carton/Lockfile.pm
+++ b/lib/Carton/Lockfile.pm
@@ -165,7 +165,7 @@ sub find_installs {
     }
 
     my @new_dists;
-    for my $module (keys %installs) {
+    for my $module (sort keys %installs) {
         push @new_dists, $installs{$module};
     }
 
diff --git a/lib/Carton/Lockfile/Emitter.pm b/lib/Carton/Lockfile/Emitter.pm
index 255eaeb..8ffd254 100644
--- a/lib/Carton/Lockfile/Emitter.pm
+++ b/lib/Carton/Lockfile/Emitter.pm
@@ -9,7 +9,7 @@ sub emit {
     $data .= "# carton snapshot format: version @{[$lockfile->version]}\n";
     $data .= "DISTRIBUTIONS\n";
 
-    for my $dist ($lockfile->distributions) {
+    for my $dist (sort { $a->name cmp $b->name } $lockfile->distributions) {
         $data .= "  @{[$dist->name]}\n";
         $data .= "    pathname: @{[$dist->pathname]}\n";
 
@@ -19,7 +19,7 @@ sub emit {
         }
 
         $data .= "    requirements:\n";
-        for my $module ($dist->required_modules) {
+        for my $module (sort $dist->required_modules) {
             $data .= "      $module @{[ $dist->requirements_for_module($module) || '0' ]}\n";
         }
     }
diff --git a/xt/cli/snapshot.t b/xt/cli/snapshot.t
new file mode 100644
index 0000000..cf96fac
--- /dev/null
+++ b/xt/cli/snapshot.t
@@ -0,0 +1,23 @@
+use strict;
+use Test::More;
+use xt::CLI;
+
+subtest 'snapshot file has canonical representation' => sub {
+    my $app = cli();
+    $app->write_cpanfile(<<EOF);
+requires 'Try::Tiny', '== 0.11';
+requires 'Getopt::Long', '2.41';
+EOF
+
+    $app->run("install");
+
+    my $content = $app->dir->child('cpanfile.snapshot')->slurp;
+    for (1..3) {
+        $app->dir->child('cpanfile.snapshot')->remove;
+        $app->run("install");
+        is $content, $app->dir->child('cpanfile.snapshot')->slurp;
+    }
+};
+
+done_testing;
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/carton.git



More information about the Pkg-perl-cvs-commits mailing list