Skip to content

Commit 08cca75

Browse files
committed
test that issue 95 is resolved; fix #95
1 parent 3f92c6b commit 08cca75

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

test/commands/test_daemon.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,70 @@ def wait_for_stat_diff(md_stat, filename, timeout=5):
3838
return False
3939

4040

41+
NO_CRASH_MAIN_MD1 = """
42+
---
43+
entangled:
44+
version: "2.4"
45+
style: "basic"
46+
---
47+
48+
We have a missing reference here.
49+
50+
```python
51+
#| file: test.py
52+
<<test>>
53+
```
54+
""".lstrip()
55+
56+
NO_CRASH_MAIN_MD2 = """
57+
---
58+
entangled:
59+
version: "2.4"
60+
style: "basic"
61+
---
62+
63+
Now it is fixed.
64+
65+
```python
66+
#| file: test.py
67+
<<test>>
68+
```
69+
70+
```python
71+
#| id: test
72+
print("Hello, World")
73+
```
74+
""".lstrip()
75+
76+
@pytest.mark.timeout(10)
77+
def test_no_crash(tmp_path: Path):
78+
"""
79+
Test for issue #95; The watch process would crash on a UserError.
80+
With the new behaviour the process should not do anything, print
81+
a message, but keep running.
82+
"""
83+
with chdir(tmp_path):
84+
configure(debug=True)
85+
stop = threading.Event()
86+
start = threading.Event()
87+
t = threading.Thread(target=_watch, args=(stop, start))
88+
try:
89+
t.start()
90+
# Wait for watch to boot up
91+
start.wait()
92+
93+
Path("main.md").write_text(NO_CRASH_MAIN_MD1)
94+
time.sleep(0.1)
95+
assert not Path("test.py").exists()
96+
Path("main.md").write_text(NO_CRASH_MAIN_MD2)
97+
assert wait_for_file("test.py")
98+
99+
finally:
100+
stop.set()
101+
t.join()
102+
time.sleep(0.1)
103+
104+
41105
@pytest.mark.timeout(10)
42106
def test_daemon(tmp_path: Path):
43107
with chdir(tmp_path):

0 commit comments

Comments
 (0)