mirror of
https://github.com/hanzoai/pack.git
synced 2026-09-30 23:43:13 +00:00
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:
@@ -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,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!("hello from custom toolchain");
|
||||
println!("hello from custom toolchain ({})", env!("RUST_VERSION"));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[
|
||||
{
|
||||
"expectedOutput": "hello from custom toolchain"
|
||||
"expectedOutput": "hello from custom toolchain (rustc 1.59.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!("hello from custom version");
|
||||
println!("hello from custom version ({})", env!("RUST_VERSION"));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[
|
||||
{
|
||||
"expectedOutput": "hello from custom version"
|
||||
"expectedOutput": "hello from custom version (rustc 1.56.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!("This is Bin 1!");
|
||||
println!("This is Bin 1! ({})", env!("RUST_VERSION"));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[
|
||||
{
|
||||
"expectedOutput": "This is Bin 1!"
|
||||
"expectedOutput": "This is Bin 1! (rustc 1.84.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);
|
||||
}
|
||||
@@ -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]
|
||||
|
||||
@@ -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,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,5 +1,5 @@
|
||||
[
|
||||
{
|
||||
"expectedOutput": "hello from rust system deps"
|
||||
"expectedOutput": "hello from rust system deps (rustc 1.85.1)"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user