In one of my recent PRs I mistakenly had two test-cases with the same
name, preventing one of them to run. Since it's an easy mistake to make
(e.g., copy pasting existing test-cases), I ran following sanity-check
script over `lldb/test/API`, which found couple of tests which were
losing coverage because of this (or in some cases simply had duplicate
tests):
```
import ast
import sys
filename = sys.argv[1]
print(f'Checking {filename}...')
tree = ast.parse(open(filename, 'r').read())
for node in ast.walk(tree):
if not isinstance(node, ast.ClassDef):
continue
func_names = []
for child in ast.iter_child_nodes(node):
if isinstance(child, ast.FunctionDef):
func_names.append(child.name)
seen_func_names = set()
duplicate_func_names = []
for name in func_names:
if name in seen_func_names:
duplicate_func_names.append(name)
else:
seen_func_names.add(name)
if len(duplicate_func_names) != 0:
print(f'Multiple func names found:\n\t{duplicate_func_names}\n\tclass {node.name}\n\tfile: {filename}')
```
This patch fixes these cases.
35 lines
985 B
Python
35 lines
985 B
Python
import lldb
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test.decorators import *
|
|
|
|
|
|
class InvalidArgsLogTestCase(TestBase):
|
|
@no_debug_info_test
|
|
def test_enable_empty(self):
|
|
self.expect(
|
|
"log enable",
|
|
error=True,
|
|
substrs=[
|
|
"error: log enable takes a log channel and one or more log types."
|
|
],
|
|
)
|
|
|
|
@no_debug_info_test
|
|
def test_disable_empty(self):
|
|
self.expect(
|
|
"log disable",
|
|
error=True,
|
|
substrs=[
|
|
"error: log disable takes a log channel and one or more log types."
|
|
],
|
|
)
|
|
|
|
@no_debug_info_test
|
|
def test_enable_invalid_path(self):
|
|
invalid_path = os.path.join("this", "is", "not", "a", "valid", "path")
|
|
self.expect(
|
|
"log enable lldb all -f " + invalid_path,
|
|
error=True,
|
|
substrs=["Unable to open log file '" + invalid_path + "': ", "\n"],
|
|
)
|