Skip to content

Commit

Permalink
test: simplify rust_version::sync
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed Oct 6, 2024
1 parent eef8694 commit 5ec0336
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 214 deletions.
191 changes: 0 additions & 191 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,5 @@ pipe-trait = "0.4.0"
split-first-char = "0.0.0"

[dev-dependencies]
cargo_metadata = "0.18.1"
cargo_toml = "0.20.5"
pretty_assertions = "1.4.1"
semver = "1.0.23"
25 changes: 4 additions & 21 deletions tests/rust_version.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
#![cfg(feature = "std")]
use cargo_metadata::MetadataCommand;
use cargo_toml::Manifest;
use pipe_trait::Pipe;
use pretty_assertions::assert_eq;
use semver::Version;
use std::fs;
use std::{fs, path::Path};

#[test]
fn sync() {
let ws_root = MetadataCommand::new()
.exec()
.expect("the command `cargo metadata` should execute successfully")
.workspace_root;
dbg!(&ws_root);
let rust_toolchain = ws_root
let rust_toolchain = env!("CARGO_MANIFEST_DIR")
.pipe(Path::new)
.join("rust-toolchain")
.pipe(fs::read_to_string)
.expect("the rust-toolchain file should be readable")
Expand All @@ -22,18 +16,7 @@ fn sync() {
.expect("the content rust-toolchain should be valid semver");
dbg!(&rust_toolchain);
let Version { major, minor, .. } = &rust_toolchain;
let rust_version = ws_root
.join("Cargo.toml")
.pipe(Manifest::from_path)
.expect("Cargo.toml should be readable")
.package
.expect("package should be defined")
.rust_version
.expect("rust_version should be defined");
let rust_version = rust_version
.get()
.expect("rust-version should be valid")
.as_str();
let rust_version = env!("CARGO_PKG_RUST_VERSION");
dbg!(rust_version);
assert_eq!(rust_version, format!("{major}.{minor}"));
}

0 comments on commit 5ec0336

Please sign in to comment.