Skip to content

Commit 0c6fd4d

Browse files
committed
Split the input/output data of the conversion from the test code to the respective files
1 parent c78d759 commit 0c6fd4d

File tree

3 files changed

+175
-176
lines changed

3 files changed

+175
-176
lines changed

xtask/src/publish/notes.rs

Lines changed: 4 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -573,185 +573,13 @@ impl Macro {
573573
#[cfg(test)]
574574
mod tests {
575575
use super::*;
576+
use std::fs::read_to_string;
576577

577578
#[test]
578579
fn test_asciidoc_to_markdown_conversion() {
579-
let input = "\
580-
= Changelog #256
581-
:sectanchors:
582-
:page-layout: post
583-
584-
Hello!
585-
586-
Commit: commit:0123456789abcdef0123456789abcdef01234567[] +
587-
Release: release:2022-01-01[]
588-
589-
== New Features
590-
591-
* **BREAKING** pr:1111[] shortcut kbd:[ctrl+r]
592-
- hyphen-prefixed list item
593-
* nested list item
594-
** `foo` -> `foofoo`
595-
** `bar` -> `barbar`
596-
* listing in the secondary level
597-
. install
598-
. add to config
599-
+
600-
[source,json]
601-
----
602-
{\"foo\":\"bar\"}
603-
----
604-
* list item with continuation
605-
+
606-
image::https://example.com/animation.gif[]
607-
+
608-
image::https://example.com/animation.gif[\"alt text\"]
609-
+
610-
video::https://example.com/movie.mp4[options=loop]
611-
+
612-
video::https://example.com/movie.mp4[options=\"autoplay,loop\"]
613-
+
614-
.Image
615-
image::https://example.com/animation.gif[]
616-
+
617-
.Video
618-
video::https://example.com/movie.mp4[options=loop]
619-
+
620-
[source,bash]
621-
----
622-
rustup update nightly
623-
----
624-
+
625-
----
626-
This is a plain listing.
627-
----
628-
* single line item followed by empty lines
629-
630-
* multiline list
631-
item followed by empty lines
632-
633-
* multiline list
634-
item with indent
635-
636-
* multiline list
637-
item not followed by empty lines
638-
* multiline list
639-
item followed by different marker
640-
** foo
641-
** bar
642-
* multiline list
643-
item followed by list continuation
644-
+
645-
paragraph
646-
paragraph
647-
648-
== Another Section
649-
650-
* foo bar baz
651-
* list item with an inline image
652-
image:https://example.com/animation.gif[]
653-
654-
The highlight of the month is probably pr:1111[].
655-
See https://example.com/manual[online manual] for more information.
656-
657-
[source,bash]
658-
----
659-
rustup update nightly
660-
----
661-
662-
[source]
663-
----
664-
rustup update nightly
665-
----
666-
667-
----
668-
This is a plain listing.
669-
----
670-
";
671-
let expected = "\
672-
# Changelog #256
673-
674-
Hello!
675-
676-
Commit: [`0123456`](https://github.com/rust-analyzer/rust-analyzer/commit/0123456789abcdef0123456789abcdef01234567) \\
677-
Release: [`2022-01-01`](https://github.com/rust-analyzer/rust-analyzer/releases/2022-01-01)
678-
679-
## New Features
680-
681-
- **BREAKING** [`#1111`](https://github.com/rust-analyzer/rust-analyzer/pull/1111) shortcut <kbd>ctrl</kbd>+<kbd>r</kbd>
682-
- hyphen-prefixed list item
683-
- nested list item
684-
- `foo` -> `foofoo`
685-
- `bar` -> `barbar`
686-
- listing in the secondary level
687-
1. install
688-
1. add to config
689-
690-
```json
691-
{\"foo\":\"bar\"}
692-
```
693-
- list item with continuation
694-
695-
![](https://example.com/animation.gif)
696-
697-
![alt text](https://example.com/animation.gif)
698-
699-
<video src=\"https://example.com/movie.mp4\" controls loop>Your browser does not support the video tag.</video>
700-
701-
<video src=\"https://example.com/movie.mp4\" autoplay controls loop>Your browser does not support the video tag.</video>
702-
703-
_Image_\\
704-
![](https://example.com/animation.gif)
705-
706-
_Video_\\
707-
<video src=\"https://example.com/movie.mp4\" controls loop>Your browser does not support the video tag.</video>
708-
709-
```bash
710-
rustup update nightly
711-
```
712-
713-
```
714-
This is a plain listing.
715-
```
716-
- single line item followed by empty lines
717-
- multiline list
718-
item followed by empty lines
719-
- multiline list
720-
item with indent
721-
- multiline list
722-
item not followed by empty lines
723-
- multiline list
724-
item followed by different marker
725-
- foo
726-
- bar
727-
- multiline list
728-
item followed by list continuation
729-
730-
paragraph
731-
paragraph
732-
733-
## Another Section
734-
735-
- foo bar baz
736-
- list item with an inline image
737-
![](https://example.com/animation.gif)
738-
739-
The highlight of the month is probably [`#1111`](https://github.com/rust-analyzer/rust-analyzer/pull/1111).
740-
See [online manual](https://example.com/manual) for more information.
741-
742-
```bash
743-
rustup update nightly
744-
```
745-
746-
```
747-
rustup update nightly
748-
```
749-
750-
```
751-
This is a plain listing.
752-
```
753-
";
754-
let actual = convert_asciidoc_to_markdown(std::io::Cursor::new(input)).unwrap();
580+
let input = read_to_string("test_data/input.adoc").unwrap();
581+
let expected = read_to_string("test_data/expected.md").unwrap();
582+
let actual = convert_asciidoc_to_markdown(std::io::Cursor::new(&input)).unwrap();
755583

756584
assert_eq!(actual, expected);
757585
}

xtask/test_data/expected.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Changelog #256
2+
3+
Hello!
4+
5+
Commit: [`0123456`](https://github.com/rust-analyzer/rust-analyzer/commit/0123456789abcdef0123456789abcdef01234567) \
6+
Release: [`2022-01-01`](https://github.com/rust-analyzer/rust-analyzer/releases/2022-01-01)
7+
8+
## New Features
9+
10+
- **BREAKING** [`#1111`](https://github.com/rust-analyzer/rust-analyzer/pull/1111) shortcut <kbd>ctrl</kbd>+<kbd>r</kbd>
11+
- hyphen-prefixed list item
12+
- nested list item
13+
- `foo` -> `foofoo`
14+
- `bar` -> `barbar`
15+
- listing in the secondary level
16+
1. install
17+
1. add to config
18+
19+
```json
20+
{"foo":"bar"}
21+
```
22+
- list item with continuation
23+
24+
![](https://example.com/animation.gif)
25+
26+
![alt text](https://example.com/animation.gif)
27+
28+
<video src="https://example.com/movie.mp4" controls loop>Your browser does not support the video tag.</video>
29+
30+
<video src="https://example.com/movie.mp4" autoplay controls loop>Your browser does not support the video tag.</video>
31+
32+
_Image_\
33+
![](https://example.com/animation.gif)
34+
35+
_Video_\
36+
<video src="https://example.com/movie.mp4" controls loop>Your browser does not support the video tag.</video>
37+
38+
```bash
39+
rustup update nightly
40+
```
41+
42+
```
43+
This is a plain listing.
44+
```
45+
- single line item followed by empty lines
46+
- multiline list
47+
item followed by empty lines
48+
- multiline list
49+
item with indent
50+
- multiline list
51+
item not followed by empty lines
52+
- multiline list
53+
item followed by different marker
54+
- foo
55+
- bar
56+
- multiline list
57+
item followed by list continuation
58+
59+
paragraph
60+
paragraph
61+
62+
## Another Section
63+
64+
- foo bar baz
65+
- list item with an inline image
66+
![](https://example.com/animation.gif)
67+
68+
The highlight of the month is probably [`#1111`](https://github.com/rust-analyzer/rust-analyzer/pull/1111).
69+
See [online manual](https://example.com/manual) for more information.
70+
71+
```bash
72+
rustup update nightly
73+
```
74+
75+
```
76+
rustup update nightly
77+
```
78+
79+
```
80+
This is a plain listing.
81+
```

xtask/test_data/input.adoc

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
= Changelog #256
2+
:sectanchors:
3+
:page-layout: post
4+
5+
Hello!
6+
7+
Commit: commit:0123456789abcdef0123456789abcdef01234567[] +
8+
Release: release:2022-01-01[]
9+
10+
== New Features
11+
12+
* **BREAKING** pr:1111[] shortcut kbd:[ctrl+r]
13+
- hyphen-prefixed list item
14+
* nested list item
15+
** `foo` -> `foofoo`
16+
** `bar` -> `barbar`
17+
* listing in the secondary level
18+
. install
19+
. add to config
20+
+
21+
[source,json]
22+
----
23+
{"foo":"bar"}
24+
----
25+
* list item with continuation
26+
+
27+
image::https://example.com/animation.gif[]
28+
+
29+
image::https://example.com/animation.gif["alt text"]
30+
+
31+
video::https://example.com/movie.mp4[options=loop]
32+
+
33+
video::https://example.com/movie.mp4[options="autoplay,loop"]
34+
+
35+
.Image
36+
image::https://example.com/animation.gif[]
37+
+
38+
.Video
39+
video::https://example.com/movie.mp4[options=loop]
40+
+
41+
[source,bash]
42+
----
43+
rustup update nightly
44+
----
45+
+
46+
----
47+
This is a plain listing.
48+
----
49+
* single line item followed by empty lines
50+
51+
* multiline list
52+
item followed by empty lines
53+
54+
* multiline list
55+
item with indent
56+
57+
* multiline list
58+
item not followed by empty lines
59+
* multiline list
60+
item followed by different marker
61+
** foo
62+
** bar
63+
* multiline list
64+
item followed by list continuation
65+
+
66+
paragraph
67+
paragraph
68+
69+
== Another Section
70+
71+
* foo bar baz
72+
* list item with an inline image
73+
image:https://example.com/animation.gif[]
74+
75+
The highlight of the month is probably pr:1111[].
76+
See https://example.com/manual[online manual] for more information.
77+
78+
[source,bash]
79+
----
80+
rustup update nightly
81+
----
82+
83+
[source]
84+
----
85+
rustup update nightly
86+
----
87+
88+
----
89+
This is a plain listing.
90+
----

0 commit comments

Comments
 (0)