Merge ~blkerby/ubuntu/+source/rustc:test-build-std into ~canonical-foundations/ubuntu/+source/rustc:merge-1.91

Proposed by Brent Kerby
Status: Merged
Merged at revision: e06807b1e67c2246307112fa3c2ab2f18f511764
Proposed branch: ~blkerby/ubuntu/+source/rustc:test-build-std
Merge into: ~canonical-foundations/ubuntu/+source/rustc:merge-1.91
Diff against target: 54 lines (+39/-0)
2 files modified
debian/tests/build-std (+35/-0)
debian/tests/control (+4/-0)
Reviewer Review Type Date Requested Status
Max Gilmour Approve
Review via email: mp+498241@code.launchpad.net

Description of the change

Add an autopkgtest test to ensure that the Cargo unstable feature "-Z build-std" works correctly with the vendored standard library installed by rust-X.Y-src.

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

Looks good, merged. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/tests/build-std b/debian/tests/build-std
2new file mode 100644
3index 0000000..7995525
4--- /dev/null
5+++ b/debian/tests/build-std
6@@ -0,0 +1,35 @@
7+#!/bin/bash
8+# Test that the `-Z build-std` unstable Cargo feature works,
9+# using the vendored standard library dependencies.
10+set -euox pipefail
11+
12+RUST_VERSION=$(dpkg-parsechangelog -SVersion | sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/')
13+RUST_FULL_VERSION=$(dpkg-parsechangelog -SVersion | sed -re 's/([^+]+).*/\1/')
14+
15+# Set RUSTC so that `cargo` knows which rustc to use
16+export RUSTC=/usr/lib/rust-${RUST_VERSION}/bin/rustc
17+CARGO=/usr/lib/rust-${RUST_VERSION}/bin/cargo
18+
19+tmpdir=$(mktemp -d)
20+cd "$tmpdir"
21+
22+${CARGO} new hello
23+cd hello
24+
25+${CARGO} add serde # add dummy dependency so "cargo vendor" doesn't complain
26+${CARGO} vendor --versioned-dirs
27+
28+# Merge in the standard library dependencies (installed by rust-X.Y-src)
29+# into the vendor directory as symlinks:
30+ln -s /usr/src/rustc-${RUST_FULL_VERSION}/vendor/* vendor/
31+
32+mkdir .cargo
33+cat <<EOF >.cargo/config.toml
34+[source.crates-io]
35+replace-with = "vendored-sources"
36+
37+[source.vendored-sources]
38+directory = "vendor"
39+EOF
40+
41+RUSTC_BOOTSTRAP=1 ${CARGO} run -Z build-std --offline
42diff --git a/debian/tests/control b/debian/tests/control
43index 4cbda53..5311ef1 100644
44--- a/debian/tests/control
45+++ b/debian/tests/control
46@@ -8,3 +8,7 @@ Depends: @builddeps@
47
48 Tests: versioned-cargo-wrapper
49 Depends: @, cargo
50+
51+Tests: build-std
52+Restrictions: allow-stderr
53+Depends: @
54\ No newline at end of file

Subscribers

People subscribed via source and target branches