Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a negative test and a must constraint for at least one endpoint…
… (fix for issue #1)
- Loading branch information
1 parent
265e3a0
commit 886b5ee
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,6 @@ pulls.json | |
report.xml | ||
lib | ||
*.withyang | ||
*.yangdeps | ||
tmp-negative.out | ||
modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
+ yanglint -f json -t data -D -s -V -p modules -p . ietf-taps-api.yang negative-ietf-taps-api-no-endpoints.json | ||
err : Must condition "count(//preconnection/local-endpoints) > 0 or | ||
count(//preconnection/remote-endpoints) > 0" not satisfied. (/ietf-taps-api:preconnection) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"ietf-taps-api:preconnection":{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
input_yang=$1 | ||
|
||
if [ ! -f "$input_yang" ] ; then | ||
echo "no file $input_yang" | ||
echo "usage: $0 <input>.yang :" | ||
echo " runs yanglint on all files named negative-<input>-*.json," | ||
echo " with <input>.yang, and confirms that they all fail." | ||
exit 1 | ||
fi | ||
|
||
yangfile=$(basename -- "$input_yang") | ||
# extension="${yangfile##*.}" | ||
input="${yangfile%.*}" | ||
|
||
problems=0 | ||
problems_in="" | ||
passed="" | ||
passed_count=0 | ||
|
||
for f in $(ls negative-${input}-*.json); do | ||
bash -x -e -c "yanglint -f json -t data -D -s -V -p modules -p . $input.yang $f" 2>&1 | grep -v "warn: Module's revisions are not unique (2018-06-28)" > tmp-negative.out | ||
|
||
if [ "${PIPESTATUS[0]}" = "0" ]; then | ||
problems=$((problems+1)) | ||
problems_in="$problems_in\\n $f" | ||
else | ||
filename=$(basename -- "$f") | ||
# extension="${filename##*.}" | ||
basename="${filename%.*}" | ||
if [ ! -e $basename.expect ]; then | ||
echo "no such file: $basename.expect" | ||
problems=$((problems+1)) | ||
problems_in="$problems_in\\n $f" | ||
else | ||
if ! bash -x -c "diff $basename.expect tmp-negative.out"; then | ||
problems=$((problems+1)) | ||
problems_in="$problems_in\\n $f" | ||
else | ||
passed="$passed\\n $f" | ||
passed_count=$((passed_count+1)) | ||
fi | ||
fi | ||
fi | ||
done | ||
|
||
if [ "$problems" != "0" ]; then | ||
printf "$problems negative tests had problems:" | ||
printf "$problems_in\\n" | ||
exit 1 | ||
else | ||
printf "all $passed_count negative tests passed:" | ||
printf "$passed\\n" | ||
fi |