[carton] 357/472: Add an exception when parsing fails.
Lucas Kanashiro
kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:39:24 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 bb9da3be2780fda628db0caccccf4e368c636343
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date: Wed Jul 24 00:29:14 2013 -0700
Add an exception when parsing fails.
---
lib/Carton/Snapshot/Parser.pm | 4 ++--
xt/cli/snapshot.t | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/lib/Carton/Snapshot/Parser.pm b/lib/Carton/Snapshot/Parser.pm
index b3e720d..9a90ab3 100644
--- a/lib/Carton/Snapshot/Parser.pm
+++ b/lib/Carton/Snapshot/Parser.pm
@@ -1,6 +1,7 @@
package Carton::Snapshot::Parser;
use strict;
use Carton::Dist;
+use Carton::Error;
use Moo;
my $machine = {
@@ -117,9 +118,8 @@ sub parse {
}
}
- die "SOMETHING IS WRONG $line";
+ Carton::Error::SnapshotParseError->throw(error => "Could not parse snapshot file.");
}
-
}
}
diff --git a/xt/cli/snapshot.t b/xt/cli/snapshot.t
index cf96fac..2b0254d 100644
--- a/xt/cli/snapshot.t
+++ b/xt/cli/snapshot.t
@@ -19,5 +19,30 @@ EOF
}
};
+subtest 'Bad snapshot version' => sub {
+ my $app = cli();
+ $app->write_cpanfile('');
+ $app->write_file('cpanfile.snapshot', <<EOF);
+# carton snapshot format: version 111
+EOF
+
+ $app->run("install");
+ like $app->stderr, qr/Could not parse/;
+};
+
+subtest 'Bad snapshot file' => sub {
+ my $app = cli();
+ $app->write_cpanfile('');
+ $app->write_file('cpanfile.snapshot', <<EOF);
+# carton snapshot format: version 1.0
+DISTRIBUTIONS
+ Foo-Bar-1
+ unknown: foo
+EOF
+
+ $app->run("install");
+ like $app->stderr, qr/Could not parse/;
+};
+
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