From d82a302d775a593cb62f06d8aa02484a7f2a7a2b Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Mon, 13 Jan 2025 21:53:22 -0500 Subject: [PATCH] Restore testing by using the GitHub archive as an additional source --- .gitignore | 1 + jiff-fix-metadata-auto.diff | 2 +- jiff-fix-metadata.diff | 2 +- rust-jiff.spec | 26 +++++++++++---- rust2rpm.toml | 65 ++++++++++++++++++++++++------------- sources | 1 + 6 files changed, 66 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 8f96439..e53d9c3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ /jiff-0.1.20.crate /jiff-0.1.21.crate /jiff-0.1.23.crate +/jiff-0.1.23.tar.gz diff --git a/jiff-fix-metadata-auto.diff b/jiff-fix-metadata-auto.diff index 7d033ac..7849e87 100644 --- a/jiff-fix-metadata-auto.diff +++ b/jiff-fix-metadata-auto.diff @@ -1,5 +1,5 @@ --- jiff-0.1.23/Cargo.toml 1970-01-01T00:00:01+00:00 -+++ jiff-0.1.23/Cargo.toml 2025-01-14T02:33:55.951394+00:00 ++++ jiff-0.1.23/Cargo.toml 2025-01-14T03:03:22.824286+00:00 @@ -141,7 +141,6 @@ [features] alloc = [ diff --git a/jiff-fix-metadata.diff b/jiff-fix-metadata.diff index b519959..37ae527 100644 --- a/jiff-fix-metadata.diff +++ b/jiff-fix-metadata.diff @@ -1,5 +1,5 @@ --- jiff-0.1.23/Cargo.toml 1970-01-01T00:00:01+00:00 -+++ jiff-0.1.23/Cargo.toml 2025-01-14T02:33:55.952394+00:00 ++++ jiff-0.1.23/Cargo.toml 2025-01-14T03:03:22.825286+00:00 @@ -118,9 +118,6 @@ [dev-dependencies.serde_json] version = "1.0.117" diff --git a/rust-jiff.spec b/rust-jiff.spec index bec1167..b050b88 100644 --- a/rust-jiff.spec +++ b/rust-jiff.spec @@ -1,8 +1,5 @@ # Generated by rust2rpm 27 -# * Since 0.1.22, src/tz/snapshots/ and src/tz/testdata/ are no longer included -# in the crate, so it is not feasible to run the tests without a separate -# source archive. -%bcond check 0 +%bcond check 1 %global debug_package %{nil} %global crate jiff @@ -15,6 +12,13 @@ Summary: Date-time library that encourages you to jump into the pit of su License: Unlicense OR MIT URL: https://crates.io/crates/jiff Source: %{crates_source} +# * Since 0.1.22, the published crates no longer include “non-essential files +# (including tests and test data).” Since we would like to run the tests, we +# use the GitHub archive as an additonal source as permitted in +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/#_package_sources, +# waiting until %%check to copy in the extra files to prove they are not +# included in the crate sources shipped in the binary RPMs. +Source10: https://github.com/BurntSushi/jiff/archive/%{version}/jiff-%{version}.tar.gz # Automatically generated patch to strip dependencies and normalize metadata Patch: jiff-fix-metadata-auto.diff # Manually created patch for downstream crate metadata changes @@ -32,9 +36,9 @@ Patch12: 0001-Downstream-only-omit-tests-that-require-serde_yml.patch # * EPEL9: Ignore doctests that require very recent Rust compilers # * In this crate, doctests and examples (but not the lib and integration tests) # are allowed to use Rust features from versions newer than the MSRV. It’s -# therefore necessary to ignore some of them on EPEL9. If this patch becomes -# too unwieldy, we could choose to start skipping doctests and/or examples -# there entirely. +# therefore necessary to ignore some of them on EPEL9. If this patch becomes too +# unwieldy, we could choose to start skipping doctests and/or examples there +# entirely. Patch1009: 0001-EPEL9-Ignore-doctests-that-require-very-recent-Rust-.patch BuildRequires: cargo-rpm-macros >= 24 @@ -198,6 +202,14 @@ tomcli set Cargo.toml del dev-dependencies.icu %if %{with check} %check +# Copy in snapshots, integration tests, and test data – required to run tests, +# but not included in the released crate. By doing so here in %%check rather +# than in %%prep, we prove that the binary RPMs are derived solely from the +# published crate sources. +tar -xzvf '%{SOURCE10}' --strip-components=1 \ + jiff-%{version}/src/tz/snapshots \ + jiff-%{version}/src/tz/testdata \ + jiff-%{version}/tests %cargo_test -f serde %endif diff --git a/rust2rpm.toml b/rust2rpm.toml index c7fcf4e..7ebf5a8 100644 --- a/rust2rpm.toml +++ b/rust2rpm.toml @@ -25,6 +25,20 @@ cargo-toml-patch-comments = [ """, ] +[[package.extra-sources]] +number = 10 +file = "https://github.com/BurntSushi/jiff/archive/%{version}/jiff-%{version}.tar.gz" +comments = [ + """\ + Since 0.1.22, the published crates no longer include “non-essential files \ + (including tests and test data).” Since we would like to run the tests, we \ + use the GitHub archive as an additonal source as permitted in \ + https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/#_package_sources, \ + waiting until %%check to copy in the extra files to prove they are not \ + included in the crate sources shipped in the binary RPMs.\ + """, +] + [[package.extra-patches]] number = 10 file = "0001-Downstream-only-Omit-doctests-that-require-hifitime.patch" @@ -59,11 +73,11 @@ file = "0001-EPEL9-Ignore-doctests-that-require-very-recent-Rust-.patch" comments = [ "EPEL9: Ignore doctests that require very recent Rust compilers", """\ - In this crate, doctests and examples (but not the lib and integration tests) \ - are allowed to use Rust features from versions newer than the MSRV. It’s \ - therefore necessary to ignore some of them on EPEL9. If this patch becomes too \ - unwieldy, we could choose to start skipping doctests and/or examples there \ - entirely.\ +In this crate, doctests and examples (but not the lib and integration tests) +are allowed to use Rust features from versions newer than the MSRV. It’s +therefore necessary to ignore some of them on EPEL9. If this patch becomes too +unwieldy, we could choose to start skipping doctests and/or examples there +entirely.\ """, ] @@ -75,27 +89,34 @@ build = [ [scripts.prep] pre = [ - "# NOTE: The -p1 in %%autosetup, above, must be replaced with -N so that we can", - "# do conditional patching, below.", - "%autopatch -M 999 -p1", - "# We reserved patch number 1000+ for EPEL.", - "%if 0%{?el9}", + """\ +# NOTE: The -p1 in %%autosetup, above, must be replaced with -N so that we can +# do conditional patching, below. +%autopatch -M 999 -p1 +# We reserved patch number 1000+ for EPEL.\ +""", # EPEL9 rpm does not support "%patch ", and would quietly attempt and # fail to re-apply Patch0 instead of applying the desired patch. We *need* # to use "%patch -P " instead. - "%patch -P 1009 -p1", - "%endif", - "# We do not yet have a rust-icu package (although one would be desirable)", - "tomcli set Cargo.toml del dev-dependencies.icu", + """\ +%if 0%{?el9} +%patch -P 1009 -p1 +%endif +# We do not yet have a rust-icu package (although one would be desirable) +tomcli set Cargo.toml del dev-dependencies.icu\ +""" ] - -[tests] -comments = [ +[scripts.check] +pre = [ """\ - Since 0.1.22, src/tz/snapshots/ and src/tz/testdata/ are no longer included \ - in the crate, so it is not feasible to run the tests without a separate \ - source archive.\ - """, +# Copy in snapshots, integration tests, and test data – required to run tests, +# but not included in the released crate. By doing so here in %%check rather +# than in %%prep, we prove that the binary RPMs are derived solely from the +# published crate sources. +tar -xzvf '%{SOURCE10}' --strip-components=1 \\ + jiff-%{version}/src/tz/snapshots \\ + jiff-%{version}/src/tz/testdata \\ + jiff-%{version}/tests\ +""", ] -run = ["none"] diff --git a/sources b/sources index b18be88..660f78b 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ SHA512 (jiff-0.1.23.crate) = 9faac5b8f560023b68d6e0fecc2cab898deb9bee816af47994fcb9212cb49a5513fcff5031fe493b939ceb6ef907852764b78d5395d7adfc6adcba3f0191d476 +SHA512 (jiff-0.1.23.tar.gz) = 067adc05341143dfd539317d6b2aae3f1fc5f2127ad265462aea8aec1e07d054290eb2a245eb07f7514204920d5c066289d475f841ac4a7c9f857dbad95896c7