|
1 | 1 | #!/usr/bin/perl -w |
2 | 2 |
|
3 | 3 | use strict; |
4 | | -use Test::More tests => 19; |
| 4 | +use Test::More tests => 22; |
5 | 5 |
|
6 | 6 | use Build; |
7 | 7 | use Build::Rpm; |
@@ -495,3 +495,83 @@ $expected = { |
495 | 495 | }; |
496 | 496 | $result = Build::Rpm::parse($conf, [ split("\n", $spec) ]); |
497 | 497 | is_deeply($result, $expected, "option macros with negation"); |
| 498 | + |
| 499 | +# Test filename fallback when Name: tag is missing |
| 500 | +$spec = q{ |
| 501 | +Version: 1.0 |
| 502 | +Release: 1 |
| 503 | +BuildRequires: foo |
| 504 | +}; |
| 505 | +$expected = { |
| 506 | + 'name' => 'test-package', |
| 507 | + 'version' => '1.0', |
| 508 | + 'release' => '1', |
| 509 | + 'deps' => [ 'foo' ], |
| 510 | + 'subpacks' => [ 'test-package' ], |
| 511 | +}; |
| 512 | +$result = Build::Rpm::parse($conf, [ split("\n", $spec) ], 'recipename' => 'test-package.spec'); |
| 513 | +is_deeply($result, $expected, "filename fallback for missing Name tag"); |
| 514 | + |
| 515 | +# Test filename fallback when Name: tag contains unresolved macro |
| 516 | +$spec = q{ |
| 517 | +Name: %{undefined_macro} |
| 518 | +Version: 1.0 |
| 519 | +Release: 1 |
| 520 | +BuildRequires: bar |
| 521 | +}; |
| 522 | +$expected = { |
| 523 | + 'name' => 'my-package', |
| 524 | + 'version' => '1.0', |
| 525 | + 'release' => '1', |
| 526 | + 'deps' => [ 'bar' ], |
| 527 | + 'subpacks' => [ 'my-package' ], |
| 528 | +}; |
| 529 | +$result = Build::Rpm::parse($conf, [ split("\n", $spec) ], 'recipename' => 'my-package.spec'); |
| 530 | +is_deeply($result, $expected, "filename fallback for macro-based Name tag"); |
| 531 | + |
| 532 | +# Test rpmautospec-style spec file (similar to vazirmatn-fonts.spec) |
| 533 | +$spec = q{ |
| 534 | +## START: Set by rpmautospec |
| 535 | +## RPMAUTOSPEC: autorelease, autochangelog |
| 536 | +%define autorelease(e:s:pb:n) %{?-p:0.}%{lua: |
| 537 | + release_number = 10; |
| 538 | + base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); |
| 539 | + print(release_number + base_release_number - 1); |
| 540 | +}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} |
| 541 | +## END: Set by rpmautospec |
| 542 | +
|
| 543 | +Version: 33.003 |
| 544 | +Release: %autorelease |
| 545 | +URL: https://example.com/project |
| 546 | +
|
| 547 | +%global fontlicense OFL-1.1 |
| 548 | +%global common_description A test font package |
| 549 | +
|
| 550 | +Source0: https://example.com/release/v%{version}/font-v%{version}.zip |
| 551 | +
|
| 552 | +%prep |
| 553 | +%setup -q -c |
| 554 | +
|
| 555 | +%build |
| 556 | +# Build commands here |
| 557 | +
|
| 558 | +%install |
| 559 | +# Install commands here |
| 560 | +
|
| 561 | +%files |
| 562 | +# File list here |
| 563 | +
|
| 564 | +%changelog |
| 565 | +# Generated by rpmautospec |
| 566 | +}; |
| 567 | +$expected = { |
| 568 | + 'name' => 'vazirmatn-fonts', |
| 569 | + 'version' => '33.003', |
| 570 | + 'release' => '%{lua:', |
| 571 | + 'url' => 'https://example.com/project', |
| 572 | + 'source0' => 'https://example.com/release/v33.003/font-v33.003.zip', |
| 573 | + 'deps' => [], |
| 574 | + 'subpacks' => [ 'vazirmatn-fonts' ], |
| 575 | +}; |
| 576 | +$result = Build::Rpm::parse($conf, [ split("\n", $spec) ], 'recipename' => 'vazirmatn-fonts.spec'); |
| 577 | +is_deeply($result, $expected, "rpmautospec-style spec file with filename fallback"); |
0 commit comments