Skip to content

Commit 9b27f9b

Browse files
authored
fix asymptote test (#757)
* fix asymptote test * make proper pretext doc
1 parent bf9d3cb commit 9b27f9b

File tree

4 files changed

+59
-11
lines changed

4 files changed

+59
-11
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- This file, the project manifest, provides the overall configuration for your PreTeXt project. To edit the content of your document, open `source/main.ptx`. See https://pretextbook.org/doc/guide/html/processing-CLI.html#cli-project-manifest. -->
3+
<project ptx-version="2">
4+
<targets>
5+
<target name="web" format="html" />
6+
<target name="print" format="pdf" />
7+
</targets>
8+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<publication>
3+
<!-- directories are relative to the main source PreTeXt file -->
4+
<source>
5+
<directories external="../assets" generated="../generated-assets"/>
6+
</source>
7+
</publication>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<pretext xmlns:xi="http://www.w3.org/2001/XInclude">
4+
<book>
5+
<title>Asymptote</title>
6+
<chapter xml:id="ch-foo">
7+
<title>foo</title>
8+
<image xml:id="test">
9+
<asymptote>
10+
size(4cm,6cm);
11+
pen canadared=rgb(235/256,45/256,55/256);
12+
real flagwidth=4, flagheight=2;
13+
path flag_outline=scale(flagwidth,flagheight)*unitsquare;
14+
path cbar1=scale(1,2)*unitsquare, cbar2=shift(3,0)*cbar1;
15+
path mapleleafleft=
16+
(0,-102) --(-5,-102)--(-2,-56) {dir(87)}..{dir(190)}
17+
(-8,-53) --(-51,-61)--(-45,-45){dir(70)}..{dir(141)}
18+
(-46,-41)--(-94,-3) --(-82,1) {dir(25)}..{dir(108)}
19+
(-81,6) --(-90,34) --(-63,29) {dir(348)}..{dir(67)}
20+
(-59,30) --(-54,43) --(-33,20) {dir(313)}..{dir(101)}
21+
(-27,23) --(-38,76) --(-21,62) {dir(330)}..{dir(63)}
22+
(-16,67) --(0,100);
23+
path mapleleafright=reflect((0,0),(0,1))*reverse(mapleleafleft);
24+
path mapleleaf=mapleleafleft--mapleleafright--cycle;
25+
filldraw(flag_outline,white,black);
26+
fill(cbar1,canadared);
27+
fill(cbar2,canadared);
28+
fill(shift(2,1)*scale(.008)*mapleleaf,canadared);
29+
draw(flag_outline);
30+
</asymptote>
31+
</image>
32+
</chapter>
33+
</book>
34+
</pretext>

tests/test_cli.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,22 @@ def test_init(tmp_path: Path, script_runner: ScriptRunner) -> None:
126126

127127

128128
def test_generate_asymptote(tmp_path: Path, script_runner: ScriptRunner) -> None:
129-
assert script_runner.run([PTX_CMD, "-v", "debug", "init"], cwd=tmp_path).success
130-
(tmp_path / "source").mkdir()
131-
shutil.copyfile(EXAMPLES_DIR / "asymptote.ptx", tmp_path / "source" / "main.ptx")
129+
asy_path = tmp_path / "asymptote"
130+
shutil.copytree(EXAMPLES_DIR / "projects" / "asymptote", asy_path)
132131
assert script_runner.run(
133-
[PTX_CMD, "-v", "debug", "generate", "asymptote"], cwd=tmp_path
132+
[PTX_CMD, "-v", "debug", "generate", "asymptote"], cwd=asy_path
134133
).success
135-
assert (tmp_path / "generated-assets" / "asymptote" / "test.html").exists()
136-
os.remove(tmp_path / "generated-assets" / "asymptote" / "test.html")
134+
assert (asy_path / "generated-assets" / "asymptote" / "test.html").exists()
135+
os.remove(asy_path / "generated-assets" / "asymptote" / "test.html")
137136
assert script_runner.run(
138-
[PTX_CMD, "-v", "debug", "generate", "-x", "test"], cwd=tmp_path
137+
[PTX_CMD, "-v", "debug", "generate", "-x", "test"], cwd=asy_path
139138
).success
140-
assert (tmp_path / "generated-assets" / "asymptote" / "test.html").exists()
141-
os.remove(tmp_path / "generated-assets" / "asymptote" / "test.html")
139+
assert (asy_path / "generated-assets" / "asymptote" / "test.html").exists()
140+
os.remove(asy_path / "generated-assets" / "asymptote" / "test.html")
142141
assert script_runner.run(
143-
[PTX_CMD, "-v", "debug", "generate", "asymptote", "-t", "web"], cwd=tmp_path
142+
[PTX_CMD, "-v", "debug", "generate", "asymptote", "-t", "web"], cwd=asy_path
144143
).success
145-
os.remove(tmp_path / "generated-assets" / "asymptote" / "test.html")
144+
os.remove(asy_path / "generated-assets" / "asymptote" / "test.html")
146145

147146

148147
# @pytest.mark.skip(

0 commit comments

Comments
 (0)