add random lang hability
This commit is contained in:
@@ -118,13 +118,13 @@ export -f busy
|
|||||||
# Options:
|
# Options:
|
||||||
# --min-delay=<ms> : minimum delay between output lines (milliseconds, default: 40)
|
# --min-delay=<ms> : minimum delay between output lines (milliseconds, default: 40)
|
||||||
# --max-delay=<ms> : maximum delay between output lines (milliseconds, default: 150)
|
# --max-delay=<ms> : maximum delay between output lines (milliseconds, default: 150)
|
||||||
# --lang=<lang> : source language preset: c (default), cpp, java, python
|
# --lang=<lang> : source language preset: c (default), cpp, java, python, random
|
||||||
# --errors : inject fake compilation errors at the end of the build
|
# --errors : inject fake compilation errors at the end of the build
|
||||||
fake_compile()
|
fake_compile()
|
||||||
{
|
{
|
||||||
local min_ms="${FAKE_COMPILE_DEFAULT_MIN_DELAY:-40}" \
|
local min_ms="${FAKE_COMPILE_DEFAULT_MIN_DELAY:-40}" \
|
||||||
max_ms="${FAKE_COMPILE_DEFAULT_MAX_DELAY:-150}" \
|
max_ms="${FAKE_COMPILE_DEFAULT_MAX_DELAY:-150}" \
|
||||||
lang="c" with_errors=0
|
lang="${FAKE_COMPILE_DEFAULT_LANG:-c}" with_errors=0
|
||||||
|
|
||||||
local PARSED
|
local PARSED
|
||||||
# Short: h, n:, x:, l:, e
|
# Short: h, n:, x:, l:, e
|
||||||
@@ -146,7 +146,7 @@ fake_compile()
|
|||||||
printf "\t-h, --help\t\t\tDisplay this help screen\n"
|
printf "\t-h, --help\t\t\tDisplay this help screen\n"
|
||||||
printf "\t-n, --min-delay MS\t\tMin delay between lines in milliseconds (default: 40)\n"
|
printf "\t-n, --min-delay MS\t\tMin delay between lines in milliseconds (default: 40)\n"
|
||||||
printf "\t-x, --max-delay MS\t\tMax delay between lines in milliseconds (default: 150)\n"
|
printf "\t-x, --max-delay MS\t\tMax delay between lines in milliseconds (default: 150)\n"
|
||||||
printf "\t-l, --lang LANG\t\t\tLanguage preset: c, cpp, java, python (default: c)\n"
|
printf "\t-l, --lang LANG\t\t\tLanguage preset: c, cpp, java, python, random (default: c)\n"
|
||||||
printf "\t-e, --errors\t\t\tInject fake compilation errors at the end\n"
|
printf "\t-e, --errors\t\t\tInject fake compilation errors at the end\n"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
@@ -169,9 +169,9 @@ fake_compile()
|
|||||||
-l|--lang)
|
-l|--lang)
|
||||||
lang="$2"
|
lang="$2"
|
||||||
case "$lang" in
|
case "$lang" in
|
||||||
c|cpp|java|python) ;;
|
c|cpp|java|python|random) ;;
|
||||||
*)
|
*)
|
||||||
disp E "Invalid lang: must be one of: c, cpp, java, python."
|
disp E "Invalid lang: must be one of: c, cpp, java, python, random."
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -243,6 +243,16 @@ fake_compile()
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
if [[ "$lang" == "random" ]]; then
|
||||||
|
_langs=("c" "cpp" "java" "python")
|
||||||
|
_pick="${_langs[$((RANDOM % 4))]}"
|
||||||
|
case "$_pick" in
|
||||||
|
c) files=("${c_files[@]}"); ext=".c" ;;
|
||||||
|
cpp) files=("${cpp_files[@]}"); ext=".cpp" ;;
|
||||||
|
java) files=("${java_files[@]}"); ext=".java" ;;
|
||||||
|
python) files=("${python_files[@]}"); ext=".py" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
total=${#files[@]}
|
total=${#files[@]}
|
||||||
i=0
|
i=0
|
||||||
for f in "${files[@]}"; do
|
for f in "${files[@]}"; do
|
||||||
|
|||||||
Reference in New Issue
Block a user