Skip to content

Commit 1636f3e

Browse files
authored
fix: clear build cache in sync build-in-source test tearDown for reliable reruns (#8745)
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.
1 parent e7de444 commit 1636f3e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/integration/sync/test_sync_build_in_source.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def tearDown(self):
3333
if os.path.isfile(path):
3434
os.remove(path)
3535

36+
# Clear the build cache so reruns re-execute the Makefile and recreate marker files
37+
shutil.rmtree(self.test_data_path.joinpath(".aws-sam"), ignore_errors=True)
38+
3639
@parameterized.expand(
3740
[
3841
(True, True), # build in source
@@ -94,6 +97,9 @@ def tearDown(self):
9497
if os.path.isfile(path):
9598
os.remove(path)
9699

100+
# Clear the build cache so reruns re-execute the Makefile and recreate marker files
101+
shutil.rmtree(Path(self.test_data_path, ".aws-sam"), ignore_errors=True)
102+
97103
@parameterized.expand(
98104
[
99105
(True, True), # build in source

0 commit comments

Comments
 (0)