Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
atools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leo
atools
Commits
248976a3
Commit
248976a3
authored
Jul 31, 2019
by
Leo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for variable-capitalized
parent
a5d29d51
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
0 deletions
+77
-0
tests/apkbuild-lint.bats
tests/apkbuild-lint.bats
+77
-0
No files found.
tests/apkbuild-lint.bats
View file @
248976a3
...
...
@@ -641,4 +641,81 @@ is_travis() {
assert_match "${lines[0]}" "\[AL30\].*:.*double underscore on variables are reserved"
}
@test 'capitalized variable' {
cat <<-"EOF" >$apkbuild
Foo=bar
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
# Match lines[1] instead of lines[0] because check for variables that should have
# underscore coems before it
assert_match "${lines[1]}" "\[AL31\].*:.*variables must not have capital letters"
}
@test 'underscored capitalized variable' {
cat <<-"EOF" >$apkbuild
_Foo=bar
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL31\].*:.*variables must not have capital letters"
}
@test 'normal variable' {
cat <<-"EOF" >$apkbuild
pkgver=1.0
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test 'normal underscored variable' {
cat <<-"EOF" >$apkbuild
_commit=aabbcc
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test 'capitalized local variable' {
cat <<-"EOF" >$apkbuild
foo() {
local NotValid
}
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL31\].*:.*variables must not have capital letters"
}
@test 'capitalized local variable between valid ones' {
cat <<-"EOF" >$apkbuild
foo() {
local valid NotValid correct
}
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL31\].*:.*variables must not have capital letters"
}
@test 'valid local variables' {
cat <<-"EOF" >$apkbuild
foo() {
local valid
}
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
assert_match "${lines[0]}" "\[AL31\].*:.*variables must not have capital letters"
}
# vim: noexpandtab
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment