test: assert against specific rust version defined by rust-toolchain.toml (#299)

* test: assert against specific rust version defined by rust-toolchain.toml

* test: assert cargo workspace version

* test: assert specific rust version in integration tests

* test: fix wrong rust version

need to add a .tool-version in another PR
This commit is contained in:
Michael Bianco
2025-10-21 14:12:14 -06:00
committed by GitHub
parent 4baa261ec8
commit d7302e8ea6
20 changed files with 161 additions and 14 deletions
@@ -0,0 +1,21 @@
use std::process::Command;
fn main() {
let output = Command::new("rustc")
.arg("--version")
.output()
.expect("Failed to execute rustc");
let version = String::from_utf8(output.stdout)
.expect("Invalid UTF-8 in rustc output")
.trim()
.to_string();
let simplified_version = version
.split('(')
.next()
.unwrap_or(&version)
.trim();
println!("cargo:rustc-env=RUST_VERSION={}", simplified_version);
}
@@ -1,3 +1,3 @@
fn main() {
println!("{}", library::MESSAGE);
println!("{} ({})", library::MESSAGE, env!("RUST_VERSION"));
}
@@ -1,5 +1,5 @@
[
{
"expectedOutput": "Hello from rust"
"expectedOutput": "Hello from rust (rustc 1.89.0)"
}
]
@@ -0,0 +1,21 @@
use std::process::Command;
fn main() {
let output = Command::new("rustc")
.arg("--version")
.output()
.expect("Failed to execute rustc");
let version = String::from_utf8(output.stdout)
.expect("Invalid UTF-8 in rustc output")
.trim()
.to_string();
let simplified_version = version
.split('(')
.next()
.unwrap_or(&version)
.trim();
println!("cargo:rustc-env=RUST_VERSION={}", simplified_version);
}
@@ -1,3 +1,3 @@
fn main() {
println!("{}", library::MESSAGE);
println!("{} ({})", library::MESSAGE, env!("RUST_VERSION"));
}
+1 -1
View File
@@ -1,5 +1,5 @@
[
{
"expectedOutput": "Hello from rust"
"expectedOutput": "Hello from rust (rustc 1.89.0)"
}
]
+21
View File
@@ -0,0 +1,21 @@
use std::process::Command;
fn main() {
let output = Command::new("rustc")
.arg("--version")
.output()
.expect("Failed to execute rustc");
let version = String::from_utf8(output.stdout)
.expect("Invalid UTF-8 in rustc output")
.trim()
.to_string();
let simplified_version = version
.split('(')
.next()
.unwrap_or(&version)
.trim();
println!("cargo:rustc-env=RUST_VERSION={}", simplified_version);
}
+1 -1
View File
@@ -1,3 +1,3 @@
fn main() {
println!("hello from custom toolchain");
println!("hello from custom toolchain ({})", env!("RUST_VERSION"));
}
+1 -1
View File
@@ -1,5 +1,5 @@
[
{
"expectedOutput": "hello from custom toolchain"
"expectedOutput": "hello from custom toolchain (rustc 1.59.0)"
}
]
+21
View File
@@ -0,0 +1,21 @@
use std::process::Command;
fn main() {
let output = Command::new("rustc")
.arg("--version")
.output()
.expect("Failed to execute rustc");
let version = String::from_utf8(output.stdout)
.expect("Invalid UTF-8 in rustc output")
.trim()
.to_string();
let simplified_version = version
.split('(')
.next()
.unwrap_or(&version)
.trim();
println!("cargo:rustc-env=RUST_VERSION={}", simplified_version);
}
+1 -1
View File
@@ -1,3 +1,3 @@
fn main() {
println!("hello from custom version");
println!("hello from custom version ({})", env!("RUST_VERSION"));
}
+1 -1
View File
@@ -1,5 +1,5 @@
[
{
"expectedOutput": "hello from custom version"
"expectedOutput": "hello from custom version (rustc 1.56.0)"
}
]
+21
View File
@@ -0,0 +1,21 @@
use std::process::Command;
fn main() {
let output = Command::new("rustc")
.arg("--version")
.output()
.expect("Failed to execute rustc");
let version = String::from_utf8(output.stdout)
.expect("Invalid UTF-8 in rustc output")
.trim()
.to_string();
let simplified_version = version
.split('(')
.next()
.unwrap_or(&version)
.trim();
println!("cargo:rustc-env=RUST_VERSION={}", simplified_version);
}
+1 -1
View File
@@ -1,3 +1,3 @@
fn main() {
println!("This is Bin 1!");
println!("This is Bin 1! ({})", env!("RUST_VERSION"));
}
+1 -1
View File
@@ -1,5 +1,5 @@
[
{
"expectedOutput": "This is Bin 1!"
"expectedOutput": "This is Bin 1! (rustc 1.84.0)"
}
]
+21
View File
@@ -0,0 +1,21 @@
use std::process::Command;
fn main() {
let output = Command::new("rustc")
.arg("--version")
.output()
.expect("Failed to execute rustc");
let version = String::from_utf8(output.stdout)
.expect("Invalid UTF-8 in rustc output")
.trim()
.to_string();
let simplified_version = version
.split('(')
.next()
.unwrap_or(&version)
.trim();
println!("cargo:rustc-env=RUST_VERSION={}", simplified_version);
}
+2 -2
View File
@@ -2,8 +2,8 @@
extern crate rocket;
#[get("/")]
fn index() -> &'static str {
"Hello, from Rocket!"
fn index() -> String {
format!("Hello, from Rocket! ({})", env!("RUST_VERSION"))
}
#[launch]
+21
View File
@@ -0,0 +1,21 @@
use std::process::Command;
fn main() {
let output = Command::new("rustc")
.arg("--version")
.output()
.expect("Failed to execute rustc");
let version = String::from_utf8(output.stdout)
.expect("Invalid UTF-8 in rustc output")
.trim()
.to_string();
let simplified_version = version
.split('(')
.next()
.unwrap_or(&version)
.trim();
println!("cargo:rustc-env=RUST_VERSION={}", simplified_version);
}
+1 -1
View File
@@ -2,5 +2,5 @@ use openssl as _;
use ring as _;
fn main() {
println!("hello from rust system deps")
println!("hello from rust system deps ({})", env!("RUST_VERSION"))
}
+1 -1
View File
@@ -1,5 +1,5 @@
[
{
"expectedOutput": "hello from rust system deps"
"expectedOutput": "hello from rust system deps (rustc 1.85.1)"
}
]