Commit 0672d6ac authored by User expired's avatar User expired
Browse files

Do not suppress errors in tests unless needed

parent 4243b4db
......@@ -90,8 +90,8 @@ setUp() {
testPrintNonAsciiCharacters() {
# Two lines contain non ascii characters.
assertEquals '2' "$(bib-format -p $fileOne 2>&1 | wc -l)"
assertEquals '2' "$(bib-format -p $fileTwo 2>&1 | wc -l)"
assertEquals '2' "$(bib-format -p $fileOne | wc -l)"
assertEquals '2' "$(bib-format -p $fileTwo | wc -l)"
assertTrue 'file1 contains á' "bib-format -p $fileOne | grep -q 'á'"
assertTrue 'file1 contains ó' "bib-format -p $fileOne | grep -q 'ó'"
assertTrue 'file1 contains –' "bib-format -p $fileOne | grep -q '–'"
......@@ -99,7 +99,7 @@ testPrintNonAsciiCharacters() {
assertTrue 'file2 contains ó' "bib-format -p $fileTwo | grep -q 'ó'"
assertTrue 'file2 contains –' "bib-format -p $fileTwo | grep -q '–'"
# No non ascii characters in third file.
assertEquals '0' "$(bib-format -p $fileThree 2>&1 | wc -l)"
assertEquals '0' "$(bib-format -p $fileThree | wc -l)"
}
testPrintChangesStructure() {
......
......@@ -53,24 +53,24 @@ testListOfUnknownJournals() {
testJournalAbbreviation() {
# First only print changes.
assertEquals '5 lines change preview' '5' "$(bib-jabbr -n $fileOne 2>&1 | wc -l)"
assertEquals '5 lines change preview' '5' "$(bib-jabbr -n $fileOne | wc -l)"
assertTrue 'no file change with -n' "writeFileOne | diff - $fileOne"
# Now do the abbreviation.
bib-jabbr $fileOne
assertFalse 'file was changed' "writeFileOne | diff - $fileOne"
assertEquals '2 short name found' '2' "$(grep "$abbrName" $fileOne 2>&1 | wc -l)"
assertEquals '2 short name found' '2' "$(grep "$abbrName" $fileOne | wc -l)"
# No further changes in subsequent call.
assertEquals 'empty change preview' '' "$(bib-jabbr -n $fileOne)"
}
testJournalUnabbreviation() {
# First only print changes.
assertEquals '5 lines change preview' '5' "$(bib-jabbr -n -f $fileOne 2>&1 | wc -l)"
assertEquals '5 lines change preview' '5' "$(bib-jabbr -n -f $fileOne | wc -l)"
assertTrue 'no file change with -n' "writeFileOne | diff - $fileOne"
# Now replace abbreviation by full name.
bib-jabbr -f $fileOne
assertFalse 'file was changed' "writeFileOne | diff - $fileOne"
assertEquals '2 long names found' '2' "$(grep "$fullName" $fileOne 2>&1 | wc -l)"
assertEquals '2 long names found' '2' "$(grep "$fullName" $fileOne | wc -l)"
# No further changes in subsequent call.
assertEquals 'empty change preview' '' "$(bib-jabbr -n -f $fileOne)"
}
......
......@@ -136,11 +136,11 @@ testExampleBibtexFile() {
}
testQuietAndPrintChanges() {
assertEquals '3 lines preview' '3' "$(bib-keyinsert -n $fileOne 2>&1 | wc -l)"
assertEquals '3 lines preview' '3' "$(bib-keyinsert -n $fileOne | wc -l)"
assertEquals 'Unchanged file' '@Article{doi:10.1063/1.3276633,' "$(head -n1 $fileOne)"
assertEquals 'Quiet with -q' '0' "$(bib-keyinsert -q $fileOne 2>&1 | wc -l)"
assertEquals 'Quiet with -q' '0' "$(bib-keyinsert -q $fileOne | wc -l)"
assertEquals 'Updated key' '@Article{Czako2009:jcp,' "$(head -n1 $fileOne)"
assertEquals '0 lines preview' '0' "$(bib-keyinsert -n $fileOne 2>&1 | wc -l)"
assertEquals '0 lines preview' '0' "$(bib-keyinsert -n $fileOne | wc -l)"
}
testIgnoreCase() {
......@@ -161,16 +161,16 @@ testYearWithLetter() {
assertEquals '@Article{Czako2009c,' "$(head -n1 $fileOne)"
file=$(bib-name $fileOne | grep -o "[^']*.pdf.bib") # Filename from citation key.
assertEquals 'Letter in filename' '/tmp/Czako_2009c_.pdf.bib' "$file"
assertEquals 'Test letter override' '3' "$(bib-keyinsert -n $file:b 2>&1 | wc -l)"
assertEquals 'Keep filename letter' '0' "$(bib-keyinsert -n $file 2>&1 | wc -l)"
assertEquals 'Test letter override' '3' "$(bib-keyinsert -n $file:b | wc -l)"
assertEquals 'Keep filename letter' '0' "$(bib-keyinsert -n $file | wc -l)"
mv $file ${file/c_/_} && file=${file/c_/_} # Remove letter from filename.
assertEquals 'Otherwise drop letter' '3' "$(bib-keyinsert -n $file 2>&1 | wc -l)"
assertEquals 'Otherwise drop letter' '3' "$(bib-keyinsert -n $file | wc -l)"
mv $file $fileOne
}
testPrintKeys() {
# Option -p prints 4 unsorted keys.
assertEquals '4' "$(bib-keyinsert -p $fileTwo 2>&1 | wc -l)"
assertEquals '4' "$(bib-keyinsert -p $fileTwo | wc -l)"
assertEquals "$KEYS" "$(bib-keyinsert -p $fileTwo | cut -d' ' -f2 | sort -u)"
# Option -d print duplicate key occuring two times.
assertEquals '2' "$(bib-keyinsert -d $fileTwo | cut -f1)"
......
......@@ -136,7 +136,7 @@ testExampleBibtexFile() {
assertTrue 'File with new name exists' 'test -e $file'
# Do not try to rename again.
assertTrue 'Filename up to date' 'bib-name -n "$file" | grep "up to date"'
assertEquals 'No rename attempted' '' "$(bib-name "$file" 2>&1)"
assertEquals 'No rename attempted' '' "$(bib-name "$file")"
# Undo the renaming.
mv $file $fileOne
......
......@@ -47,7 +47,7 @@ tearDown() {
testInsertReferenceToPDF() {
# Source bib-pdfinsert to use 'file' alias.
assertEquals 'preview change' '2' "$(. bin/bib-pdfinsert -n $fileOne 2>&1 | wc -l)"
assertEquals 'preview change' '2' "$(. bin/bib-pdfinsert -n $fileOne | wc -l)"
assertTrue 'no change done' 'writeFileOne | diff - $fileOne'
assertTrue 'insert pdf link' '. bin/bib-pdfinsert $fileOne | grep -q "{:.*:PDF}"'
assertEquals 'no further change' '' "$(. bin/bib-pdfinsert $fileOne)"
......@@ -59,7 +59,7 @@ testInsertReferenceToPDF() {
testRemoveReferenceFromPDF() {
. bin/bib-pdfinsert $fileOne >/dev/null
assertTrue 'pdf link inserted' 'grep -q "{:.*:PDF}" $fileOne'
assertEquals 'preview change' '2' "$(. bin/bib-pdfinsert -n -r $fileOne 2>&1 | wc -l)"
assertEquals 'preview change' '2' "$(. bin/bib-pdfinsert -n -r $fileOne | wc -l)"
. bin/bib-pdfinsert -r $fileOne
assertEquals 'no further change' '' "$(. bin/bib-pdfinsert -n -r $fileOne)"
assertFalse 'pdf link removed' 'grep -q "{:.*:PDF}" $fileOne'
......
Markdown is supported
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