#138 %cargo_test doesn't handle multiline arguments
Closed: Invalid 2 years ago by zbyszek. Opened 2 years ago by dcavalca.

If you write something like:

%cargo_test -- -- \
    --skip test_skeleton_basic \
    --skip test_skeleton_builder_basic \
    --skip test_skeleton_datasec \
    --skip test_skeleton_empty_source

cargo will actually skip all the tests (it'll find zero tests everywhere regardless of what you actually skipped). However, if you put this all on one line it works as expected:

%cargo_test -- -- --skip test_skeleton_basic --skip test_skeleton_builder_basic --skip test_skeleton_datasec --skip test_skeleton_empty_source

I suspect this is something to do with how the macro handles the escaping. You can look at rust-libbpf-cargo for an example package.


https://bugzilla.redhat.com/show_bug.cgi?id=1987153 is another example (and what actually prompted filing this)

Affected packages:

$ grep -E '^%cargo_test.*\\$' rpm-specs/*.spec
rpm-specs/rust-assert_cli.spec:%cargo_test -- --   --skip diff::tests::added_first_line_diff \
rpm-specs/rust-below-common.spec:%cargo_test -- -- \
rpm-specs/rust-bumpalo.spec:%cargo_test -- -- --skip    readme_up_to_date \
rpm-specs/rust-cargo-readme.spec:%cargo_test -- -- --skip    alternate_input_a_little_bit_longer \
rpm-specs/rust-dua-cli.spec:%cargo_test -- --   --skip interactive::app_test::journeys_with_writes::basic_user_journey_with_deletion                \
rpm-specs/rust-easy-cast.spec:%cargo_test -- -- \
rpm-specs/rust-image.spec:%cargo_test -- -- \
rpm-specs/rust-libbpf-cargo.spec:%cargo_test -- -- \
rpm-specs/rust-reqwest0.10.spec:%cargo_test -- -- \
rpm-specs/rust-reqwest.spec:%cargo_test -- -- \
rpm-specs/rust-rustls-native-certs.spec:%cargo_test -- -- \
rpm-specs/rust-shadow-rs.spec:%cargo_test -- -- --skip git::tests::test_git \

(rpm-specs is from https://src.fedoraproject.org/lookaside/rpm-specs-20210729.tar.xz)

this is very weird. i could have sworn that this worked when I made those spec changes, but it looks like this never worked correctly after all? :cry:

I tested with rust-nix:

-%cargo_test -- -- --skip sys::test_socket::test_af_alg_aead
+%cargo_test -- -- \
+  --skip sys::test_socket::test_af_alg_aead

and it seems to work fine:

running 91 tests                                                                                        
test src/kmod.rs - kmod::finit_module (line 73) - compile ... ok                                        test src/kmod.rs - kmod::delete_module (line 111) - compile ... ok           
...

With

-%cargo_test -- -- --skip sys::test_socket::test_af_alg_aead
+%cargo_test -- -- \
+  --skip sys::test_socket::test_af_alg_aead \
+  --skip sys::test_socket::test_af_alg_aead

still 91 tests.

I wanted to check rhbz#1987153, but it has a whole tree of dependencies. Is this all just a ploy to get more reviews? ;--[]
Challenge accepted, I'll do some reviews first.

I can see the issue. It reproduces in F33 (using rpmspec -P), but not in F35. I thought this is caused by the changes in rust-packaging, but it doesn't seem to be. So it must be something in rpm or the other tools.

It also reproduces in F34. F34 has rpm-4.16.1.3-1.fc34, while F35 and rawhide have rpm-4.17.0. I don't see anything relevant in the release notes, except maybe "Unify built-in and user-define macro syntax and calling conventions". @pmatilai, @ffesti any idea?

What do you mean by reproducing here (with rpmspec -P), exactly? I'm not familiar with the rust/cargo packaging so it all looks the same to me :sweat_smile:

F33:

$ cat rust-nix.spec | grep -A4 %check
%check
# skip a test that tends to hang in systemd-nspawn environments
%cargo_test -- -- \
  --skip sys::test_socket::test_af_alg_aead \
  --skip sys::test_socket::test_af_alg_aead
$ rpmspec -P *spec | grep -A4 %check
%check
# skip a test that tends to hang in systemd-nspawn environments

  /usr/bin/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 /usr/bin/cargo test -j12 -Z avoid-dev-deps --release --no-fail-fast -- \ 
(empty line here)

Same file, F35:

$ rpmspec -P $PWD/*spec|grep -A5 %check
%check
# skip a test that tends to hang in systemd-nspawn environments

/usr/bin/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 /usr/bin/cargo test -j4 -Z avoid-dev-deps --release --no-fail-fast -- \  --skip sys::test_socket::test_af_alg_aead \
  --skip sys::test_socket::test_af_alg_aead

Okay so it's really a case of something suddenly working right in F35 whereas it never did in older versions.

I wasn't able to reproduce the issue on my system, but if it's this then it may not be entirely reproducable in the affected versions: https://github.com/rpm-software-management/rpm/commit/6d7fa91949337c7a86bab3359b39558fdae07dce

That was pulled to 4.16.1.3 though, which was made available as an update to both Fedora 33 and 34 so there would be a difference between GA and up-to-date versions.

I have rpm-4.16.1.3-1.fc33.x86_64 and rpm-4.17.0-1.fc35.x86_64 and they behave different.

What is the expected behaviour: should the lines after the break symbol be there in the processed file?

Well, something is behaving differently. Like I said, I can't see this difference of behavior when testing with different rpm versions on the same system.

The expectation is a good question, not sure anybody really knows. See https://bugzilla.redhat.com/show_bug.cgi?id=1045723 where macros are expecting to pass a literal \ in the macro arguments.

It all seems verify iffy.

%global FOO foo
%FOO \
xxx

If line continuation symbols were supported by rpm, I would expect that this would be the same as %FOO xxx and would expand to foo xxx. But rpm seems to just pass backslashes through. Fine. But I would expect this to expand to

foo 
xxx

Instead it seems to expand to

foo \ xxx

(rpm 4.17.0)
OR

foo

(rpm 4.16.1.3)

Based on the comments in 1045723, it seems that the "new" behaviour in 4.17.0 is what people were expecting even back then, and the version in F21 did something like this in the end.

Sure it's iffy and strange because there's no specification and nobody knows how various corner cases are supposed to work. It also depends on the context - spec files vs macro files and so on.
Feel free to file an upstream ticket about it.

https://github.com/rpm-software-management/rpm/issues/1857

Let's close this, as this seems to be rpm issue that we can't fix here.

Metadata Update from @zbyszek:
- Issue close_status updated to: Invalid
- Issue status updated to: Closed (was: Open)

2 years ago

Login to comment on this ticket.

Metadata