Merge ~blkerby/ubuntu/+source/rustc:fix-create-and-build-crate into ~canonical-foundations/ubuntu/+source/rustc:merge-1.91

Proposed by Brent Kerby
Status: Merged
Merge reported by: Max Gilmour
Merged at revision: 612e7c4646cb71652eab11ceca03f6c87757496c
Proposed branch: ~blkerby/ubuntu/+source/rustc:fix-create-and-build-crate
Merge into: ~canonical-foundations/ubuntu/+source/rustc:merge-1.91
Diff against target: 61 lines (+16/-10)
2 files modified
debian/tests/control (+2/-2)
debian/tests/create-and-build-crate (+14/-8)
Reviewer Review Type Date Requested Status
Max Gilmour Approve
Review via email: mp+498229@code.launchpad.net

Description of the change

Currently the "create-and-build-crate" test uses the system version of cargo and rustc (1.88), meaning it's not actually testing the version built by the package. So this merge proposal updates it to use the correct version. A few other changes:
- In the test Depends, replace @builddeps@ with @. The build dependencies are not needed for this test and are what resulted in the wrong cargo/rustc versions being available.
- In the test Restrictions, drop "rw-build-tree", as it isn't needed for this test.
- Include the "-x" bash option, to be able to see the commands being executed. This helped with debugging the test and also makes clear which versions are being used. This writes to stderr but we are already using the "allow-stderr" restriction so it works.

To post a comment you must log in.
Revision history for this message
Max Gilmour (maxgmr) wrote :

Great catch, thanks! Merging.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/tests/control b/debian/tests/control
2index 4cbda53..af2d84e 100644
3--- a/debian/tests/control
4+++ b/debian/tests/control
5@@ -3,8 +3,8 @@ Depends: @, @builddeps@
6 Restrictions: rw-build-tree, allow-stderr
7
8 Tests: create-and-build-crate
9-Restrictions: rw-build-tree, allow-stderr
10-Depends: @builddeps@
11+Restrictions: allow-stderr
12+Depends: @
13
14 Tests: versioned-cargo-wrapper
15 Depends: @, cargo
16diff --git a/debian/tests/create-and-build-crate b/debian/tests/create-and-build-crate
17index 46cc2a0..af5e2a0 100755
18--- a/debian/tests/create-and-build-crate
19+++ b/debian/tests/create-and-build-crate
20@@ -1,10 +1,16 @@
21 #!/bin/bash
22-set -euo pipefail
23+set -euox pipefail
24+
25+RUST_VERSION=$(dpkg-parsechangelog -SVersion | sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/')
26+
27+# Set RUSTC so that `cargo` knows which rustc to use
28+export RUSTC=/usr/lib/rust-${RUST_VERSION}/bin/rustc
29+CARGO=/usr/lib/rust-${RUST_VERSION}/bin/cargo
30
31 tmpdir=$(mktemp -d)
32 cd "$tmpdir"
33
34-cargo new hello
35+${CARGO} new hello
36 cd hello
37
38 cat <<EOF > src/main.rs
39@@ -21,8 +27,8 @@ fn test() {
40 }
41 EOF
42
43-cargo add 'anyhow@^1'
44-cargo vendor
45+${CARGO} add 'anyhow@^1'
46+${CARGO} vendor
47
48 mkdir -p .cargo
49 cat <<EOF > .cargo/config.toml
50@@ -33,7 +39,7 @@ replace-with = "vendored-sources"
51 directory = "vendor"
52 EOF
53
54-cargo check
55-cargo build
56-cargo test
57-cargo run
58+${CARGO} check
59+${CARGO} build
60+${CARGO} test
61+${CARGO} run

Subscribers

People subscribed via source and target branches