Skip to content

Commit

Permalink
Enabled SnapshotTracer to create its output_directory argument if it …
Browse files Browse the repository at this point in the history
…doesn't already exist
  • Loading branch information
david-yz-liu committed Dec 8, 2024
1 parent 459c0dd commit 7de71f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Added `z3` option to `one-iteration-checker` to only check for feasible code blocks based on edge z3 constraints
- Added reporting for errors raised by custom transforms (`Z3Visitor`, `CFGVisitor`)
- Ensured `SnapshotTracer` does not include the `_trace_func` stack frame
- Enabled `SnapshotTracer` to create its `output_directory` argument if it doesn't already exist

### 💫 New checkers

Expand Down
4 changes: 4 additions & 0 deletions python_ta/debug/snapshot_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import sys
import types
import webbrowser
from pathlib import Path
from typing import Any, Optional

from bs4 import BeautifulSoup
Expand Down Expand Up @@ -45,6 +46,7 @@ def __init__(
Args:
output_directory: The directory to save the snapshots, defaulting to the current directory.
**Note**: Use this argument instead of the `--output` flag in `memory_viz_args` to specify the output directory.
The directory will be created if it does not exist.
webstepper: Opens a MemoryViz Webstepper webpage to interactively visualize the resulting memory diagrams.
**kwargs: All other keyword arguments are passed to `python.debug.snapshot`. Refer to the `snapshot` function for more details.
"""
Expand All @@ -60,6 +62,8 @@ def __init__(
self._snapshot_args["exclude_frames"] = copy.deepcopy(kwargs.get("exclude_frames", []))
self._snapshot_args["exclude_frames"].append("_trace_func")
self.output_directory = os.path.abspath(output_directory if output_directory else ".")
Path(self.output_directory).mkdir(parents=True, exist_ok=True)

self.webstepper = webstepper
self._first_line = float("inf")

Expand Down

0 comments on commit 7de71f9

Please sign in to comment.