diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2006-01-19 13:05:54 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2006-01-19 13:05:54 +0000 |
commit | ec9cacadc5e93e90a4c4e859a04c716edba442b3 (patch) | |
tree | 6767aedb57ffc5c77d4ef77ecc4f6820463bafae | |
parent | 35a1e7817d16df95fa4a416c9a9ac2c9a059c9de (diff) | |
download | perl-URPM-ec9cacadc5e93e90a4c4e859a04c716edba442b3.tar perl-URPM-ec9cacadc5e93e90a4c4e859a04c716edba442b3.tar.gz perl-URPM-ec9cacadc5e93e90a4c4e859a04c716edba442b3.tar.bz2 perl-URPM-ec9cacadc5e93e90a4c4e859a04c716edba442b3.tar.xz perl-URPM-ec9cacadc5e93e90a4c4e859a04c716edba442b3.zip |
Return undef on spec parsing failure
-rw-r--r-- | URPM.xs | 9 | ||||
-rw-r--r-- | t/parse.t | 9 |
2 files changed, 13 insertions, 5 deletions
@@ -3654,24 +3654,27 @@ Urpm_spec2srcheader(specfile) URPM__Package pkg; Spec spec = NULL; PPCODE: +/* Do not verify architecture */ #define SPEC_ANYARCH 1 +/* Do not verify whether sources exist */ #define SPEC_FORCE 1 if (!parseSpec(ts, specfile, "/", NULL, 0, NULL, NULL, SPEC_ANYARCH, SPEC_FORCE)) { + SV *sv_pkg; spec = rpmtsSetSpec(ts, NULL); - if ( ! spec->sourceHeader) + if (! spec->sourceHeader) initSourceHeader(spec); pkg = (URPM__Package)malloc(sizeof(struct s_Package)); memset(pkg, 0, sizeof(struct s_Package)); pkg->h = headerLink(spec->sourceHeader); - SV *sv_pkg; EXTEND(SP, 1); sv_pkg = sv_newmortal(); sv_setref_pv(sv_pkg, "URPM::Package", (void*)pkg); PUSHs(sv_pkg); spec = freeSpec(spec); + } else { + PUSHs(&PL_sv_undef); } ts = rpmtsFree(ts); - void expand(name) @@ -4,12 +4,15 @@ use strict; use warnings; -use Test::More tests => 26; +use Test::More tests => 27; use MDV::Packdrakeng; use URPM; use URPM::Build; use URPM::Query; +# shut up +URPM::setVerbosity(2); + my $a = new URPM; ok($a); @@ -66,5 +69,7 @@ ok(URPM::rpmvercmp("1:1-1mdk", "2:1-1mdk") == -1, "epoch 1 vs 2 = -1"); { my $pkg = URPM::spec2srcheader("test-rpm.spec"); ok(defined $pkg, "Parsing a spec works"); - ok($pkg->get_tag(1000) eq 'test-rpm'); + ok($pkg->get_tag(1000) eq 'test-rpm', 'parsed correctly'); + $pkg = URPM::spec2srcheader("doesnotexist.spec"); + ok(!defined $pkg, "non-existent spec"); } |