Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test-on-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test-on-push
name: test-on-PR

on:
push:
Expand Down Expand Up @@ -61,8 +61,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install apt packages (Linux only)
if: runner.os == 'Linux'
- name: Install apt packages (Linux with python 3.11 only)
if: runner.os == 'Linux' && matrix.python-version == '3.11'
run: |
sudo apt update
sudo apt install -y --no-install-recommends texlive texlive-science texlive-xetex ghostscript pdf2svg texlive-fonts-extra sagemath
Expand Down
5 changes: 3 additions & 2 deletions pretext/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,9 @@ def view(
# Start server if there isn't one running already:
used_port = utils.server_is_running()
if port or restart_server or not used_port:
# First terminate any server that might be running
utils.stop_server(port)
# First terminate the running server
if used_port:
utils.stop_server(used_port)
# Start the server
log.info("Starting server.")
server = project.server_process(
Expand Down
2 changes: 2 additions & 0 deletions pretext/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,8 @@ def generate_assets(
log.debug(f"Unable to generate some sageplot images: {e}")

if "interactive" in assets_to_generate:
# Ensure playwright is installed:
utils.playwright_install()
for id in assets_to_generate["interactive"]:
try:
core.preview_images(
Expand Down
1 change: 1 addition & 0 deletions pretext/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ def stop_server(port: t.Optional[int] = None) -> None:
if len(proc.connections()) > 0:
if (
proc.name() == "pretext"
and proc.parent().name() == "pretext"
and proc.connections()[0].laddr.port == port
):
log.debug(
Expand Down
12 changes: 4 additions & 8 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def pretext_view(*args: str) -> Generator:
process = subprocess.Popen(
[PTX_CMD, "-v", "debug", "view", "--no-launch"] + list(args)
)
time.sleep(3) # stall for possible build
time.sleep(5) # stall for possible build
try:
yield process
finally:
Expand Down Expand Up @@ -186,13 +186,9 @@ def test_view(tmp_path: Path, script_runner: ScriptRunner) -> None:
assert script_runner.run([PTX_CMD, "-v", "debug", "build"]).success
port = random.randint(10_000, 65_536)
with pretext_view("-p", f"{port}"):
assert requests.get(f"http://localhost:{port}/").status_code == 200
os.chdir(tmp_path)
assert script_runner.run([PTX_CMD, "-v", "debug", "new", "-d", "2"]).success
os.chdir(Path("2"))
port = random.randint(10_000, 65_536)
with pretext_view("-p", f"{port}", "-b", "-g"):
assert requests.get(f"http://localhost:{port}/").status_code == 200
r = requests.get(f"http://localhost:{port}")
assert r.status_code == 200
assert script_runner.run([PTX_CMD, "-v", "debug", "view", "-s"]).success


def test_custom_xsl(tmp_path: Path, script_runner: ScriptRunner) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_serve(tmp_path: Path) -> None:
p.start()
time.sleep(1)
assert not (dir / "index.html").exists()
r = requests.get(f"http://localhost:{port}/index.html")
r = requests.get(f"http://localhost:{port}/{dir}/index.html")
assert r.status_code == 404
dir.mkdir()
with open(dir / "index.html", "w") as index_file:
Expand Down Expand Up @@ -209,7 +209,7 @@ def test_manifest_elaborate_build(tmp_path: Path) -> None:
assert (prj_path / "build" / "here" / "web" / "index.html").exists()
if HAS_XELATEX:
project.get_target("print").build()
assert (prj_path / "build" / "here" / "my-pdf" / "main.pdf").exists()
assert (prj_path / "build" / "here" / "my-pdf" / "out.pdf").exists()


def test_manifest_legacy() -> None:
Expand Down