Skip to content

Commit

Permalink
Merge pull request #431 from perillo/improve-tests-code-more
Browse files Browse the repository at this point in the history
Improve tests code more
  • Loading branch information
SimonKagstrom authored Mar 27, 2024
2 parents 5ae73ae + 505cb60 commit c3b0b2a
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 151 deletions.
13 changes: 2 additions & 11 deletions tests/tools/accumulate.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

import parse_cobertura
import testbase


class accumulate_data(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand Down Expand Up @@ -36,7 +34,6 @@ def runTest(self):

class dont_accumulate_data_with_clean(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand Down Expand Up @@ -67,7 +64,6 @@ def runTest(self):

class merge_basic(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand All @@ -92,7 +88,6 @@ def runTest(self):

class merge_multiple_output_directories(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand Down Expand Up @@ -126,7 +121,6 @@ def runTest(self):

class merge_merged_output(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand Down Expand Up @@ -182,7 +176,6 @@ def runTest(self):

class merge_coveralls(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " --coveralls-id=dry-run "
Expand All @@ -200,9 +193,7 @@ def runTest(self):
+ "/tests/bash/shell-main"
)

rv, o = self.doShell("grep second.py %s/kcov/main/coveralls.out" % (testbase.outbase))
rv, o = self.doShell(f"grep second.py {(testbase.outbase)}/kcov/main/coveralls.out")
assert rv == 0
rv, o = self.doShell(
"grep shell-main %s/kcov/shell-main/coveralls.out" % (testbase.outbase)
)
rv, o = self.doShell(f"grep shell-main {(testbase.outbase)}/kcov/shell-main/coveralls.out")
assert rv == 0
21 changes: 0 additions & 21 deletions tests/tools/bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class BashBase(testbase.KcovTestCase):
def doTest(self, args):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand All @@ -25,7 +24,6 @@ def doTest(self, args):

class bash_coverage(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand Down Expand Up @@ -57,7 +55,6 @@ def runTest(self):
# Very limited, will expand once it's working better
class bash_coverage_debug_trap(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " --bash-method=DEBUG "
Expand All @@ -75,7 +72,6 @@ def runTest(self):

class bash_short_file(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand Down Expand Up @@ -129,7 +125,6 @@ def runTest(self):

class bash_honor_signal(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.sources
+ "/tests/setpgid-kill/test-script.sh "
Expand All @@ -148,7 +143,6 @@ def runTest(self):

class bash_accumulate_data(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand Down Expand Up @@ -179,7 +173,6 @@ class bash_accumulate_changed_data(testbase.KcovTestCase):
# Not sure why, but for now...
@unittest.skipUnless(platform.machine() in ["x86_64", "i686", "i386"], "Only for x86")
def runTest(self):
self.setUp()
os.system("mkdir -p /tmp/test-kcov")
os.system("cp " + testbase.sources + "/tests/bash/shell-main /tmp/test-kcov")
os.system("cp " + testbase.sources + "/tests/bash/other.sh /tmp/test-kcov")
Expand All @@ -204,7 +197,6 @@ def runTest(self):

class bash_merge_data_issue_38(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand Down Expand Up @@ -247,7 +239,6 @@ def runTest(self):

class bash_issue_116_arithmetic_and_heredoc_issue_117_comment_within_string(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand All @@ -266,7 +257,6 @@ def runTest(self):

class bash_multiline_quotes(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand All @@ -283,7 +273,6 @@ def runTest(self):

class bash_multiline_backslashes(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand All @@ -298,7 +287,6 @@ def runTest(self):

class bash_no_executed_lines(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand All @@ -317,7 +305,6 @@ def runTest(self):

class bash_stderr_redirection(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand All @@ -341,7 +328,6 @@ def runTest(self):

class bash_dollar_var_replacement(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand All @@ -362,7 +348,6 @@ def runTest(self):
# Issue #152
class bash_done_eof(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand All @@ -379,7 +364,6 @@ def runTest(self):
# Issue #154
class bash_eof_backtick(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand Down Expand Up @@ -429,7 +413,6 @@ def runTest(self):

class bash_exit_status(testbase.KcovTestCase):
def runTest(self):
self.setUp()
noKcovRv, o = self.do(testbase.sources + "/tests/bash/shell-main 5", False)
rv, o = self.do(
testbase.kcov
Expand All @@ -446,7 +429,6 @@ def runTest(self):
# Issue 180
class bash_ignore_uncovered(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " --exclude-region=CUSTOM_RANGE_START:CUSTOM_RANGE_END "
Expand Down Expand Up @@ -487,7 +469,6 @@ def runTest(self):
# Issue #224
class bash_can_find_non_executed_scripts(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " "
Expand All @@ -505,7 +486,6 @@ def runTest(self):

class bash_can_find_non_executed_scripts_manually(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " --bash-parse-files-in-dir="
Expand All @@ -525,7 +505,6 @@ def runTest(self):

class bash_can_ignore_non_executed_scripts(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " --bash-dont-parse-binary-dir "
Expand Down
2 changes: 0 additions & 2 deletions tests/tools/bash_linux_only.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

import parse_cobertura
import testbase


class bash_sh_shebang(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, o = self.do(
testbase.kcov
+ " --bash-handle-sh-invocation "
Expand Down
4 changes: 0 additions & 4 deletions tests/tools/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class TooFewArguments(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, output = self.do(testbase.kcov + " " + testbase.outbase + "/kcov")

assert b"Usage: kcov" in output
Expand All @@ -16,7 +15,6 @@ def runTest(self):

class WrongArguments(testbase.KcovTestCase):
def runTest(self):
self.setUp()
rv, output = self.do(
testbase.kcov
+ " --abc=efg "
Expand All @@ -33,7 +31,6 @@ def runTest(self):
class LookupBinaryInPath(testbase.KcovTestCase):
@unittest.expectedFailure
def runTest(self):
self.setUp()
os.environ["PATH"] += testbase.sources + "/tests/python"
noKcovRv, o = self.do(testbase.sources + "/tests/python/main 5")
rv, o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov " + "main 5")
Expand All @@ -46,7 +43,6 @@ def runTest(self):
# Issue #414
class OutDirectoryIsExecutable(testbase.KcovTestCase):
def runTest(self):
self.setUp()
# Running a system executable on Linux may cause ptrace to fails with
# "Operation not permitted", even with ptrace_scope set to 0.
# See https://www.kernel.org/doc/Documentation/security/Yama.txt
Expand Down
Loading

0 comments on commit c3b0b2a

Please sign in to comment.