mirror of https://github.com/bpkg/bpkg
refactor(lib): cleanup, remove useless code, fix lint
parent
d8dae99045
commit
f4665a5b74
@ -1,6 +1,17 @@
|
||||
## Allow unsued variables
|
||||
## Allow: To read lines rather than words, pipe/redirect to a 'while read' loop
|
||||
disable=SC2013
|
||||
|
||||
## Allow: Unsued variables
|
||||
disable=SC2034
|
||||
## Allow declare and assign separately to avoid masking return values
|
||||
disable=SC2155
|
||||
## Double quote array expansions to avoid re-splitting elements.
|
||||
|
||||
## Allow: Double quote array expansions to avoid re-splitting elements
|
||||
disable=SC2068
|
||||
|
||||
## Allow: Declare and assign separately to avoid masking return values
|
||||
disable=SC2155
|
||||
|
||||
## Allow: Prefer mapfile or read -a to split command output (or quote to avoid splitting)
|
||||
disable=SC2207
|
||||
|
||||
## Allow: Instead of 'let expr', prefer (( expr ))
|
||||
disable=SC2219
|
||||
|
@ -1,29 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
cd "${0%/*}" || exit
|
||||
|
||||
# make test output TAP compatible
|
||||
# http://en.wikipedia.org/wiki/Test_Anything_Protocol
|
||||
|
||||
fails=0
|
||||
tests=$(ls invalid/* -1 | wc -l)
|
||||
|
||||
echo "1..${tests##* }"
|
||||
for input in invalid/*
|
||||
do
|
||||
i=$((i+1))
|
||||
if ../JSON.sh < "$input" > /tmp/JSON.sh_outlog 2> /tmp/JSON.sh_errlog
|
||||
then
|
||||
echo "not ok $i - cat $input | ../JSON.sh should fail"
|
||||
#this should be indented with '#' at the start.
|
||||
echo "OUTPUT WAS >>>"
|
||||
cat /tmp/JSON.sh_outlog
|
||||
echo "<<<"
|
||||
fails=$((fails+1))
|
||||
else
|
||||
echo "ok $i - $input was rejected"
|
||||
echo "#" $(cat /tmp/JSON.sh_errlog)
|
||||
fi
|
||||
done
|
||||
echo "$fails test(s) failed"
|
||||
exit $fails
|
@ -1 +0,0 @@
|
||||
"hello\u20world"
|
@ -1 +0,0 @@
|
||||
bareword
|
@ -1 +0,0 @@
|
||||
{[: "bad"}
|
@ -1 +0,0 @@
|
||||
:
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"hello": :
|
||||
}
|
@ -1 +0,0 @@
|
||||
[,]
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"hello", "comma!"
|
||||
}
|
@ -1 +0,0 @@
|
||||
.
|
@ -1 +0,0 @@
|
||||
{false: "bad"}
|
@ -1 +0,0 @@
|
||||
{null: "bad"}
|
@ -1 +0,0 @@
|
||||
{5: "bad"}
|
@ -1 +0,0 @@
|
||||
[1,2,3,]
|
@ -1 +0,0 @@
|
||||
[1,2,3]'
|
@ -1 +0,0 @@
|
||||
{"a":1,"b":2,"c":3,}
|
@ -1 +0,0 @@
|
||||
{true: "bad"}
|
@ -1 +0,0 @@
|
||||
[5,4,"goeu"
|
@ -1,2 +0,0 @@
|
||||
{
|
||||
"hELLO": "goodeoeu"
|
@ -1 +0,0 @@
|
||||
"Hello world
|
@ -1 +0,0 @@
|
||||
@
|
@ -1 +0,0 @@
|
||||
{@: "bad"}
|
@ -1,35 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
cd "${0%/*}" || exit
|
||||
|
||||
. ../JSON.sh
|
||||
|
||||
ptest () {
|
||||
tokenize | parse >/dev/null
|
||||
}
|
||||
|
||||
fails=0
|
||||
i=0
|
||||
echo "1..4"
|
||||
for input in '"oooo" ' '[true, 1, [0, {}]] ' '{"true": 1}'
|
||||
do
|
||||
i=$((i+1))
|
||||
if echo "$input" | ptest
|
||||
then
|
||||
echo "ok $i - $input"
|
||||
else
|
||||
echo "not ok $i - $input"
|
||||
fails=$((fails+1))
|
||||
fi
|
||||
done
|
||||
|
||||
if ! ptest < ../bpkg.json
|
||||
then
|
||||
echo "not ok 4 - Parsing bpkg.json failed!"
|
||||
fails=$((fails+1))
|
||||
else
|
||||
echo "ok $i - bpkg.json"
|
||||
fi
|
||||
|
||||
echo "$fails test(s) failed"
|
||||
exit $fails
|
@ -1,54 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
cd "${0%/*}" || exit
|
||||
. ../JSON.sh
|
||||
|
||||
i=0
|
||||
fails=0
|
||||
ttest () {
|
||||
i=$((i+1))
|
||||
local input="$1"; shift
|
||||
local expected="$(printf '%s\n' "$@")"
|
||||
echo "$expected" > /tmp/json_ttest_expected
|
||||
if echo "$input" | tokenize | diff -u - /tmp/json_ttest_expected
|
||||
then
|
||||
echo "ok $i - $input"
|
||||
else
|
||||
echo "not ok $i - $input"
|
||||
fails=$((fails+1))
|
||||
fi
|
||||
}
|
||||
|
||||
ttest '"dah"' '"dah"'
|
||||
ttest '""' '""'
|
||||
ttest '["dah"]' '[' '"dah"' ']'
|
||||
ttest '" "' '" "'
|
||||
ttest '" \" "' '" \" "'
|
||||
|
||||
ttest '["dah"]' '[' '"dah"' ']'
|
||||
|
||||
ttest '123' '123'
|
||||
ttest '123.142' '123.142'
|
||||
ttest '-123' '-123'
|
||||
|
||||
ttest '1e23' '1e23'
|
||||
ttest '0.1' '0.1'
|
||||
ttest '-110' '-110'
|
||||
ttest '-110.10' '-110.10'
|
||||
ttest '-110e10' '-110e10'
|
||||
ttest 'null' 'null'
|
||||
ttest 'true' 'true'
|
||||
ttest 'false' 'false'
|
||||
ttest '[ null , -110e10, "null" ]' \
|
||||
'[' 'null' ',' '-110e10' ',' '"null"' ']'
|
||||
ttest '{"e": false}' '{' '"e"' ':' 'false' '}'
|
||||
ttest '{"e": "string"}' '{' '"e"' ':' '"string"' '}'
|
||||
|
||||
if ! cat ../bpkg.json | tokenize >/dev/null
|
||||
then
|
||||
fails=$((fails+1))
|
||||
echo "Tokenizing bpkg.json failed!"
|
||||
fi
|
||||
|
||||
echo "$fails test(s) failed"
|
||||
exit $fails
|
@ -1,21 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
cd "${0%/*}" || exit
|
||||
fails=0
|
||||
i=0
|
||||
tests=$(ls valid/*.json -1l | wc -l)
|
||||
echo "1..$tests"
|
||||
for input in valid/*.json
|
||||
do
|
||||
expected="${input%.json}.parsed"
|
||||
i=$((i+1))
|
||||
if ! ../JSON.sh < "$input" | diff -u - "$expected"
|
||||
then
|
||||
echo "not ok $i - $input"
|
||||
fails=$((fails+1))
|
||||
else
|
||||
echo "ok $i - $input"
|
||||
fi
|
||||
done
|
||||
echo "$fails test(s) failed"
|
||||
exit $fails
|
@ -1 +0,0 @@
|
||||
[1,2,3,"hello"]
|
@ -1,5 +0,0 @@
|
||||
[0] 1
|
||||
[1] 2
|
||||
[2] 3
|
||||
[3] "hello"
|
||||
[] [1,2,3,"hello"]
|
@ -1 +0,0 @@
|
||||
{"foo": "{\"foo\":\"bar\"}"}
|
@ -1,2 +0,0 @@
|
||||
["foo"] "{\"foo\":\"bar\"}"
|
||||
[] {"foo":"{\"foo\":\"bar\"}"}
|
@ -1 +0,0 @@
|
||||
[]
|
@ -1 +0,0 @@
|
||||
[] []
|
@ -1 +0,0 @@
|
||||
{}
|
@ -1 +0,0 @@
|
||||
[] {}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"key1": "string",
|
||||
"key2": 3573
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
["key1"] "string"
|
||||
["key2"] 3573
|
||||
[] {"key1":"string","key2":3573}
|
@ -1,5 +0,0 @@
|
||||
[ 1
|
||||
, []
|
||||
, [4, "hello", {}]
|
||||
, {"array": []}
|
||||
]
|
@ -1,9 +0,0 @@
|
||||
[0] 1
|
||||
[1] []
|
||||
[2,0] 4
|
||||
[2,1] "hello"
|
||||
[2,2] {}
|
||||
[2] [4,"hello",{}]
|
||||
[3,"array"] []
|
||||
[3] {"array":[]}
|
||||
[] [1,[],[4,"hello",{}],{"array":[]}]
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"object": {
|
||||
"key": "value",
|
||||
"empty": {}
|
||||
},
|
||||
"number": 5
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
["object","key"] "value"
|
||||
["object","empty"] {}
|
||||
["object"] {"key":"value","empty":{}}
|
||||
["number"] 5
|
||||
[] {"object":{"key":"value","empty":{}},"number":5}
|
@ -1 +0,0 @@
|
||||
3
|
@ -1 +0,0 @@
|
||||
[] 3
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"key": "Value"
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
["key"] "Value"
|
||||
[] {"key":"Value"}
|
@ -1 +0,0 @@
|
||||
"hello this is a string"
|
@ -1 +0,0 @@
|
||||
[] "hello this is a string"
|
@ -1 +0,0 @@
|
||||
["hello this is a string"]
|
@ -1,2 +0,0 @@
|
||||
[0] "hello this is a string"
|
||||
[] ["hello this is a string"]
|
@ -1 +0,0 @@
|
||||
{"key":"hello this is a string"}
|
@ -1,2 +0,0 @@
|
||||
["key"] "hello this is a string"
|
||||
[] {"key":"hello this is a string"}
|
@ -1 +0,0 @@
|
||||
"hello\tworld"
|
@ -1 +0,0 @@
|
||||
[] "hello\tworld"
|
@ -1,98 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
## include
|
||||
. term.sh
|
||||
|
||||
## data
|
||||
declare -a data=( 0 2 3 1 3 3 3 8 2 12 4 2 4 3 )
|
||||
|
||||
## clean up everything
|
||||
cleanup () {
|
||||
## clear
|
||||
term clear screen
|
||||
## bring back cursor
|
||||
term cursor show
|
||||
return 0
|
||||
}
|
||||
|
||||
## on SIGINT signal
|
||||
onsigint () {
|
||||
cleanup
|
||||
exit 1
|
||||
}
|
||||
|
||||
## clear screen
|
||||
term clear screen
|
||||
|
||||
## position to top left
|
||||
term move 0 0
|
||||
|
||||
## clear line
|
||||
term clear line
|
||||
|
||||
## hide cursor
|
||||
term cursor hide
|
||||
|
||||
## catch sigint
|
||||
trap "onsigint" SIGINT
|
||||
|
||||
|
||||
## main loop
|
||||
{
|
||||
let pad=3
|
||||
let n=0
|
||||
let w=($(tput cols))
|
||||
let h=($(tput lines))
|
||||
let x=0
|
||||
let y=0
|
||||
let len="${#data[@]}"
|
||||
|
||||
term clear screen
|
||||
|
||||
term move ${pad} 1
|
||||
|
||||
## y axis
|
||||
for (( n = 0; n < (h - pad - 1); n += 2 )); do
|
||||
term transition 0 2
|
||||
term color gray
|
||||
printf "."
|
||||
done
|
||||
|
||||
y=( ${h} - 2 )
|
||||
term move ${pad} ${y}
|
||||
|
||||
## x axis
|
||||
for (( n = 0; n < (w - pad * 3); n += 6)); do
|
||||
term color gray
|
||||
printf "."
|
||||
term transition 6 0
|
||||
done
|
||||
|
||||
x=0
|
||||
for (( i = 0; i < len; ++i )); do
|
||||
let n="${data[$i]}"
|
||||
while (( n-- )); do
|
||||
if (( n < 0 )); then
|
||||
break
|
||||
fi
|
||||
let a=( ${x} * 6 + ${pad} )
|
||||
let b=( ${h} - ${n} + ${pad} )
|
||||
#echo $a $b
|
||||
term move ${a} ${b}
|
||||
term reset
|
||||
printf "█"
|
||||
done
|
||||
(( x++ ))
|
||||
sleep .5
|
||||
done
|
||||
|
||||
h=( ${h} - 1)
|
||||
term move ${w} ${h}
|
||||
}
|
||||
|
||||
## clean up terminal
|
||||
cleanup
|
||||
|
||||
## exit
|
||||
exit $?
|
||||
|
Loading…
Reference in New Issue