Skip to content

test: guard pcap regeneration on missing python3 or fixtures - #25

Closed
walsykerem wants to merge 1 commit into
mainfrom
fix/issue-5-python-guard
Closed

walsykerem wants to merge 1 commit into
mainfrom
fix/issue-5-python-guard

Conversation

@walsykerem

Copy link
Copy Markdown
Owner

Fixes #5

TestR2L08FixturePcapRegeneratesByteForByte now skips instead of failing when it cannot safely regenerate the fixture:

  • CI is set: external python3 regeneration is not part of the CI-safe suite.
  • python3 is not on PATH, matching test/op_fixture_determinism_test.go.
  • testdata/fixtures/pcap/make.py or fixture.pcap is absent.

When python3 and both fixtures are available, the generator runs and the byte-for-byte comparison is unchanged. No production code or dependencies changed.

Tests: cp test/*_test.go lrecon/ && go test ./lrecon -run '^TestR2L08FixturePcapRegeneratesByteForByte$' -v -count=1

  • missing fixtures: SKIP, PASS
  • CI=true: SKIP, PASS
  • python3 removed from PATH: SKIP, PASS
  • synthetic 513-byte generator + fixture: PASS (regeneration path unchanged)

The checkout does not track the pcap fixtures, so the real make.py could not be exercised; the synthetic fixture covers the unchanged regeneration path.

@sonarqubecloud

Copy link
Copy Markdown

@qodo-code-review

qodo-code-review Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Skip pcap regeneration test when prerequisites are unavailable

🧪 Tests 🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Skip the pcap regeneration test in CI or when Python or fixture files are unavailable.
• Preserve the 513-byte and byte-for-byte checks when regeneration can run.
Merge Risk 🟢 Low

Blast radius 🟢 Low 💥 0 capabilities

  • No production behavior changes identified.
Behavioral complexity 🟢 Low 🧩 Assessed behavior

  • No production behavior changes identified.
Potential damage 🟢 Low 🩹 Assessed behavior

  • No production behavior changes identified.
Assessed commit 045244c
Diagram

graph TD
  A{"CI set?"} -->|No| B{"Python available?"} -->|Yes| C{"Fixtures available?"} -->|Yes| D["Regenerate pcap"] --> E["Compare bytes"] -->|Match| P["Pass test"]
  A -->|Yes| S["Skip test"]
  B -->|No| S
  C -->|No| S
  E -->|Mismatch| F["Fail test"]
Loading
High-Level Assessment

The targeted guard is appropriate for this test: it avoids environment-dependent failures without changing the comparison. Sharing prerequisite logic with the separate determinism test would broaden the change for little benefit.

Files changed (1) +9 / -2

Tests (1) +9 / -2
op_round2_lane08_simulation_test.goGuard pcap regeneration against unavailable prerequisites +9/-2

Guard pcap regeneration against unavailable prerequisites

• The test now skips when CI is set, python3 is absent, or the generator or committed pcap cannot be read. When prerequisites are present, it runs the resolved Python executable and retains the existing size and byte-by-byte checks.

test/op_round2_lane08_simulation_test.go

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Committed pcap fixture going missing no longer fails the test 🔴 High 🐞 Bug ≡ Correctness
Description
The os.ReadFile error branch in TestR2L08FixturePcapRegeneratesByteForByte was changed from
t.Fatal to t.Skipf, so a deleted or misnamed committed pcap fixture reports SKIP instead of
FAIL. The new os.Getenv("CI") != "" guard also skips the whole byte-for-byte regeneration check
whenever CI is set to any non-empty value (including false or 0), which is the default on most
CI runners. Because the PR notes the checkout does not track the pcap fixtures, these two skips
together mean the regeneration check silently never runs in CI, so a regression in make.py or the
committed output goes unnoticed.
Code

test/op_round2_lane08_simulation_test.go[287]

+		t.Skipf("fixture.pcap absent: %v", err)
Evidence
The PR changes the ReadFile error handling from fatal to skip, and the CI guard is the first
statement of the test, so it returns before any fixture check runs; with CI set, the byte-for-byte
comparison is never reached. The PR description states the pcap fixtures are not tracked by the
checkout, so the skip path is the one that will run in practice, and a genuinely missing fixture is
indistinguishable from an intentionally untracked one. No other path exercises the regeneration in
CI.

test/op_round2_lane08_simulation_test.go[285-291]
test/op_round2_lane08_simulation_test.go[275-277]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
In test/op_round2_lane08_simulation_test.go, `TestR2L08FixturePcapRegeneratesByteForByte` has two skips that disable its only regression check for the pcap generator. First, the `os.ReadFile` error branch for `testdata/fixtures/pcap/fixture.pcap` now calls `t.Skipf` instead of failing, so a deleted or renamed committed fixture reports SKIP. Second, a new `os.Getenv("CI") != ""` guard skips the whole byte-for-byte regeneration whenever CI is non-empty, including `CI=false` or `CI=0`. Since the checkout does not track the pcap fixtures, these skips mean the check never runs in CI, and a regression in make.py or the committed output passes unnoticed.

## Fix Focus Areas
- test/op_round2_lane08_simulation_test.go[274-282]
- test/op_round2_lane08_simulation_test.go[285-291]

## Recommended Fix
1. Remove the `CI` environment check at the top of the test. Keep the `exec.LookPath("python3")` skip and the make.py existence skip, since those already cover runners that cannot run the generator.
2. In the ReadFile error branch, restore `t.Fatal(err)`. Only the python3 and make.py guards should skip.
3. If the checkout genuinely lacks the fixture, gate the skip on an explicit condition (for example, skip only when make.py is also absent, or move the fixture into a tracked location) rather than skipping on any read error.
4. If CI must not run external interpreters, make that an explicit opt-out with a clearly named variable, document it, and have the CI pipeline either provision the fixtures or fail loudly.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



Remediation recommended

Nice, no open findings for this group


Informational

Nice, no open findings for this group

Grey Divider

Context sources
⚠️ Tickets: not configured — No jira, linear integration is connected for the linked tickets
✅ Cross-repo context — repo relationships
Review mode: Auto: 🚀 Fast: Localized test-only guard with minimal behavioral risk and one edit site.

Grey Divider

Tip of the day
💡 Did you know, you can tweak Display settings with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

committed, err := os.ReadFile("testdata/fixtures/pcap/fixture.pcap")
if err != nil {
t.Fatal(err)
t.Skipf("fixture.pcap absent: %v", err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Committed pcap fixture going missing no longer fails the test 🐞 Bug ≡ Correctness

The os.ReadFile error branch in TestR2L08FixturePcapRegeneratesByteForByte was changed from
t.Fatal to t.Skipf, so a deleted or misnamed committed pcap fixture reports SKIP instead of
FAIL. The new os.Getenv("CI") != "" guard also skips the whole byte-for-byte regeneration check
whenever CI is set to any non-empty value (including false or 0), which is the default on most
CI runners. Because the PR notes the checkout does not track the pcap fixtures, these two skips
together mean the regeneration check silently never runs in CI, so a regression in make.py or the
committed output goes unnoticed.
Agent Prompt
## Issue description
In test/op_round2_lane08_simulation_test.go, `TestR2L08FixturePcapRegeneratesByteForByte` has two skips that disable its only regression check for the pcap generator. First, the `os.ReadFile` error branch for `testdata/fixtures/pcap/fixture.pcap` now calls `t.Skipf` instead of failing, so a deleted or renamed committed fixture reports SKIP. Second, a new `os.Getenv("CI") != ""` guard skips the whole byte-for-byte regeneration whenever CI is non-empty, including `CI=false` or `CI=0`. Since the checkout does not track the pcap fixtures, these skips mean the check never runs in CI, and a regression in make.py or the committed output passes unnoticed.

## Fix Focus Areas
- test/op_round2_lane08_simulation_test.go[274-282]
- test/op_round2_lane08_simulation_test.go[285-291]

## Recommended Fix
1. Remove the `CI` environment check at the top of the test. Keep the `exec.LookPath("python3")` skip and the make.py existence skip, since those already cover runners that cannot run the generator.
2. In the ReadFile error branch, restore `t.Fatal(err)`. Only the python3 and make.py guards should skip.
3. If the checkout genuinely lacks the fixture, gate the skip on an explicit condition (for example, skip only when make.py is also absent, or move the fixture into a tracked location) rather than skipping on any read error.
4. If CI must not run external interpreters, make that an explicit opt-out with a clearly named variable, document it, and have the CI pipeline either provision the fixtures or fail loudly.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

@qodo-code-review

Copy link
Copy Markdown

Qodo Fixer

🍒 Ready to be cherry-picked — ✅ Merged (0) · ☑ Fixed (1)

Grey Divider

🔗 Fix PR: #29

This fix PR was closed automatically. Its branch is preserved so you can cherry pick the changes into the original PR.

Prompt for coding agent

This is an automated fix prepared on a separate branch (#29). It is NOT applied to this PR.
To use it: review Fix PR #29 (https://github.com/walsykerem/lrecon/pull/29), evaluate each change critically against your local context, and cherry-pick the changes that are correct into this branch. Do not accept them blindly.
Process — 1 fixed
  • ☑ Fixed: Committed pcap fixture going missing no longer fails the test

@walsykerem

Copy link
Copy Markdown
Owner Author

Recreated from verified backup (/Users/keremurhan/lrecon-pr-backup-20261126) as part of PR cleanup; replacement PR follows.

@walsykerem walsykerem closed this Nov 26, 2026
@walsykerem
walsykerem deleted the fix/issue-5-python-guard branch November 26, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test/op_round2_lane08_simulation_test.go: python3 regeneration has no skip guard

1 participant