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

3
tests/common.rs Normal file
View File

@@ -0,0 +1,3 @@
// Intentionally hardcoded. When you bump the version in Cargo.toml,
// tests will fail here until you update this to match.
pub const EXPECTED_VERSION: &str = "1.1.0-beta.1";

View File

@@ -2,6 +2,10 @@ use assert_cmd::prelude::*;
use predicates::prelude::*;
use std::process::Command;
#[path = "common.rs"]
mod common;
use common::EXPECTED_VERSION;
#[path = "integration/environment_tests.rs"]
mod environment_tests;
@@ -25,7 +29,7 @@ fn test_version_command() {
cmd.assert()
.success()
.stdout(predicate::str::contains("1.0.0"));
.stdout(predicate::str::contains(EXPECTED_VERSION));
}
#[test]

View File

@@ -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"));

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"));
}