Skip to content

test: gate real apktool decode behind local opt-in - #39

Open
walsykerem wants to merge 1 commit into
mainfrom
fix/issue-4-apktool-guard
Open

walsykerem wants to merge 1 commit into
mainfrom
fix/issue-4-apktool-guard

Conversation

@walsykerem

Copy link
Copy Markdown
Owner

Fixes #4

Gate the real apktool/Java decode test so it runs only on a local machine that explicitly opts in with LRECON_OPS_APKTOOL=1 and has both apktool and java on PATH. When CI is set the test skips with a clear reason instead of depending on the runner image. The fixture integrity test and every other test are unchanged.

Verified in a temp clone (repo test convention: cp test/*_test.go lrecon/):

  • go test ./lrecon -count=1 -run '^TestApktoolDecodeFixture$' -v -> SKIP, PASS
  • CI=true go test ./lrecon -count=1 -run '^TestApktoolDecodeFixture$' -v -> SKIP, PASS

@sonarqubecloud

Copy link
Copy Markdown

@qodo-code-review

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

Copy link
Copy Markdown

PR Summary by Qodo

Gate real apktool decode test behind local opt-in

🧪 Tests 🕐 Less than 5 minutes

Grey Divider

AI Description

• Skip the machine-dependent apktool decode test in CI and unless locally opted in.
• Require both apktool and Java before running the real decode test; leave other tests unchanged.
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 30447c4
Diagram

graph TD
  CI{"CI set?"} -->|No| Opt{"Opted in?"} -->|Yes| Tools{"Both tools?"} -->|Yes| Decode["Run decode tests"]
  CI -->|Yes| Skip["Skip with reason"]
  Opt -->|No| Skip
  Tools -->|No| Skip
Loading
High-Level Assessment

The runtime guard is appropriate for a machine-dependent integration test: it preserves local coverage without making CI depend on runner tools. A build-tag-only approach would require selecting a separate test build and would not provide the same explicit CI and tool-availability skips.

Files changed (1) +10 / -2

Tests (1) +10 / -2
op_ext_apktool_test.goRequire local opt-in and external tools for real APK decoding +10/-2

Require local opt-in and external tools for real APK decoding

• TestApktoolDecodeFixture now skips in CI, without LRECON_OPS_APKTOOL=1, or when apktool or java is absent from PATH. Its decode assertions and the fixture integrity test remain unchanged.

test/op_ext_apktool_test.go

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

Nice, no open findings for this group


Remediation recommended

1. Decode test never runs unless someone opts in locally 🟠 Medium 🐞 Bug ☼ Reliability
Description
The new LRECON_OPS_APKTOOL != "1" guard at line 65 makes TestApktoolDecodeFixture skip on every
default go test run, including on machines that have apktool and java installed, which previously
exercised it. The PR adds no workflow or other opt-in runner, so after merge the only test that
drives the real apktool decode path (items 513-516) is a permanent SKIP in practice, and the four
decode subtests never execute.
Code

test/op_ext_apktool_test.go[R65-67]

+	if os.Getenv("LRECON_OPS_APKTOOL") != "1" {
+		t.Skip("real apktool decode is opt-in: set LRECON_OPS_APKTOOL=1 locally")
+	}
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The decode test in test/op_ext_apktool_test.go is now gated behind LRECON_OPS_APKTOOL=1 and skipped when CI is set. Under default `go test` runs it never executes, so the real apktool decode path (items 513-516) has no automated coverage and the skip is easy to miss.

## Fix Focus Areas
- test/op_ext_apktool_test.go[59-75]

## Recommended Fix
Keep the opt-in gate but make the lack of coverage visible: add a named, documented way to run the test (for example a Makefile or script target such as `LRECON_OPS_APKTOOL=1 go test ./test -run '^TestApktoolDecodeFixture$' -v`) and document it in the test file header or the repo README. Where a dedicated runner exists that is allowed to have apktool, have it set the variable. Do not add it to the shared CI workflow if the ticket forbids that, but record the gap in the ticket so the coverage loss is tracked.

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

Dismiss ↗ | View ↗


2. Opted-in run passes silently when a tool is missing 🟠 Medium 🐞 Bug ◔ Observability
Description
In TestApktoolDecodeFixture, the loop at lines 68-71 calls t.Skip when apktool or java is
not on PATH, and this runs after the developer has already set LRECON_OPS_APKTOOL=1. A developer
who explicitly asked for the real decode and has a broken toolchain therefore gets a SKIP line
rather than a failure, which hides the misconfiguration the opt-in was meant to surface.
Code

test/op_ext_apktool_test.go[R68-71]

+	for _, tool := range []string{"apktool", "java"} {
+		if _, err := exec.LookPath(tool); err != nil {
+			t.Skip(tool + " not installed")
+		}
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_ext_apktool_test.go the PATH check for `apktool` and `java` calls t.Skip even when LRECON_OPS_APKTOOL=1 was set. An explicit opt-in with a missing toolchain is then reported as a skip and not as a failure, so the misconfiguration goes unnoticed.

## Fix Focus Areas
- test/op_ext_apktool_test.go[62-72]

## Recommended Fix
After the opt-in check, replace the `t.Skip(tool + " not installed")` in the LookPath loop with `t.Fatalf("LRECON_OPS_APKTOOL=1 but %s not on PATH: %v", tool, err)`. Keep the t.Skip only for the unset-opt-in path so that default runs still skip cleanly.

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

Dismiss ↗ | View ↗



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 gating change with minimal, easily assessed logic.

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

Comment on lines +65 to +67
if os.Getenv("LRECON_OPS_APKTOOL") != "1" {
t.Skip("real apktool decode is opt-in: set LRECON_OPS_APKTOOL=1 locally")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Decode test never runs unless someone opts in locally 🐞 Bug ☼ Reliability

The new LRECON_OPS_APKTOOL != "1" guard at line 65 makes TestApktoolDecodeFixture skip on every
default go test run, including on machines that have apktool and java installed, which previously
exercised it. The PR adds no workflow or other opt-in runner, so after merge the only test that
drives the real apktool decode path (items 513-516) is a permanent SKIP in practice, and the four
decode subtests never execute.
Agent Prompt
## Issue description
The decode test in test/op_ext_apktool_test.go is now gated behind LRECON_OPS_APKTOOL=1 and skipped when CI is set. Under default `go test` runs it never executes, so the real apktool decode path (items 513-516) has no automated coverage and the skip is easy to miss.

## Fix Focus Areas
- test/op_ext_apktool_test.go[59-75]

## Recommended Fix
Keep the opt-in gate but make the lack of coverage visible: add a named, documented way to run the test (for example a Makefile or script target such as `LRECON_OPS_APKTOOL=1 go test ./test -run '^TestApktoolDecodeFixture$' -v`) and document it in the test file header or the repo README. Where a dedicated runner exists that is allowed to have apktool, have it set the variable. Do not add it to the shared CI workflow if the ticket forbids that, but record the gap in the ticket so the coverage loss is tracked.

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

Dismiss ↗ | View ↗

Comment on lines +68 to +71
for _, tool := range []string{"apktool", "java"} {
if _, err := exec.LookPath(tool); err != nil {
t.Skip(tool + " not installed")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. Opted-in run passes silently when a tool is missing 🐞 Bug ◔ Observability

In TestApktoolDecodeFixture, the loop at lines 68-71 calls t.Skip when apktool or java is
not on PATH, and this runs after the developer has already set LRECON_OPS_APKTOOL=1. A developer
who explicitly asked for the real decode and has a broken toolchain therefore gets a SKIP line
rather than a failure, which hides the misconfiguration the opt-in was meant to surface.
Agent Prompt
## Issue description
In test/op_ext_apktool_test.go the PATH check for `apktool` and `java` calls t.Skip even when LRECON_OPS_APKTOOL=1 was set. An explicit opt-in with a missing toolchain is then reported as a skip and not as a failure, so the misconfiguration goes unnoticed.

## Fix Focus Areas
- test/op_ext_apktool_test.go[62-72]

## Recommended Fix
After the opt-in check, replace the `t.Skip(tool + " not installed")` in the LookPath loop with `t.Fatalf("LRECON_OPS_APKTOOL=1 but %s not on PATH: %v", tool, err)`. Keep the t.Skip only for the unset-opt-in path so that default runs still skip cleanly.

ⓘ 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

No findings are within the configured fix scope. To change which findings are fixed, adjust the setting on your Qodo configuration page.

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_ext_apktool_test.go: real apktool/Java decode is machine-dependent

1 participant