Skip to content

Commit f819584

Browse files
authored
Add tests for Julia (#4012)
* Added tests for Julia These are simple ports of existing Python tests. * Added Julia install and setup to test-smokes workflow. * fix julia-subfig test
1 parent f0c58c0 commit f819584

File tree

10 files changed

+177
-2
lines changed

10 files changed

+177
-2
lines changed

.github/workflows/test-smokes.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ jobs:
7070
pushd tests
7171
source bin/activate
7272
python3 -m pip install --upgrade pip pip==21.3.1
73-
python3 -m pip install wheel
73+
python3 -m pip install wheel
7474
python3 -m pip install --user virtualenv
75-
python3 -m pip install -r requirements.txt
75+
python3 -m pip install -r requirements.txt
7676
popd
7777
7878
- uses: ./.github/workflows/actions/quarto-dev
@@ -86,6 +86,15 @@ jobs:
8686
- name: Install Chrome
8787
uses: browser-actions/setup-chrome@latest
8888

89+
- name: Setup Julia
90+
uses: julia-actions/setup-julia@v1
91+
92+
- name: Julia Packages
93+
run: |
94+
pushd tests
95+
julia --project=. -e "import Pkg; Pkg.instantiate(); Pkg.build(\"IJulia\"); Pkg.precompile()"
96+
popd
97+
8998
- name: Smoke Test Commits
9099
if: github.event.before != ''
91100
env:

tests/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
3+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: "Quarto Jupyter Cell Attribute Implementation Reference"
3+
format:
4+
html:
5+
keep-md: true
6+
code-background: true
7+
---
8+
9+
I thought `output:false` would suppress the output, but no? `echo: false` does it.
10+
11+
```{julia}
12+
#| echo: false
13+
using Plots
14+
```
15+
16+
## `label`
17+
18+
```{julia}
19+
#| label: julia-label-1
20+
21+
plot([1,2,3,4])
22+
```
23+
24+
25+
```{julia}
26+
#| label: julia label 2
27+
28+
plot([1,2,3,4])
29+
```
30+
31+
### `fig-cap`
32+
33+
```{julia}
34+
#| label: fig-caption-test
35+
#| fig-cap: A caption for the figure
36+
37+
plot([1,2,3,4])
38+
```
39+
40+
**(Styling Bug?) Centering of images appears inconsistent depending on whether they have captions?**
41+
42+
### `fig-subcap`
43+
44+
```{julia}
45+
#| label: fig-big-caption-test
46+
#| fig-cap: Big caption
47+
#| fig-subcap:
48+
#| - Caption 1
49+
#| - Caption 2
50+
plot([4,3,2,1]) |> display
51+
plot([1,2,3,4]) |> display
52+
```
53+
54+
55+
```{julia}
56+
#| label: fig-no-big-caption-test
57+
#| fig-subcap:
58+
#| - Caption 1
59+
#| - Caption 2
60+
plot([4,3,2,1]) |> display
61+
plot([1,2,3,4]) |> display
62+
```
63+
64+
### `code-fold` and `code-summary`
65+
66+
**(Inconsistency?) The R engine sets code-fold and code-summary for both the outer and inner div; The Julia engine ...**
67+
68+
Fold:
69+
70+
```{julia}
71+
#| code-fold: true
72+
plot([1,2,3,4])
73+
```
74+
75+
Summary:
76+
77+
```{julia}
78+
#| code-summary: "Some text"
79+
plot([1,2,3,4])
80+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Julia Subfig Test
3+
---
4+
5+
## Julia Crossref Figure
6+
7+
```{julia}
8+
#| label: fig-plots
9+
#| fig-cap: "Plots"
10+
#| fig-subcap:
11+
#| - "Plot 1"
12+
#| - "Plot 2"
13+
#| layout-ncol: 2
14+
15+
using Plots
16+
plot([1,23,2,4]) |> display
17+
18+
plot([8,65,23,90]) |> display
19+
```
20+
21+
See @fig-plots for examples. In particular, @fig-plots-2.

tests/docs/crossrefs/julia.qmd

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Julia Crossref Test
3+
---
4+
5+
## Julia Crossref Figure
6+
7+
```{julia}
8+
#| label: fig-plot
9+
#| fig-cap: "Plot"
10+
11+
using Plots
12+
Plots.gr(format="png")
13+
plot([1,23,2,4])
14+
```
15+
16+
For example, see @fig-plot.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Some text
2+
3+
```{julia}
4+
1 + 1
5+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: test
3+
format: commonmark
4+
---
5+
6+
```{julia}
7+
1 + 1
8+
```

tests/smoke/convert/convert-empty-frontmatter.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ import { docs } from "../../utils.ts";
88
import { testConvert } from "./convert.ts";
99

1010
testConvert(docs("empty-frontmatter.qmd"));
11+
testConvert(docs("empty-frontmatter-julia.qmd"));

tests/smoke/crossref/figures.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,37 @@ if (Deno.build.os !== "windows") {
6363
/\?@fig-/,
6464
]),
6565
]);
66+
67+
const juliaQmd = crossref("julia.qmd", "html");
68+
testRender(juliaQmd.input, "html", false, [
69+
ensureHtmlElements(juliaQmd.output.outputPath, [
70+
"section#julia-crossref-figure div#fig-plot > figure img.figure-img",
71+
"section#julia-crossref-figure div#fig-plot > figure > figcaption",
72+
]),
73+
ensureFileRegexMatches(juliaQmd.output.outputPath, [
74+
/Figure 1: Plot/,
75+
/Figure 1/,
76+
], [
77+
/\?@fig-/,
78+
]),
79+
]);
80+
81+
const juliaSubfigQmd = crossref("julia-subfig.qmd", "html");
82+
testRender(juliaSubfigQmd.input, "html", false, [
83+
ensureHtmlElements(juliaSubfigQmd.output.outputPath, [
84+
"section#julia-crossref-figure div.quarto-layout-panel > figure > div.quarto-layout-row",
85+
"section#julia-crossref-figure div.quarto-layout-panel > figure > figcaption.figure-caption",
86+
]),
87+
ensureFileRegexMatches(juliaSubfigQmd.output.outputPath, [
88+
/Figure 1: Plots/,
89+
/Figure 1/,
90+
/Figure 1 \(b\)/,
91+
/\(a\) Plot 1/,
92+
/\(b\) Plot 2/,
93+
], [
94+
/\?@fig-/,
95+
]),
96+
]);
6697
}
6798

6899
const knitrQmd = crossref("knitr.qmd", "html");

tests/smoke/render/render-commonmark.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const tests = [
1313
{ file: "commonmark-plain.qmd", python: false },
1414
{ file: "commonmark-r.qmd", python: false },
1515
{ file: "commonmark-python.qmd", python: true },
16+
{ file: "commonmark-julia.qmd", python: false },
1617
];
1718
tests.forEach((test) => {
1819
const input = docs(join("markdown", test.file));

0 commit comments

Comments
 (0)