Skip to content

Commit 6d1ef9a

Browse files
committed
bugfix: -m makefile output behavior; fix tests
1 parent 6863e18 commit 6d1ef9a

File tree

2 files changed

+28
-40
lines changed

2 files changed

+28
-40
lines changed

runfile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ EOF
567567
if [[ " $* " != *' --compat '* ]] && \
568568
! [[ "${RUNFILE_COMPAT:-}" =~ ^(1|true|TRUE|True)$ ]] && \
569569
# If running in Make compatibility mode, skip this section.
570-
[[ " $* " != *' --makefile '* ]] && \
570+
[[ " $* " != *' --makefile '* && " $* " != *' -m '* ]] && \
571571
[[ " $* " != *' --eject '* ]]
572572
# If outputting Makefile, skip this section.
573573
then

test.bats

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -33,77 +33,65 @@ EOF
3333
assert_success
3434
}
3535

36-
@test "${BATS_TEST_NUMBER} run -v" {
36+
function test_version() {
3737
execute_test_command
3838
assert_output --regexp "^[0-9]+\.[0-9]+\.[0-9]$"
3939
assert_success
4040
}
41+
@test "${BATS_TEST_NUMBER} run -v" { test_version; }
42+
@test "${BATS_TEST_NUMBER} run --version" { test_version; }
4143

42-
@test "${BATS_TEST_NUMBER} run --version" {
43-
execute_test_command
44-
assert_output --regexp "^[0-9]+\.[0-9]+\.[0-9]$"
45-
assert_success
46-
}
47-
48-
@test "${BATS_TEST_NUMBER} run -h" {
44+
function test_help() {
4945
execute_test_command
5046
assert_output -p "runfile.sh"
5147
assert_output --regexp "[0-9]+\.[0-9]+\.[0-9]"
5248
assert_output -p "Usage"
53-
assert_output -p "Actions"
54-
assert_output -p "Options"
5549
assert_success
5650
}
51+
@test "${BATS_TEST_NUMBER} run --help" { test_help; }
52+
@test "${BATS_TEST_NUMBER} run -h" { test_help; }
5753

58-
@test "${BATS_TEST_NUMBER} run --help" {
54+
function test_runfile() {
5955
execute_test_command
60-
assert_output -p "runfile.sh"
61-
assert_output --regexp "[0-9]+\.[0-9]+\.[0-9]"
62-
assert_output -p "Usage"
63-
assert_output -p "Actions"
64-
assert_output -p "Options"
56+
assert_output "$( cat ./Runfile )"
6557
assert_success
6658
}
59+
@test "${BATS_TEST_NUMBER} run --runfile" { test_runfile; }
60+
@test "${BATS_TEST_NUMBER} run -r" { test_runfile; }
6761

68-
@test "${BATS_TEST_NUMBER} run --usage" {
62+
function test_runfile_compact() {
6963
execute_test_command
70-
assert_output -p "runfile.sh"
71-
assert_output --regexp "[0-9]+\.[0-9]+\.[0-9]"
72-
assert_output -p "Usage"
73-
assert_output -p "Actions"
74-
assert_output -p "Options"
64+
assert_output "$( cat ./Runfile | sed -e '/^$/d' -e 's/^[[:space:]]//' )"
7565
assert_success
7666
}
67+
@test "${BATS_TEST_NUMBER} run --runfile --compact" { test_runfile_compact; }
68+
@test "${BATS_TEST_NUMBER} run -r --compact" { test_runfile_compact; }
7769

78-
@test "${BATS_TEST_NUMBER} run --runfile" {
70+
function test_makefile() {
7971
execute_test_command
80-
assert_output "$( cat ./Runfile )"
72+
assert_output "$( cat ./Makefile )"
8173
assert_success
8274
}
75+
@test "${BATS_TEST_NUMBER} run --makefile" { test_makefile; }
76+
@test "${BATS_TEST_NUMBER} run -m" { test_makefile; }
8377

84-
@test "${BATS_TEST_NUMBER} run --runfile --runfile-compact" {
78+
function test_makefile_task_start() {
8579
execute_test_command
86-
assert_output "$( cat ./Runfile | sed -e '/^$/d' -e 's/^[[:space:]]//' )"
87-
assert_success
88-
} # shortcut for above:
89-
@test "${BATS_TEST_NUMBER} run --runfile-compact" {
90-
execute_test_command
91-
assert_output "$( cat ./Runfile | sed -e '/^$/d' -e 's/^[[:space:]]//' )"
80+
assert_output -p "$( cat ./Makefile | grep "@" | head -4 | sed 's/^.*@//' )"
9281
assert_success
9382
}
83+
@test "${BATS_TEST_NUMBER} run --makefile start" { test_makefile_task_start; }
84+
@test "${BATS_TEST_NUMBER} run -m start" { test_makefile_task_start; }
9485

95-
@test "${BATS_TEST_NUMBER} run --makefile" {
86+
function test_makefile_task_stop() {
9687
execute_test_command
97-
assert_output "$( cat ./Makefile )"
98-
assert_success
99-
} # same as above; --runfile-compact should have no effect:
100-
@test "${BATS_TEST_NUMBER} run --makefile --runfile-compact" {
101-
execute_test_command
102-
assert_output "$( cat ./Makefile )"
88+
assert_output -p "$( cat ./Makefile | grep "@" | head -5 | tail -1 | sed 's/^.*@//' )"
10389
assert_success
10490
}
91+
@test "${BATS_TEST_NUMBER} run --makefile stop" { test_makefile_task_stop; }
92+
@test "${BATS_TEST_NUMBER} run -m stop" { test_makefile_task_stop; }
10593

106-
@test "${BATS_TEST_NUMBER} run --runfile-aliases" {
94+
@test "${BATS_TEST_NUMBER} run --alias" {
10795
execute_test_command
10896
assert_output "$( cat <<-EOF
10997
# Runfile Aliases

0 commit comments

Comments
 (0)