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

@@ -7,6 +7,8 @@ use git2::Repository;
use crate::sdk::SdkConfig;
const WEEVIL_VERSION: &str = env!("CARGO_PKG_VERSION");
pub mod deployer;
pub mod config;
@@ -68,7 +70,7 @@ impl ProjectBuilder {
let mut _context = TeraContext::new();
_context.insert("project_name", &self.name);
_context.insert("sdk_dir", &sdk_config.ftc_sdk_path.to_string_lossy());
_context.insert("generator_version", "1.0.0");
_context.insert("generator_version", WEEVIL_VERSION);
self.create_project_files(project_path, sdk_config)?;
@@ -84,7 +86,7 @@ impl ProjectBuilder {
let readme = format!(
r#"# {}
FTC Robot Project generated by Weevil v1.0.0
FTC Robot Project generated by Weevil v{}
## Quick Start
```bash
@@ -111,7 +113,7 @@ deploy.bat
2. Test locally: `./gradlew test`
3. Deploy: `./deploy.sh` (or `deploy.bat` on Windows)
"#,
self.name
self.name, WEEVIL_VERSION
);
fs::write(project_path.join("README.md"), readme)?;
@@ -120,7 +122,7 @@ deploy.bat
fs::write(project_path.join(".gitignore"), gitignore)?;
// Version marker
fs::write(project_path.join(".weevil-version"), "1.0.0")?;
fs::write(project_path.join(".weevil-version"), WEEVIL_VERSION)?;
// build.gradle.kts - Pure Java with deployToSDK task
// Escape backslashes for Windows paths in Kotlin strings