Skip to content

Commit 008802b

Browse files
authored
[meta] update self_update to 0.43.1, use ureq, excise ring (#3141)
The ring crate has caused no end of issues with spurious recompiles. * Update self_update to 0.43.1. * Switch to ureq -- we don't need reqwest for a single serial HTTP download. * Remove ring by manually enabling aws-lc-rs and doing the download with ureq ourselves. (As a bonus, we can use nextest's progress bar style.) The ring crate is still present in Cargo.lock, but that's only due to rust-lang/cargo#10801.
1 parent 2ca0f05 commit 008802b

File tree

10 files changed

+502
-415
lines changed

10 files changed

+502
-415
lines changed

Cargo.lock

Lines changed: 221 additions & 301 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,15 @@ recursion = "0.5.4"
111111
regex = "1.12.3"
112112
regex-syntax = "0.8.10"
113113
sapling-streampager = "0.12.0"
114-
self_update = { version = "0.42.0", default-features = false, features = [
114+
rustls = { version = "0.23.37", default-features = false }
115+
self_update = { version = "0.43.1", default-features = false, features = [
115116
"archive-tar",
116117
"compression-flate2",
118+
# nextest only uses self_update for archive extraction (ArchiveKind,
119+
# Compression, Extract), not its HTTP client. But self_update's Download
120+
# struct unconditionally calls http_client::get, so at least one HTTP
121+
# backend must be enabled for it to compile.
122+
"ureq",
117123
] }
118124
semver = "1.0.27"
119125
serde = { version = "1.0.228", features = ["derive"] }
@@ -142,6 +148,7 @@ tracing = "0.1.44"
142148
tracing-subscriber = { version = "0.3.22", default-features = false, features = ["std", "tracing-log", "fmt"] }
143149
unicode-ident = "1.0.24"
144150
unicode-normalization = "0.1.25"
151+
ureq = { version = "3.2.0", default-features = false }
145152
usdt = "0.6.0"
146153
walkdir = "2.5.0"
147154
whoami = "2.1.1"

Cross.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ passthrough = ["CARGO_PROFILE_RELEASE_LTO"]
66
# https://github.com/cross-rs/cross/pull/1166
77
image = "ghcr.io/cross-rs/x86_64-unknown-freebsd:edge"
88

9-
# This doesn't work because the cross 0.2.4 Docker container is based on Ubuntu 18.04, which doesn't
10-
# have binary packages available for riscv64.
11-
# [target.riscv64gc-unknown-linux-gnu]
12-
# pre-build = [
13-
# "dpkg --add-architecture aarch64",
14-
# "apt-get update && apt-get install --assume-yes libssl-dev:aarch64"
15-
# ]
9+
[target.riscv64gc-unknown-linux-gnu]
10+
# The default cross image is based on Ubuntu 18.04, which doesn't have riscv64
11+
# packages. The edge image is newer and does.
12+
image = "ghcr.io/cross-rs/riscv64gc-unknown-linux-gnu:edge"
13+
pre-build = [
14+
"dpkg --add-architecture riscv64",
15+
"apt-get update && apt-get install --assume-yes libssl-dev:riscv64",
16+
]

cargo-nextest/src/update.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
use crate::{ExpectedError, Result, output::OutputContext};
55
use camino::Utf8PathBuf;
66
use nextest_metadata::NextestExitCode;
7-
use nextest_runner::update::{CheckStatus, MuktiBackend, UpdateVersionReq};
7+
use nextest_runner::{
8+
helpers::ThemeCharacters,
9+
update::{CheckStatus, MuktiBackend, UpdateDisplayStyles, UpdateVersionReq},
10+
};
811
use owo_colors::OwoColorize;
912
use semver::Version;
1013
use std::cmp::Ordering;
@@ -111,8 +114,16 @@ pub(crate) fn perform_update(
111114
};
112115

113116
if should_apply {
117+
let mut update_styles = UpdateDisplayStyles {
118+
theme_characters: ThemeCharacters::detect(supports_unicode::Stream::Stderr),
119+
..Default::default()
120+
};
121+
if output.color.should_colorize(supports_color::Stream::Stderr) {
122+
update_styles.colorize();
123+
}
124+
114125
debug!(url = ctx.location.url, "updating cargo nextest");
115-
ctx.do_update()
126+
ctx.do_update(&update_styles)
116127
.map_err(|err| ExpectedError::UpdateError { err })?;
117128
info!(
118129
"cargo-nextest updated to {}",

nextest-runner/Cargo.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,20 @@ windows-sys = { workspace = true, features = [
142142
] }
143143
win32job.workspace = true
144144

145-
# Use rustls by default, OpenSSL on platforms where rustls isn't available:
145+
# Use rustls with aws-lc-rs by default, OpenSSL on platforms where rustls
146+
# isn't available:
146147
# RISC-V: https://github.com/nextest-rs/nextest/issues/820
147-
# (default features for self_update turns on openssl)
148148
[target.'cfg(not(any(target_arch = "riscv32", target_arch = "riscv64")))'.dependencies]
149-
self_update = { workspace = true, optional = true, default-features = false, features = [
150-
"rustls",
151-
] }
149+
self_update = { workspace = true, optional = true, default-features = false }
150+
# self_update's "rustls" feature hardcodes ureq's ring crypto provider. To use
151+
# aws-lc-rs instead, activate ureq's TLS and rustls's provider separately.
152+
ureq = { workspace = true, optional = true, features = ["rustls-no-provider", "rustls-webpki-roots"] }
153+
rustls = { workspace = true, optional = true, features = ["aws-lc-rs"] }
152154

153155
[target.'cfg(any(target_arch = "riscv32", target_arch = "riscv64"))'.dependencies]
154-
self_update = { workspace = true, optional = true, default-features = true }
156+
self_update = { workspace = true, optional = true, default-features = false }
157+
# On RISC-V, rustls/aws-lc-rs aren't available, so use native-tls instead.
158+
ureq = { workspace = true, optional = true, features = ["native-tls"] }
155159

156160

157161
[dev-dependencies]
@@ -176,7 +180,9 @@ self-update = [
176180
"dep:self_update",
177181
"dep:http",
178182
"dep:mukti-metadata",
183+
"dep:rustls",
179184
"dep:sha2",
185+
"dep:ureq",
180186
]
181187
usdt = ["dep:usdt"]
182188
experimental-tokio-console = [

nextest-runner/src/errors.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,32 @@ mod self_update_errors {
28902890
#[error("self-update failed")]
28912891
SelfUpdate(#[source] self_update::errors::Error),
28922892

2893+
/// An HTTP error occurred while performing a request.
2894+
#[error("error performing HTTP request")]
2895+
Http(#[source] ureq::Error),
2896+
2897+
/// An error occurred while reading an HTTP response body.
2898+
#[error("error reading HTTP response body")]
2899+
HttpBody(#[source] std::io::Error),
2900+
2901+
/// The server's Content-Length header was present but could not be
2902+
/// parsed.
2903+
#[error("Content-Length header present but could not be parsed as an integer: {value:?}")]
2904+
ContentLengthInvalid {
2905+
/// The raw header value.
2906+
value: String,
2907+
},
2908+
2909+
/// The server's Content-Length header didn't match the number of bytes
2910+
/// received.
2911+
#[error("content length mismatch: expected {expected} bytes, received {actual} bytes")]
2912+
ContentLengthMismatch {
2913+
/// The expected number of bytes (from the Content-Length header).
2914+
expected: u64,
2915+
/// The actual number of bytes received.
2916+
actual: u64,
2917+
},
2918+
28932919
/// Deserializing release metadata failed.
28942920
#[error("deserializing release metadata failed")]
28952921
ReleaseMetadataDe(#[source] serde_json::Error),

nextest-runner/src/helpers.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,16 @@ impl Default for ThemeCharacters {
735735
}
736736

737737
impl ThemeCharacters {
738+
/// Creates a `ThemeCharacters` with Unicode auto-detected for the given
739+
/// stream.
740+
pub fn detect(stream: supports_unicode::Stream) -> Self {
741+
let mut this = Self::default();
742+
if supports_unicode::on(stream) {
743+
this.use_unicode();
744+
}
745+
this
746+
}
747+
738748
/// Switches to Unicode characters for richer terminal output.
739749
pub fn use_unicode(&mut self) {
740750
self.hbar = '─';

nextest-runner/src/reporter/displayer/imp.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,16 @@ impl DisplayReporterBuilder {
9191
styles.colorize();
9292
}
9393

94-
let mut theme_characters = ThemeCharacters::default();
95-
match &output {
96-
ReporterOutput::Terminal => {
97-
if supports_unicode::on(supports_unicode::Stream::Stderr) {
98-
theme_characters.use_unicode();
99-
}
100-
}
94+
let theme_characters = match &output {
95+
ReporterOutput::Terminal => ThemeCharacters::detect(supports_unicode::Stream::Stderr),
10196
ReporterOutput::Writer { use_unicode, .. } => {
97+
let mut tc = ThemeCharacters::default();
10298
if *use_unicode {
103-
theme_characters.use_unicode();
99+
tc.use_unicode();
104100
}
101+
tc
105102
}
106-
}
103+
};
107104

108105
let is_terminal = matches!(&output, ReporterOutput::Terminal) && io::stderr().is_terminal();
109106
let is_ci = is_ci::uncached();

0 commit comments

Comments
 (0)