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:
Eric Ratliff
2026-01-31 14:17:51 -06:00
parent d2cc62e32f
commit 5596f5bade
10 changed files with 71 additions and 43 deletions

View File

@@ -6,6 +6,10 @@ use std::path::PathBuf;
use tempfile::TempDir;
use std::fs;
#[path = "../common.rs"]
mod common;
use common::EXPECTED_VERSION;
#[test]
fn test_config_create_and_save() {
let temp_dir = TempDir::new().unwrap();
@@ -15,7 +19,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.weevil_version, "1.0.0");
assert_eq!(config.weevil_version, EXPECTED_VERSION);
// Save and reload
config.save(temp_dir.path()).unwrap();
@@ -45,7 +49,7 @@ fn test_config_toml_format() {
let content = fs::read_to_string(temp_dir.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"));
}