Skip to content

Commit 81216bb

Browse files
authored
Use gitattributes to make CLI tests fully pass on Windows (#30)
* test cli without newlines * try with just .gitattributes * cleanup
1 parent 2776074 commit 81216bb

File tree

2 files changed

+8
-39
lines changed

2 files changed

+8
-39
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

plugins/postcss-base-plugin/test/cli/test.sh

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
set -e
22

3-
echo $OSTYPE
4-
53
# Zero out result file
64
echo '' > ./test/cli/basic.result.css;
75

86
# Test with long flag
97
postcss-base-plugin ./test/cli/basic.css --output ./test/cli/basic.result.css
108

119
# Check result
12-
if [[ "$OSTYPE" == "msys" ]]; then
13-
# CRLF on Windows makes it hard to test with base64 encoded sourcemaps
14-
echo 'did not compare actual output assuming exit 0 means everything is ok'
15-
else
16-
git --no-pager diff --no-index --word-diff ./test/cli/basic.expect.css ./test/cli/basic.result.css
17-
fi
10+
git --no-pager diff --no-index --word-diff ./test/cli/basic.expect.css ./test/cli/basic.result.css
1811

1912
# Reset result file
2013
cat ./test/cli/basic.css > ./test/cli/basic.replace.css;
@@ -23,12 +16,7 @@ cat ./test/cli/basic.css > ./test/cli/basic.replace.css;
2316
postcss-base-plugin ./test/cli/basic.replace.css -r
2417

2518
# Check result
26-
if [[ "$OSTYPE" == "msys" ]]; then
27-
# CRLF on Windows makes it hard to test with base64 encoded sourcemaps
28-
echo 'did not compare actual output assuming exit 0 means everything is ok'
29-
else
30-
git --no-pager diff --no-index --word-diff ./test/cli/basic.replace.css ./test/cli/basic.replace.expect.css
31-
fi
19+
git --no-pager diff --no-index --word-diff ./test/cli/basic.replace.css ./test/cli/basic.replace.expect.css
3220

3321
# Zero out result file
3422
echo '' > ./test/cli/basic.color.result.css;
@@ -37,12 +25,7 @@ echo '' > ./test/cli/basic.color.result.css;
3725
postcss-base-plugin ./test/cli/basic.css -o ./test/cli/basic.color.result.css -p '{ "color": "purple" }'
3826

3927
# Check result
40-
if [[ "$OSTYPE" == "msys" ]]; then
41-
# CRLF on Windows makes it hard to test with base64 encoded sourcemaps
42-
echo 'did not compare actual output assuming exit 0 means everything is ok'
43-
else
44-
git --no-pager diff --no-index --word-diff ./test/cli/basic.color.expect.css ./test/cli/basic.color.result.css
45-
fi
28+
git --no-pager diff --no-index --word-diff ./test/cli/basic.color.expect.css ./test/cli/basic.color.result.css
4629

4730
# Zero out result file
4831
echo '' > ./test/cli/basic.stdin.result.css;
@@ -51,12 +34,7 @@ echo '' > ./test/cli/basic.stdin.result.css;
5134
cat ./test/cli/basic.css | postcss-base-plugin > ./test/cli/basic.stdin.result.css
5235

5336
# Check result
54-
if [[ "$OSTYPE" == "msys" ]]; then
55-
# CRLF on Windows makes it hard to test with base64 encoded sourcemaps
56-
echo 'did not compare actual output assuming exit 0 means everything is ok'
57-
else
58-
git --no-pager diff --no-index --word-diff ./test/cli/basic.stdin.expect.css ./test/cli/basic.stdin.result.css
59-
fi
37+
git --no-pager diff --no-index --word-diff ./test/cli/basic.stdin.expect.css ./test/cli/basic.stdin.result.css
6038

6139
# Zero out result file
6240
echo '' > ./test/cli/basic.no-map.result.css;
@@ -76,12 +54,7 @@ cat ./test/cli/basic.css | postcss-base-plugin --map -o ./test/cli/basic.extern
7654

7755
# Check result
7856
git --no-pager diff --no-index --word-diff ./test/cli/basic.external-map.expect.css ./test/cli/basic.external-map.result.css
79-
if [[ "$OSTYPE" == "msys" ]]; then
80-
# CRLF on Windows makes it hard to test with base64 encoded sourcemaps
81-
echo 'did not compare actual output assuming exit 0 means everything is ok'
82-
else
83-
git --no-pager diff --no-index --word-diff ./test/cli/basic.external-map.expect.css.map ./test/cli/basic.external-map.result.css.map
84-
fi
57+
git --no-pager diff --no-index --word-diff ./test/cli/basic.external-map.expect.css.map ./test/cli/basic.external-map.result.css.map
8558

8659
# Zero out result file
8760
echo '' > ./test/cli/out/a.css
@@ -95,14 +68,9 @@ postcss-base-plugin ./test/cli/src/a.css ./test/cli/src/b.css -m -d ./test/cli/o
9568
# Check result
9669
git --no-pager diff --no-index --word-diff ./test/cli/out/a.css ./test/cli/out/a.expect.css
9770
git --no-pager diff --no-index --word-diff ./test/cli/out/b.css ./test/cli/out/b.expect.css
71+
git --no-pager diff --no-index --word-diff ./test/cli/out/a.css.map ./test/cli/out/a.expect.css.map
72+
git --no-pager diff --no-index --word-diff ./test/cli/out/b.css.map ./test/cli/out/b.expect.css.map
9873

99-
if [[ "$OSTYPE" == "msys" ]]; then
100-
# CRLF on Windows makes it hard to test with base64 encoded sourcemaps
101-
echo 'did not compare actual output assuming exit 0 means everything is ok'
102-
else
103-
git --no-pager diff --no-index --word-diff ./test/cli/out/a.css.map ./test/cli/out/a.expect.css.map
104-
git --no-pager diff --no-index --word-diff ./test/cli/out/b.css.map ./test/cli/out/b.expect.css.map
105-
fi
10674

10775
# Zero out result file
10876
echo '' > ./test/cli/out/concatenated.css

0 commit comments

Comments
 (0)