Skip to content

Commit 06b68f6

Browse files
authored
Merge pull request #45 from clue-labs/egrep
Update integration tests to use extended grep instead of PCRE
2 parents 7da3ae5 + 2483a4a commit 06b68f6

1 file changed

Lines changed: 33 additions & 29 deletions

File tree

tests/integration.bash

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ n=0
77
skipping=false
88
curl() {
99
skipping=false
10-
out=$($(which curl) "$@" 2>&1);
10+
out=$($(which curl) "$@" 2>&1 | sed 's/\r$//');
1111
}
1212
match() {
1313
[[ $skipping == true ]] && return 0
@@ -18,24 +18,28 @@ match() {
1818
skipif() {
1919
echo "$out" | grep "$@" >/dev/null && echo -n S && skipping=true || return 0
2020
}
21+
skipifnot() {
22+
echo "$out" | grep "$@" >/dev/null && return 0 || echo -n S && skipping=true
23+
}
2124

2225
# check index endpoint
2326

2427
curl -v $base/ --compressed
2528
match "HTTP/.* 200"
26-
match -iP "Content-Type: text/html[\r\n]"
27-
match -iP "Content-Encoding: br[\r\n]"
28-
match -iP "Vary: Accept-Encoding[\r\n]"
29+
match -iE "Content-Type: text/html$"
30+
match -iE "Vary: Accept-Encoding$"
31+
skipifnot -iE "Accept-Encoding: (.*, ?)?br(,.*)?$"
32+
match -iE "Content-Encoding: br$"
2933

30-
curl -v $base/ --compressed -H 'Accept-Encoding: gzip, deflate'
34+
curl -v $base/ --compressed -H 'Accept-Encoding: gzip'
3135
match "HTTP/.* 200"
32-
match -iP "Content-Type: text/html[\r\n]"
33-
match -iP "Content-Encoding: gzip[\r\n]"
34-
match -iP "Vary: Accept-Encoding[\r\n]"
36+
match -iE "Content-Type: text/html$"
37+
match -iE "Content-Encoding: gzip$"
38+
match -iE "Vary: Accept-Encoding$"
3539

3640
curl -v $base/robots.txt
3741
match "HTTP/.* 200"
38-
match -iP "Content-Type: text/plain[;\r\n]"
42+
match -iE "Content-Type: text/plain(;.*)?$"
3943

4044
curl -v $base/invalid
4145
match "HTTP/.* 404"
@@ -45,85 +49,85 @@ match -i "Content-Type: text/html"
4549

4650
curl -v $base/docs
4751
match "HTTP/.* 301"
48-
match -iP "Location: .*/docs/[\r\n]"
52+
match -iE "Location: .*/docs/$"
4953

5054
curl -v $base/docs/
5155
match "HTTP/.* 302"
52-
match -iP "Location: .*/docs/getting-started/[\r\n]"
56+
match -iE "Location: .*/docs/getting-started/$"
5357

5458
# check HTTP redirects behind CDN
5559

5660
curl -v $base/docs -H 'X-Forwarded-Host: example.com' -H 'X-Forwarded-Proto: https'
5761
match "HTTP/.* 301"
58-
skipif -iP "Location: $base/docs/[\r\n]"
59-
match -iP "Location: https://example\.com/docs/[\r\n]"
62+
skipif -iE "Location: $base/docs/$"
63+
match -iE "Location: https://example\.com/docs/$"
6064

6165
curl -v $base/docs/ -H 'X-Forwarded-Host: example.com' -H 'X-Forwarded-Proto: http'
6266
match "HTTP/.* 302"
63-
skipif -iP "Location: $base/docs/getting-started/[\r\n]"
64-
match -iP "Location: http://example\.com/docs/getting-started/[\r\n]"
67+
skipif -iE "Location: $base/docs/getting-started/$"
68+
match -iE "Location: http://example\.com/docs/getting-started/$"
6569

6670
# check HTTP redirects for chapter endpoints
6771

6872
curl -v $base/docs/getting-started/
6973
match "HTTP/.* 302"
70-
match -iP "Location: .*/docs/getting-started/quickstart/[\r\n]"
74+
match -iE "Location: .*/docs/getting-started/quickstart/$"
7175

7276
curl -v $base/docs/best-practices/
7377
match "HTTP/.* 302"
74-
match -iP "Location: .*/docs/best-practices/controllers/[\r\n]"
78+
match -iE "Location: .*/docs/best-practices/controllers/$"
7579

7680
curl -v $base/docs/api/
7781
match "HTTP/.* 302"
78-
match -iP "Location: .*/docs/api/app/[\r\n]"
82+
match -iE "Location: .*/docs/api/app/$"
7983

8084
curl -v $base/docs/async/
8185
match "HTTP/.* 302"
82-
match -iP "Location: .*/docs/async/fibers/[\r\n]"
86+
match -iE "Location: .*/docs/async/fibers/$"
8387

8488
curl -v $base/docs/integrations/
8589
match "HTTP/.* 302"
86-
match -iP "Location: .*/docs/integrations/database/[\r\n]"
90+
match -iE "Location: .*/docs/integrations/database/$"
8791

8892
# check HTTP redirects for `index.html` at end of path
8993

9094
curl -v $base/index.html
9195
match "HTTP/.* 301"
92-
match -iP "Location: .*/[\r\n]"
96+
match -iE "Location: .*/$"
9397

9498
curl -v $base/docs/index.html
9599
match "HTTP/.* 301"
96-
match -iP "Location: .*/docs/[\r\n]"
100+
match -iE "Location: .*/docs/$"
97101

98102
curl -v $base/docs/getting-started/quickstart/index.html
99103
match "HTTP/.* 301"
100-
match -iP "Location: .*/docs/getting-started/quickstart/[\r\n]"
104+
match -iE "Location: .*/docs/getting-started/quickstart/$"
101105

102106
# check HTTP redirects for old documentation structure
103107

104108
curl -v $base/docs/more/
105109
match "HTTP/.* 302"
106-
match -iP "Location: .*/\.\./getting-started/philosophy/[\r\n]"
110+
match -iE "Location: .*/\.\./getting-started/philosophy/$"
107111

108112
curl -v $base/docs/more/philosophy/
109113
match "HTTP/.* 302"
110-
match -iP "Location: .*/\.\./\.\./getting-started/philosophy/[\r\n]"
114+
match -iE "Location: .*/\.\./\.\./getting-started/philosophy/$"
111115

112116
curl -v $base/docs/more/architecture/
113117
match "HTTP/.* 302"
114-
match -iP "Location: .*/\.\./\.\./getting-started/philosophy/[\r\n]"
118+
match -iE "Location: .*/\.\./\.\./getting-started/philosophy/$"
115119

116120
curl -v $base/docs/more/community/
117121
match "HTTP/.* 302"
118-
match -iP "Location: .*/\.\./\.\./getting-started/community/[\r\n]"
122+
match -iE "Location: .*/\.\./\.\./getting-started/community/$"
119123

120124
curl -v $base/docs/async/child-processes/
121125
match "HTTP/.* 302"
122-
match -iP "Location: .*/\.\./\.\./integrations/child-processes/[\r\n]"
126+
match -iE "Location: .*/\.\./\.\./integrations/child-processes/$"
123127

124128
curl -v $base/docs/async/streaming/
125129
match "HTTP/.* 302"
126-
match -iP "Location: .*/\.\./\.\./integrations/streaming/[\r\n]"
130+
match -iE "Location: .*/\.\./\.\./integrations/streaming/$"
127131

128132
# end
129133

0 commit comments

Comments
 (0)