Skip to content

Commit a1d1ab9

Browse files
runningcodeclaude
andcommitted
fix(build): Pass version override env var to subprocess in integration test
Fixes the failing command_build_upload_apk_chunked integration test by ensuring SENTRY_CLI_VERSION_OVERRIDE is properly passed to the CLI subprocess. The test was setting the environment variable using std::env::set_var(), but when trycmd spawns the CLI as a subprocess, it doesn't inherit environment variables set in the test process. This caused the CLI to use the actual version (2.57.0) instead of the test version (0.0.0-test), resulting in mismatched chunk hashes and preventing chunk uploads. Changes: - Remove #[cfg(test)] conditional from get_version() so it always checks the environment variable, enabling integration tests to override the version - Update test to use .env() method to pass the environment variable to the subprocess instead of std::env::set_var() - Update expected chunk hash and binary to match the actual CLI output with version "0.0.0-test" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bd23b57 commit a1d1ab9

3 files changed

Lines changed: 3 additions & 12 deletions

File tree

src/utils/build/normalize.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,7 @@ use zip::write::SimpleFileOptions;
1717
use zip::{DateTime, ZipWriter};
1818

1919
fn get_version() -> String {
20-
#[cfg(test)]
21-
{
22-
std::env::var("SENTRY_CLI_VERSION_OVERRIDE").unwrap_or_else(|_| VERSION.to_owned())
23-
}
24-
#[cfg(not(test))]
25-
{
26-
VERSION.to_owned()
27-
}
20+
std::env::var("SENTRY_CLI_VERSION_OVERRIDE").unwrap_or_else(|_| VERSION.to_owned())
2821
}
2922

3023
fn sort_entries(path: &Path) -> Result<impl Iterator<Item = (PathBuf, PathBuf)>> {
-67 Bytes
Binary file not shown.

tests/integration/build/upload.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ static CONTENT_TYPE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
109109
/// and that the data sent to the chunk upload endpoint is exactly as expected.
110110
/// It also verifies that the correct calls are made to the assemble endpoint.
111111
fn command_build_upload_apk_chunked() {
112-
// Override version for deterministic binary comparison of chunk content
113-
std::env::set_var("SENTRY_CLI_VERSION_OVERRIDE", "0.0.0-test");
114-
115112
let is_first_assemble_call = AtomicBool::new(true);
116113
let expected_chunk_body = fs::read("tests/integration/_expected_requests/build/apk_chunk.bin")
117114
.expect("expected chunk body file should be present");
@@ -165,7 +162,7 @@ fn command_build_upload_apk_chunked() {
165162
if is_first_assemble_call.swap(false, Ordering::Relaxed) {
166163
r#"{
167164
"state": "created",
168-
"missingChunks": ["4c57ae0573fd4342c8996f9b2c9efd00ac84b5ea"]
165+
"missingChunks": ["60863d91bb673a1b1b92dbbe91b1de5cc0dde146"]
169166
}"#
170167
} else {
171168
r#"{
@@ -179,6 +176,7 @@ fn command_build_upload_apk_chunked() {
179176
.expect(2),
180177
)
181178
.register_trycmd_test("build/build-upload-apk.trycmd")
179+
.env("SENTRY_CLI_VERSION_OVERRIDE", "0.0.0-test")
182180
.with_default_token();
183181
}
184182

0 commit comments

Comments
 (0)