Skip to content

Commit ea68ece

Browse files
committed
Move exit code tests to a file of their own
1 parent 7bfebcc commit ea68ece

File tree

3 files changed

+73
-72
lines changed

3 files changed

+73
-72
lines changed

tests/EndToEnd/exit_code_test.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
3+
function tear_down() {
4+
rm -f tests/EndToEnd/Fixtures/*.fixed
5+
}
6+
7+
function test_phpcs_exit_code_clean_file() {
8+
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassOneWithoutStyleError.inc
9+
assert_exit_code 0
10+
}
11+
function test_phpcs_exit_code_clean_stdin() {
12+
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassOneWithoutStyleError.inc
13+
assert_exit_code 0
14+
}
15+
function test_phpcbf_exit_code_clean_file() {
16+
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassOneWithoutStyleError.inc
17+
assert_exit_code 0
18+
}
19+
function test_phpcbf_exit_code_clean_stdin() {
20+
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassOneWithoutStyleError.inc
21+
assert_exit_code 0
22+
}
23+
24+
function test_phpcs_exit_code_fixable_file() {
25+
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithStyleError.inc
26+
assert_exit_code 1
27+
}
28+
function test_phpcs_exit_code_fixable_stdin() {
29+
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithStyleError.inc
30+
assert_exit_code 1
31+
}
32+
function test_phpcbf_exit_code_fixable_file() {
33+
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithStyleError.inc
34+
assert_exit_code 0
35+
}
36+
function test_phpcbf_exit_code_fixable_stdin() {
37+
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithStyleError.inc
38+
assert_exit_code 0
39+
}
40+
41+
function test_phpcs_exit_code_non_fixable_file() {
42+
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithUnfixableStyleError.inc
43+
assert_exit_code 2
44+
}
45+
function test_phpcs_exit_code_non_fixable_stdin() {
46+
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithUnfixableStyleError.inc
47+
assert_exit_code 2
48+
}
49+
function test_phpcbf_exit_code_non_fixable_file() {
50+
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithUnfixableStyleError.inc
51+
assert_exit_code 2
52+
}
53+
function test_phpcbf_exit_code_non_fixable_stdin() {
54+
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithUnfixableStyleError.inc
55+
assert_exit_code 2
56+
}
57+
58+
function test_phpcs_exit_code_fixable_and_non_fixable_file() {
59+
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithTwoStyleErrors.inc
60+
assert_exit_code 3
61+
}
62+
function test_phpcs_exit_code_fixable_and_non_fixable_stdin() {
63+
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithTwoStyleErrors.inc
64+
assert_exit_code 3
65+
}
66+
function test_phpcbf_exit_code_fixable_and_non_fixable_file() {
67+
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithTwoStyleErrors.inc
68+
assert_exit_code 2
69+
}
70+
function test_phpcbf_exit_code_fixable_and_non_fixable_stdin() {
71+
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithTwoStyleErrors.inc
72+
assert_exit_code 2
73+
}

tests/EndToEnd/phpcbf_test.sh

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,39 +43,3 @@ function test_phpcbf_bug_1112() {
4343
assert_successful_code "$(bash -ic 'bash --init-file <(echo "echo \"Subprocess\"") -c "bin/phpcbf --no-cache --parallel=2 --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassOneWithoutStyleError.inc tests/EndToEnd/Fixtures/ClassTwoWithoutStyleError.inc"')"
4444
fi
4545
}
46-
47-
function test_phpcbf_exit_code_clean() {
48-
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassOneWithoutStyleError.inc
49-
assert_exit_code 0
50-
51-
# Same result via STDIN
52-
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassOneWithoutStyleError.inc
53-
assert_exit_code 0
54-
}
55-
56-
function test_phpcbf_exit_code_fixable() {
57-
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithStyleError.inc
58-
assert_exit_code 0
59-
60-
# Same result via STDIN
61-
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithStyleError.inc
62-
assert_exit_code 0
63-
}
64-
65-
function test_phpcbf_exit_code_non_fixable() {
66-
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithUnfixableStyleError.inc
67-
assert_exit_code 2
68-
69-
# Same result via STDIN
70-
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithUnfixableStyleError.inc
71-
assert_exit_code 2
72-
}
73-
74-
function test_phpcbf_exit_code_fixable_and_non_fixable() {
75-
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithTwoStyleErrors.inc
76-
assert_exit_code 2
77-
78-
# Same result via STDIN
79-
bin/phpcbf --suffix=.fixed --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithTwoStyleErrors.inc
80-
assert_exit_code 2
81-
}

tests/EndToEnd/phpcs_test.sh

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,3 @@ function test_phpcs_bug_1112() {
2626
assert_successful_code "$(bash -ic 'bash --init-file <(echo "echo \"Subprocess\"") -c "bin/phpcs --no-cache --parallel=2 --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassOneWithoutStyleError.inc tests/EndToEnd/Fixtures/ClassTwoWithoutStyleError.inc"')"
2727
fi
2828
}
29-
30-
function test_phpcs_exit_code_clean() {
31-
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassOneWithoutStyleError.inc
32-
assert_exit_code 0
33-
34-
# Same result via STDIN
35-
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassOneWithoutStyleError.inc
36-
assert_exit_code 0
37-
}
38-
39-
function test_phpcs_exit_code_fixable() {
40-
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithStyleError.inc
41-
assert_exit_code 1
42-
43-
# Same result via STDIN
44-
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithStyleError.inc
45-
assert_exit_code 1
46-
}
47-
48-
function test_phpcs_exit_code_non_fixable() {
49-
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithUnfixableStyleError.inc
50-
assert_exit_code 2
51-
52-
# Same result via STDIN
53-
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithUnfixableStyleError.inc
54-
assert_exit_code 2
55-
}
56-
57-
function test_phpcs_exit_code_fixable_and_non_fixable() {
58-
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ClassWithTwoStyleErrors.inc
59-
assert_exit_code 3
60-
61-
# Same result via STDIN
62-
bin/phpcs --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist < tests/EndToEnd/Fixtures/ClassWithTwoStyleErrors.inc
63-
assert_exit_code 3
64-
}

0 commit comments

Comments
 (0)