Skip to content

Commit

Permalink
add tests according to the previous changes
Browse files Browse the repository at this point in the history
See-also: a750d47
See-also: a03bf8d
Signed-off-by: Mattéo Rossillol‑‑Laruelle <beatussum@protonmail.com>
  • Loading branch information
beatussum committed Jul 31, 2024
1 parent eb1b79b commit c68f3b7
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/bash/shell-main
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,25 @@ booknames=`sqlplus -S -R 3 "$LOGON_STR" <<-EOF
exit;
EOF`
echo $booknames
# Issue 457
cat << EOF
foo
bar
EOF
cat << "EOF"
foo
bar
EOF
cat <<- EOF
foo
bar
EOF
cat <<- "EOF"
foo
bar
EOF
8 changes: 8 additions & 0 deletions tests/bash/subshell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ echo "Inbetween stuff"
(echo "Other subshell"
echo More stuff in Other subshell
)

# Issue 457

fn4() (
echo "fn4"
)

fn4
45 changes: 45 additions & 0 deletions tests/tools/test_bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,48 @@ def runTest(self):
)
self.assertIsNone(cobertura.hitsPerLine(dom, "long-output-without-return.sh", 1))
self.assertEqual(32768, cobertura.hitsPerLine(dom, "long-output-without-return.sh", 4))


# Issue 457
class bash_heredoc_with_space(libkcov.TestCase):
def runTest(self):
rv, o = self.do(
self.kcov + " " + self.outbase + "/kcov " + self.sources + "/tests/bash/shell-main"
)

dom = cobertura.parseFile(self.outbase + "/kcov/shell-main/cobertura.xml")

assert cobertura.hitsPerLine(dom, "shell-main", 184) == 1
assert cobertura.hitsPerLine(dom, "shell-main", 185) is None
assert cobertura.hitsPerLine(dom, "shell-main", 186) is None
assert cobertura.hitsPerLine(dom, "shell-main", 187) is None

assert cobertura.hitsPerLine(dom, "shell-main", 189) == 1
assert cobertura.hitsPerLine(dom, "shell-main", 190) is None
assert cobertura.hitsPerLine(dom, "shell-main", 191) is None
assert cobertura.hitsPerLine(dom, "shell-main", 192) is None

assert cobertura.hitsPerLine(dom, "shell-main", 194) == 1
assert cobertura.hitsPerLine(dom, "shell-main", 195) is None
assert cobertura.hitsPerLine(dom, "shell-main", 196) is None
assert cobertura.hitsPerLine(dom, "shell-main", 197) is None

assert cobertura.hitsPerLine(dom, "shell-main", 199) == 1
assert cobertura.hitsPerLine(dom, "shell-main", 200) is None
assert cobertura.hitsPerLine(dom, "shell-main", 201) is None
assert cobertura.hitsPerLine(dom, "shell-main", 202) is None


class bash_subshell_function(libkcov.TestCase):
def runTest(self):
rv, o = self.do(
self.kcov + " " + self.outbase + "/kcov " + self.sources + "/tests/bash/subshell.sh"
)

dom = cobertura.parseFile(self.outbase + "/kcov/subshell.sh/cobertura.xml")

assert cobertura.hitsPerLine(dom, "subshell.sh", 12) is None
assert cobertura.hitsPerLine(dom, "subshell.sh", 13) == 1
assert cobertura.hitsPerLine(dom, "subshell.sh", 14) is None

assert cobertura.hitsPerLine(dom, "subshell.sh", 16) == 1

0 comments on commit c68f3b7

Please sign in to comment.