Skip to content

Commit

Permalink
fix dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
aappleby committed Mar 9, 2024
1 parent 4bd37cc commit 8de17d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions hancho.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,10 @@ async def dispatch(self):
return self.abs_files_out

# Make sure our output directories exist
for file_out in self.abs_files_out:
if dirname := path.dirname(file_out):
os.makedirs(dirname, exist_ok=True)
if not self.dryrun:
for file_out in self.abs_files_out:
if dirname := path.dirname(file_out):
os.makedirs(dirname, exist_ok=True)

# And flatten+expand our command list
commands = await flatten_async(self, self.command)
Expand All @@ -574,7 +575,7 @@ async def dispatch(self):
if self.verbose or self.debug:
log(f"Reason: {self.reason}")
for command in commands:
log(f">>> {command}")
log(f">>>{' (DRY RUN)' if self.dryrun else ''} {command}")
if self.debug:
log(self)

Expand All @@ -583,7 +584,7 @@ async def dispatch(self):
result = await self.run_command(command)

# Task complete, check if it actually updated all the output files
if self.files_in and self.files_out:
if self.files_in and self.files_out and not self.dryrun:
if second_reason := await self.needs_rerun():
raise ValueError(
f"Task '{desc}' still needs rerun after running!\n"
Expand Down
1 change: 1 addition & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# calling hancho in src dir
# meta deps changed
# transitive dependencies
# dry run not creating files/dirs

# min delta seems to be 4 msec on linux, 1 msec on windows?
# os.system("touch blahblah.txt")
Expand Down

0 comments on commit 8de17d9

Please sign in to comment.