Skip to content

fix: clear build cache in sync build-in-source test tearDown for reliable reruns#8745

Merged
bnusunny merged 1 commit intodevelopfrom
fix/sync-build-in-source-cache-rerun
Mar 11, 2026
Merged

fix: clear build cache in sync build-in-source test tearDown for reliable reruns#8745
bnusunny merged 1 commit intodevelopfrom
fix/sync-build-in-source-cache-rerun

Conversation

@bnusunny
Copy link
Contributor

@bnusunny bnusunny commented Mar 6, 2026

Problem

The TestSyncInfra_BuildInSource_Makefile::test_sync_builds_and_deploys_successfully_0 integration test fails on pytest reruns due to stale SAM build cache.

The tearDown deletes the Makefile-created marker files (file-created-from-makefile-*.txt) but does not invalidate the SAM build cache inside the temp test data directory. The base class SyncIntegBase.tearDown clears .aws-sam from os.getcwd() (the repo root), but the actual build cache lives at self.test_data_path/.aws-sam/ (inside the temp directory).

On pytest reruns, SAM finds a "valid cache" and skips re-running the Makefile, so the marker files are never recreated and the file-existence assertion fails with AssertionError: False != True.

Fix

Clear .aws-sam inside self.test_data_path in tearDown for both TestSyncInfra_BuildInSource_Makefile and TestSyncCode_BuildInSource_Makefile, so the build cache is invalidated and the Makefile re-executes on retries.

Testing

This fix addresses a flaky test rerun issue observed in CI: https://github.com/aws/aws-sam-cli/actions/runs/22754896467/job/65997092656

…able reruns

The tearDown in TestSyncInfra_BuildInSource_Makefile and
TestSyncCode_BuildInSource_Makefile deletes the Makefile-created marker
files but does not invalidate the SAM build cache inside the temp test
data directory. On pytest reruns, SAM finds a valid cache and skips
re-running the Makefile, so the marker files are never recreated and
the file-existence assertion fails.

Clear .aws-sam inside test_data_path in tearDown so the build cache is
invalidated and the Makefile re-executes on retries.
@bnusunny bnusunny requested a review from a team as a code owner March 6, 2026 17:33
@bnusunny bnusunny requested a review from roger-zhangg March 6, 2026 18:10
@bnusunny bnusunny added this pull request to the merge queue Mar 11, 2026
Merged via the queue into develop with commit 1636f3e Mar 11, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants