Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: improve the test suite implementation #429

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
line-length = 100
target-version = "py38" # default value

[format]
indent-style = "space" # default value

[lint]
# Enable Pyflakes (`F`), isort (`I`) and a subset of the pycodestyle (`E`) codes.
select = ["E4", "E7", "E9", "F", "I"]

[lint.pycodestyle]
max-line-length = 100
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ find_package (Threads REQUIRED)
find_package (ZLIB REQUIRED)
find_package (CURL REQUIRED)

find_package (Python3 3.8 REQUIRED)

if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set (DL_LIBRARY "")
else (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
Expand Down
170 changes: 149 additions & 21 deletions tests/tools/accumulate.py
Original file line number Diff line number Diff line change
@@ -1,80 +1,208 @@
import testbase
import unittest

import parse_cobertura
import testbase


class accumulate_data(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv,o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov " + testbase.sources + "/tests/python/main")
rv, o = self.do(
testbase.kcov
+ " "
+ testbase.outbase
+ "/kcov "
+ testbase.sources
+ "/tests/python/main"
)

dom = parse_cobertura.parseFile(testbase.outbase + "/kcov/main/cobertura.xml")
assert parse_cobertura.hitsPerLine(dom, "main", 16) == 1
assert parse_cobertura.hitsPerLine(dom, "main", 19) == 0
assert parse_cobertura.hitsPerLine(dom, "main", 14) == 1

rv,o = self.do(testbase.kcov + " "+ testbase.outbase + "/kcov " + testbase.sources + "/tests/python/main 5")
rv, o = self.do(
testbase.kcov
+ " "
+ testbase.outbase
+ "/kcov "
+ testbase.sources
+ "/tests/python/main 5"
)
dom = parse_cobertura.parseFile(testbase.outbase + "/kcov/main/cobertura.xml")
assert parse_cobertura.hitsPerLine(dom, "main", 16) == 1
assert parse_cobertura.hitsPerLine(dom, "main", 19) == 1
assert parse_cobertura.hitsPerLine(dom, "main", 14) == 2


class dont_accumulate_data_with_clean(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv,o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov " + testbase.sources + "/tests/python/main")
rv, o = self.do(
testbase.kcov
+ " "
+ testbase.outbase
+ "/kcov "
+ testbase.sources
+ "/tests/python/main"
)

dom = parse_cobertura.parseFile(testbase.outbase + "/kcov/main/cobertura.xml")
assert parse_cobertura.hitsPerLine(dom, "main", 16) == 1
assert parse_cobertura.hitsPerLine(dom, "main", 19) == 0
assert parse_cobertura.hitsPerLine(dom, "main", 14) == 1

rv,o = self.do(testbase.kcov + " --clean "+ testbase.outbase + "/kcov " + testbase.sources + "/tests/python/main 5")
rv, o = self.do(
testbase.kcov
+ " --clean "
+ testbase.outbase
+ "/kcov "
+ testbase.sources
+ "/tests/python/main 5"
)
dom = parse_cobertura.parseFile(testbase.outbase + "/kcov/main/cobertura.xml")
assert parse_cobertura.hitsPerLine(dom, "main", 16) == 0
assert parse_cobertura.hitsPerLine(dom, "main", 19) == 1
assert parse_cobertura.hitsPerLine(dom, "main", 14) == 1


class merge_basic(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv,o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov " + testbase.sources + "/tests/python/main 5")
rv,o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov " + testbase.sources + "/tests/bash/shell-main")
rv, o = self.do(
testbase.kcov
+ " "
+ testbase.outbase
+ "/kcov "
+ testbase.sources
+ "/tests/python/main 5"
)
rv, o = self.do(
testbase.kcov
+ " "
+ testbase.outbase
+ "/kcov "
+ testbase.sources
+ "/tests/bash/shell-main"
)

dom = parse_cobertura.parseFile(testbase.outbase + "/kcov/kcov-merged/cobertura.xml")
assert parse_cobertura.hitsPerLine(dom, "main", 10) == 1
assert parse_cobertura.hitsPerLine(dom, "shell-main", 4) == 1


class merge_multiple_output_directories(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv,o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov/first " + testbase.sources + "/tests/python/main 5")
rv,o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov/second " + testbase.sources + "/tests/bash/shell-main")
rv,o = self.do(testbase.kcov + " --merge " + testbase.outbase + "/kcov/merged " + testbase.outbase + "/kcov/first " + testbase.outbase + "/kcov/second")
rv, o = self.do(
testbase.kcov
+ " "
+ testbase.outbase
+ "/kcov/first "
+ testbase.sources
+ "/tests/python/main 5"
)
rv, o = self.do(
testbase.kcov
+ " "
+ testbase.outbase
+ "/kcov/second "
+ testbase.sources
+ "/tests/bash/shell-main"
)
rv, o = self.do(
testbase.kcov
+ " --merge "
+ testbase.outbase
+ "/kcov/merged "
+ testbase.outbase
+ "/kcov/first "
+ testbase.outbase
+ "/kcov/second"
)
dom = parse_cobertura.parseFile(testbase.outbase + "/kcov/merged/kcov-merged/cobertura.xml")
assert parse_cobertura.hitsPerLine(dom, "main", 10) == 1
assert parse_cobertura.hitsPerLine(dom, "shell-main", 4) == 1


class merge_merged_output(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv,o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov/first " + testbase.sources + "/tests/python/main 5")
rv,o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov/second " + testbase.sources + "/tests/bash/shell-main")
rv,o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov/third " + testbase.sources + "/tests/bash/dollar-var-replacements.sh")
rv, o = self.do(
testbase.kcov
+ " "
+ testbase.outbase
+ "/kcov/first "
+ testbase.sources
+ "/tests/python/main 5"
)
rv, o = self.do(
testbase.kcov
+ " "
+ testbase.outbase
+ "/kcov/second "
+ testbase.sources
+ "/tests/bash/shell-main"
)
rv, o = self.do(
testbase.kcov
+ " "
+ testbase.outbase
+ "/kcov/third "
+ testbase.sources
+ "/tests/bash/dollar-var-replacements.sh"
)

rv,o = self.do(testbase.kcov + " --merge " + testbase.outbase + "/kcov/merged " + testbase.outbase + "/kcov/first " + testbase.outbase + "/kcov/second")
rv,o = self.do(testbase.kcov + " --merge " + testbase.outbase + "/kcov/merged2 " + testbase.outbase + "/kcov/merged " + testbase.outbase + "/kcov/third")
dom = parse_cobertura.parseFile(testbase.outbase + "/kcov/merged2/kcov-merged/cobertura.xml")
rv, o = self.do(
testbase.kcov
+ " --merge "
+ testbase.outbase
+ "/kcov/merged "
+ testbase.outbase
+ "/kcov/first "
+ testbase.outbase
+ "/kcov/second"
)
rv, o = self.do(
testbase.kcov
+ " --merge "
+ testbase.outbase
+ "/kcov/merged2 "
+ testbase.outbase
+ "/kcov/merged "
+ testbase.outbase
+ "/kcov/third"
)
dom = parse_cobertura.parseFile(
testbase.outbase + "/kcov/merged2/kcov-merged/cobertura.xml"
)
assert parse_cobertura.hitsPerLine(dom, "main", 10) == 1
assert parse_cobertura.hitsPerLine(dom, "shell-main", 4) == 1
assert parse_cobertura.hitsPerLine(dom, "dollar-var-replacements.sh", 2) == 1


class merge_coveralls(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv,o = self.do(testbase.kcov + " --coveralls-id=dry-run " + testbase.outbase + "/kcov/ " + testbase.sources + "/tests/python/main 5")
rv,o = self.do(testbase.kcov + " --coveralls-id=dry-run " + testbase.outbase + "/kcov/ " + testbase.sources + "/tests/bash/shell-main")
rv, o = self.do(
testbase.kcov
+ " --coveralls-id=dry-run "
+ testbase.outbase
+ "/kcov/ "
+ testbase.sources
+ "/tests/python/main 5"
)
rv, o = self.do(
testbase.kcov
+ " --coveralls-id=dry-run "
+ testbase.outbase
+ "/kcov/ "
+ testbase.sources
+ "/tests/bash/shell-main"
)

rv,o = self.doShell("grep second.py %s/kcov/main/coveralls.out" % (testbase.outbase))
rv, o = self.doShell("grep second.py %s/kcov/main/coveralls.out" % (testbase.outbase))
assert rv == 0
rv,o = self.doShell("grep shell-main %s/kcov/shell-main/coveralls.out" % (testbase.outbase))
rv, o = self.doShell(
"grep shell-main %s/kcov/shell-main/coveralls.out" % (testbase.outbase)
)
assert rv == 0
Loading
Loading