mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
45 lines
1.2 KiB
Bash
45 lines
1.2 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helpers
|
|
|
|
banned_commands=(
|
|
realpath
|
|
# readlink on OSX behaves differently from readlink on other Unix systems
|
|
readlink
|
|
# It's best to avoid eval as it makes it easier to accidentally execute
|
|
# arbitrary strings
|
|
eval
|
|
# Command isn't included in the Ubuntu packages asdf depends on. Also not
|
|
# defined in POSIX
|
|
column
|
|
# does not work on alpine and should be grep -i either way
|
|
"grep.* -y"
|
|
# sort --sort-version isn't supported everywhere
|
|
"sort.*-V"
|
|
"sort.*--sort-versions"
|
|
# echo isn't consistent across operating systems, and sometimes output can
|
|
# be confused with echo flags. printf does everything echo does and more.
|
|
echo
|
|
# Process substitution isn't POSIX compliant and cause trouble
|
|
"<("
|
|
)
|
|
|
|
setup() {
|
|
setup_asdf_dir
|
|
}
|
|
|
|
teardown() {
|
|
clean_asdf_dir
|
|
}
|
|
|
|
@test "banned commands are not found in source code" {
|
|
for cmd in "${banned_commands[@]}"; do
|
|
# Assert command is not used in the lib and bin dirs
|
|
# or expect an explicit comment at end of line, allowing it.
|
|
run bash -c "grep -nHR '$cmd' lib bin | grep -v '# asdf_allow: $cmd'"
|
|
echo "banned command $cmd: $output"
|
|
[ "$status" -eq 1 ]
|
|
[ "" == "$output" ]
|
|
done
|
|
}
|