diff --git a/tests/Sanity/publish_to_crates_io_warns/main.fmf b/tests/Sanity/publish_to_crates_io_warns/main.fmf new file mode 100644 index 0000000..8f5a071 --- /dev/null +++ b/tests/Sanity/publish_to_crates_io_warns/main.fmf @@ -0,0 +1,12 @@ +summary: Test cargo warning when publish to crates.io +description: | + Downstreamed version of the upstream test publish_to_crates_io_warns: + https://github.com/rust-lang/cargo/blob/0.94.0/tests/testsuite/package.rs#L7741 + + Originally implemented in https://github.com/rust-lang/cargo/pull/16241 + + We need to downstream this test because koji builders don't have DNS resolving + to reach crates.io index. Hence, running this during the build will always + fail with an unexpected "Could not resolve host: index.crates.io" message. + +tier: 1 diff --git a/tests/Sanity/publish_to_crates_io_warns/runtest.sh b/tests/Sanity/publish_to_crates_io_warns/runtest.sh new file mode 100755 index 0000000..0fefc15 --- /dev/null +++ b/tests/Sanity/publish_to_crates_io_warns/runtest.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +CRATE_NAME="foo" +CRATE_VER="0.1.0" + +function generate_cargo_toml() { + local dest_dir=$1 + tee "$dest_dir/Cargo.toml" < src/main.rs" + rlRun "set -o pipefail" + rlPhaseEnd + + rlPhaseStartTest + # Publish using dry-run to avoid real operations. + rlRun "cargo publish --dry-run |& tee output.log" + # Ensure DNS was not able to resolve the remote + rlAssertGrep 'Updating crates.io index' output.log + # Verify that cargo raises the warning + rlAssertGrep 'warning: manifest' output.log + # Verify packaging is done + rlAssertGrep "Packaging $CRATE_NAME v$CRATE_VER" output.log + rlAssertGrep "Verifying $CRATE_NAME v$CRATE_VER" output.log + rlAssertGrep "Compiling $CRATE_NAME v$CRATE_VER" output.log + rlAssertGrep "Uploading $CRATE_NAME v$CRATE_VER" output.log + # Verify warning about upload cancel + rlAssertGrep 'warning: aborting upload due to dry run' output.log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd