From c68f3b7cd85c22dbcbc9ca465f515fe73082b700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Rossillol=E2=80=91=E2=80=91Laruelle?= Date: Wed, 31 Jul 2024 21:43:15 +0200 Subject: [PATCH] add tests according to the previous changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See-also: a750d4793d811dcfe1f849942bb00d66aff043a0 See-also: a03bf8decb726037f26735bbf84d710ecc6e2205 Signed-off-by: Mattéo Rossillol‑‑Laruelle --- tests/bash/shell-main | 22 ++++++++++++++++++++ tests/bash/subshell.sh | 8 +++++++ tests/tools/test_bash.py | 45 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/tests/bash/shell-main b/tests/bash/shell-main index 1d5d0b1e..13f20cf2 100755 --- a/tests/bash/shell-main +++ b/tests/bash/shell-main @@ -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 diff --git a/tests/bash/subshell.sh b/tests/bash/subshell.sh index 05bf1b55..40d815f8 100755 --- a/tests/bash/subshell.sh +++ b/tests/bash/subshell.sh @@ -6,3 +6,11 @@ echo "Inbetween stuff" (echo "Other subshell" echo More stuff in Other subshell ) + +# Issue 457 + +fn4() ( + echo "fn4" +) + +fn4 diff --git a/tests/tools/test_bash.py b/tests/tools/test_bash.py index c2df0533..da51465a 100644 --- a/tests/tools/test_bash.py +++ b/tests/tools/test_bash.py @@ -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