Commit 55be4eae authored by Leo's avatar Leo

add tests for double-underscore-in-variable

parent cc54aeac
...@@ -554,4 +554,91 @@ is_travis() { ...@@ -554,4 +554,91 @@ is_travis() {
assert_match "${lines[0]}" "\[AL29\].*:.*$pkgname should not be used in the source url" assert_match "${lines[0]}" "\[AL29\].*:.*$pkgname should not be used in the source url"
} }
@test 'double underscore in variable' {
cat <<-"EOF" >$apkbuild
__invalid=1.0
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL30\].*:.*double underscore on variables are reserved"
}
@test 'double underscore in tabbed variable' {
cat <<-"EOF" >$apkbuild
__invalid=1.0
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL30\].*:.*double underscore on variables are reserved"
}
@test 'no underscore in variable' {
cat <<-"EOF" >$apkbuild
pkgver=1.0
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test 'no underscore in tabbed variable' {
cat <<-"EOF" >$apkbuild
pkgver=1.0
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test 'double underscore in local variable' {
cat <<-"EOF" >$apkbuild
foo() {
local __invalid
}
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL30\].*:.*double underscore on variables are reserved"
}
@test 'double underscore in local tabbed variable' {
cat <<-"EOF" >$apkbuild
foo() {
local __invalid
}
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL30\].*:.*double underscore on variables are reserved"
}
@test 'double underscore in local tabbed variable with valid variable after' {
cat <<-"EOF" >$apkbuild
foo() {
local __invalid valid
}
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL30\].*:.*double underscore on variables are reserved"
}
@test 'double underscore in local tabbed variable with valid variable before' {
cat <<-"EOF" >$apkbuild
foo() {
local valid __invalid
}
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL30\].*:.*double underscore on variables are reserved"
}
# vim: noexpandtab # vim: noexpandtab
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment