Skip to content

Commit

Permalink
Allow hyphens to appear in task names
Browse files Browse the repository at this point in the history
  • Loading branch information
jotaen committed Nov 6, 2023
1 parent 992882a commit 42f48f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
4 changes: 2 additions & 2 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ ACTION=(run::action-list)

# Regex patterns for parsing the task file.
COMMENT_PATTERN='^#{1,}[[:blank:]]?(.*)$'
TASK_DEF_PATTERN_1='^[[:blank:]]*run::([a-zA-Z0-9_]+)[[:blank:]]*\([[:blank:]]*\)'
TASK_DEF_PATTERN_2='^[[:blank:]]*function[[:blank:]]*run::([a-zA-Z0-9_]+)'
TASK_DEF_PATTERN_1='^[[:blank:]]*run::([a-zA-Z0-9_-]+)[[:blank:]]*\([[:blank:]]*\)'
TASK_DEF_PATTERN_2='^[[:blank:]]*function[[:blank:]]*run::([a-zA-Z0-9_-]+)'

# The --help procedure.
run::action-help() {
Expand Down
29 changes: 27 additions & 2 deletions spec/task.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,41 @@ task::fails_if_task_does_not_exist() { #@test
[[ "${output}" == 'No such task: foobar' ]]
}

task::disregards_invalid_names() { #@test
task::recognises_valid_task_names() { #@test
create run.sh '
run::foo:bar() {
run::foo() {
echo
}
run::foo123() {
echo
}
run::foo-bar() {
echo
}
run::foo_bar() {
echo
}
'

EXPECTED_OUTPUT='foo
foo123
foo-bar
foo_bar'

run main --list
[[ "${status}" -eq 0 ]]
[[ "${output}" == "${EXPECTED_OUTPUT}" ]]
}

task::disregards_invalid_task_names() { #@test
create run.sh '
run::foo:bar() {
echo
}
run::%!&@() {
echo
}
Expand Down

0 comments on commit 42f48f9

Please sign in to comment.