diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-01-24 14:12:58 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-01-24 14:12:58 +0000 |
commit | b54121fdb6f2b57fe243bd7c7c9dfc3f460ed393 (patch) | |
tree | 2ae245cdccfc67f6f0d6570c8e2bd9315aa19ba3 /regress | |
parent | 8a4f641845d706a6dc4b05f26b2434e32281dd80 (diff) |
check package name issues
Diffstat (limited to 'regress')
-rw-r--r-- | regress/usr.sbin/pkg_add/check-name | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/regress/usr.sbin/pkg_add/check-name b/regress/usr.sbin/pkg_add/check-name index 238d65bf8af..18ab24744b9 100644 --- a/regress/usr.sbin/pkg_add/check-name +++ b/regress/usr.sbin/pkg_add/check-name @@ -1,9 +1,9 @@ #! /usr/bin/perl -# $OpenBSD: check-name,v 1.9 2010/01/10 00:40:25 espie Exp $ +# $OpenBSD: check-name,v 1.10 2010/01/24 14:12:57 espie Exp $ # Written by Marc Espie # Public domain -use Test::Simple tests => 15; +use Test::Simple tests => 19; use OpenBSD::Search; use OpenBSD::PackageName; @@ -12,10 +12,15 @@ sub check_list my $expected = shift; @_ = sort(@_); if (@$expected != @_) { + print STDERR "length: ", scalar(@$expected)," vs. ", + scalar(@_), "\n"; + print STDERR join(',', @$expected), "\n"; + print STDERR join(',', @_), "\n"; return 0; } for my $i (0 .. @_ -1) { if ($expected->[$i] ne $_[$i]) { + print STDERR "$expected->[$i] vs. $_[$i]\n"; return 0; } } @@ -30,6 +35,12 @@ sub check_pkgspec return $o->filter(@list); } +sub check_name +{ + my $s = shift; + return OpenBSD::PackageName->from_string($s)->has_issues; +} + @list = qw(py-MxDateTime-2.0.1-py2.1); ok(check_list(\@list, check_pkgspec('py-MxDateTime->=2.0-py2.1', @list)), @@ -84,3 +95,12 @@ ok(OpenBSD::PackageName->from_string('foo-1.0-f2-f1')->to_string 'canonical names'); ok(!OpenBSD::Search::PkgSpec->new('foo-<>1.5')->is_valid, 'invalid spec'); + +ok(check_list(["is a stem"], check_name("pkgname-without-version")), + "pkgname without version"); +ok(check_list(["flavor 1flavor can't start with digit"], + check_name("pkgname-1.0-flavor-1flavor")), + "numerical flavor"); +ok(check_list(["correct order is pNvM"], check_name("pkgname-1.0v0p0")), + "mixed up vp"); +ok(check_list([], check_name("pkgname-1.0p0v0")), "correct name"); |