Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
updated test_language and add walker update code
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishMahendra committed Sep 6, 2024
1 parent 69245a9 commit cc00d19
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
19 changes: 19 additions & 0 deletions jaclang/tests/fixtures/walker_update.jac
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import:jac from bar { bar_walk }
import:py from jaclang.runtimelib.machine { JacMachine }
import:py os;

can update_bar_walker {
"Updating bar.jac with new behavior." |> print;
(bar_walk_new, ) = JacMachine.get().update_walker(
"bar",
items={'bar_walk': None}
);
"Running bar_walk after update..." |> print;
root spawn bar_walk_new();
print(f"bar_walk: {bar_walk_new.__dict__}");
}


with entry {
update_bar_walker();
}
8 changes: 3 additions & 5 deletions jaclang/tests/test_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ def test_walker_dynamic_update(self) -> None:
"""Test dynamic update of a walker during runtime."""
session = self.fixture_abs_path("bar_walk.session")
bar_file_path = self.fixture_abs_path("bar.jac")
update_file_path = self.fixture_abs_path("walker_update.jac")
captured_output = io.StringIO()
sys.stdout = captured_output
cli.enter(
Expand Down Expand Up @@ -996,11 +997,8 @@ def test_walker_dynamic_update(self) -> None:
sys.stdout = captured_output

try:
cli.enter(
filename=bar_file_path,
session=session,
entrypoint="bar_walk",
args=[],
cli.run(
filename=update_file_path,
)
sys.stdout = sys.__stdout__
stdout_value = captured_output.getvalue()
Expand Down

0 comments on commit cc00d19

Please sign in to comment.