-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·71 lines (60 loc) · 1.47 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -e
mkdir -p src
echo "hello markdown" > "src/markdown test.md"
echo "<p>hello html</p>" > "src/html test.html"
echo "hello plaintext" > "src/plaintext test.txt"
./build.sh "https://example.com"
read -r -d '' template << EOL || true
<!DOCTYPE html>
<html>
<head>
<title>%s</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<main>%s</main>
</body>
</html>
EOL
read -r -d '' sitemap << EOL || true
https://example.com/html%20test
https://example.com/markdown%20test
https://example.com/plaintext%20test.txt
EOL
if [[ "$sitemap" != "`cat dist/sitemap.txt`" ]] ; then
echo "sitemap failed"
echo -e "expected:" "$sitemap"
echo -e "received:" "`cat dist/sitemap.txt`"
echo
exit 1
fi
md1=`printf "$template" "markdown test" "<p>hello markdown</p>"`
md2=`cat "dist/markdown test.html"`
if [[ "$md1" != "$md2" ]] ; then
echo "markdown failed"
echo -e "expected:" "$md1"
echo -e "received:" "$md2"
echo
exit 1
fi
html1=`printf "$template" "html test" "<p>hello html</p>"`
html2=`cat "dist/html test.html"`
if [[ "$html1" != "$html2" ]] ; then
echo "html failed"
echo -e "expected:" "$html1"
echo -e "received:" "$html2"
echo
exit 1
fi
txt1="hello plaintext"
txt2=`cat "dist/plaintext test.txt"`
if [[ "$txt1" != "$txt2" ]] ; then
echo "plaintext failed"
echo -e "expected:" "$txt1"
echo -e "received:" "$txt2"
echo
exit 1
fi
rm -rf template.html src dist