fix: single source of truth for version across crate and tests
Replace all hardcoded "1.1.0" version strings with env!("CARGO_PKG_VERSION")
in src/, so Cargo.toml is the sole source for the built binary. Tests
intentionally use a separate hardcoded constant in tests/common.rs to act
as a canary — they will fail on a version bump until manually updated.
- src/project/mod.rs: add WEEVIL_VERSION const, wire into Tera context,
generated README, and .weevil-version marker
- tests/common.rs: new file, holds EXPECTED_VERSION for all test crates
- tests/{integration,project_lifecycle,unit/config_tests}.rs: pull from
common instead of env! or inline literals
This commit is contained in:
@@ -6,6 +6,10 @@ use std::fs;
|
||||
use weevil::project::{ProjectBuilder, ProjectConfig};
|
||||
use weevil::sdk::SdkConfig;
|
||||
|
||||
#[path = "common.rs"]
|
||||
mod common;
|
||||
use common::EXPECTED_VERSION;
|
||||
|
||||
// Note: These tests use the actual FTC SDK if available, or skip if not
|
||||
// For true unit testing with mocks, we'd need to refactor to use dependency injection
|
||||
|
||||
@@ -26,7 +30,7 @@ fn test_config_create_and_save() {
|
||||
assert_eq!(config.project_name, "test-robot");
|
||||
assert_eq!(config.ftc_sdk_path, sdk_path);
|
||||
assert_eq!(config.android_sdk_path, android_sdk_path);
|
||||
assert_eq!(config.weevil_version, "1.0.0");
|
||||
assert_eq!(config.weevil_version, EXPECTED_VERSION);
|
||||
|
||||
// Save and reload
|
||||
let project_path = temp_dir.path().join("project");
|
||||
@@ -60,7 +64,7 @@ fn test_config_toml_format() {
|
||||
let content = fs::read_to_string(project_path.join(".weevil.toml")).unwrap();
|
||||
|
||||
assert!(content.contains("project_name = \"my-robot\""));
|
||||
assert!(content.contains("weevil_version = \"1.0.0\""));
|
||||
assert!(content.contains(&format!("weevil_version = \"{}\"", EXPECTED_VERSION)));
|
||||
assert!(content.contains("ftc_sdk_path"));
|
||||
assert!(content.contains("ftc_sdk_version"));
|
||||
assert!(content.contains("android_sdk_path"));
|
||||
|
||||
Reference in New Issue
Block a user