Commit 2ed493d4 authored by Vojtěch Horký's avatar Vojtěch Horký
Browse files

Tasks 14

parent d635caee
#!/usr/bin/env bats
#> task: 14/command.txt
load "../../nswi177"
@test "14/command.txt - Submitted (0)" {
fail_if_missing
}
@test "14/command.txt - Not executable (-10)" {
skip_if_missing
assert_is_not_executable
}
@test "14/command.txt - Correct format (5)" {
skip_if_missing
launch paste -s -d ' ' <14/command.txt
strip_output_whitespace
answer="${output}"
launch grep -E '^[0-9a-f]{32}$' <<<"${answer}"
msg='Invalid format, grep "[0-9a-f]{32}" failed' hide_exit_code=true assert_status 0 \
'answer' "${answer}" \
'hint' 'Have you copied all the characters?'
}
#!/usr/bin/env bats
#> task: 14/shellcheck.sh
load "../../nswi177"
skip_without_tool() {
if ! shyaml --version &>/dev/null; then
skip "shyaml tool not installed"
fi
}
@test "14/shellcheck.sh - Submitted (0)" {
fail_if_missing
}
@test "14/shellcheck.sh - Proper shebang (-30)" {
skip_if_missing
assert_is_shell
}
@test "14/shellcheck.sh - Executable bit (-30)" {
skip_if_missing
assert_is_executable
}
@test "14/shellcheck.shh - Shellcheck errors (-3)" {
skip_if_missing
assert_is_shellchecked error
}
@test "14/shellcheck.sh - Shellcheck warnings (-3)" {
skip_if_missing
assert_is_shellchecked warning
}
@test "14/shellcheck.sh - Shellcheck infos (0)" {
skip_if_missing
assert_is_shellchecked info
}
@test "14/shellcheck.sh - Shellcheck stylistic (0)" {
skip_if_missing
assert_is_shellchecked style
}
@test ".gitlab-ci.yml - Submitted (0)" {
fail_if_missing
}
@test ".gitlab-ci.yml - Valid YAML (0)" {
skip_if_missing
skip_without_tool
launch shyaml keys <.gitlab-ci.yml
msg=".gitlab-ci.yml malformatted" hide_exit_code=true assert_status 0 \
'stderr' "$erroroutput"
}
@test ".gitlab-ci.yml - Has shellcheck job (10)" {
skip_if_missing
skip_without_tool
launch shyaml get-value shellcheck <.gitlab-ci.yml
msg="Unable to find shellcheck job in .gitlab-ci.yml" hide_exit_code=true assert_status 0 \
'stderr' "$erroroutput" \
'note' "This might be a false alarm if you have splitted your CI configuration"
}
@test ".gitlab-ci.yml - Shellcheck pipeline calls 14/shellcheck.sh (10)" {
skip_if_missing
skip_without_tool
launch shyaml get-value shellcheck <.gitlab-ci.yml
if [ "${status}" -ne 0 ]; then
skip "Unable to find shellcheck job in .gitlab-ci.yml (see previous test)"
fi
job_definition="${output}"
launch shyaml get-value script <<<"${output}"
msg="No script for shellcheck job" hide_exit_code=true assert_status 0 \
'stderr' "$erroroutput" \
'pipeline' "$job_definition" \
'hint' "Do you have script section in your pipeline definition?"
launch grep -F 14/shellcheck.sh <<<"${output}"
msg="No call of 14/shellcheck.sh" hide_exit_code=true assert_status 0 \
'stderr' "$erroroutput" \
'hint' "Does your shellcheck job call your script?"
}
#!/usr/bin/env bats
#> task: 14/volume.txt
load "../../nswi177"
@test "14/volume.txt - Submitted (0)" {
fail_if_missing
}
@test "14/volume.txt - Not executable (-10)" {
skip_if_missing
assert_is_not_executable
}
@test "14/volume.txt - Correct format (5)" {
skip_if_missing
launch paste -s -d ' ' <14/volume.txt
strip_output_whitespace
answer="${output}"
launch grep -E '^[0-9a-f]{32} [0-9a-f]{40}$' <<<"${answer}"
msg='Invalid format, grep "^[0-9a-f]{32} [0-9a-f]{40}$" failed' hide_exit_code=true assert_status 0 \
'answer' "${answer}" \
'hint' 'Have you copied all the characters?'
}
Supports Markdown
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