Skip to content

Commit

Permalink
tidied up logging commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTimperley committed Jul 22, 2018
1 parent f0c0e85 commit e3c3f91
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/orchestrator/blacklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def is_file_mutable(fn: str) -> bool:
'src/perception_pcl',
'src/orocos_kinematics_dynamics/orocos_kdl/src/path_roundedcomposite.cpp',
'src/orocos_kinematics_dynamics/orocos_kdl/src/velocityprofile.cpp',
'src/rospack/src/utils.cpp',

'src/image_pipeline/depth_image_proc/src/nodelets/convert_metric.cpp',
'src/image_pipeline/depth_image_proc/src/nodelets/crop_foremost.cpp',
Expand Down
18 changes: 9 additions & 9 deletions src/orchestrator/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,28 @@ def compute_mutant_coverage(client_bugzoo: BugZooClient,
) -> TestSuiteCoverage:
# NOTE coverage appears to become flaky beyond 8 simultaneous threads
# threads = max(threads, 8)
logger.info("computing coverage for mutant: %s", mutant)
logger.info("num. coverage threads: %d", threads)
logger.info("computing coverage for mutant: %s", mutant.uuid)
logger.debug("num. coverage threads: %d", threads)
coverage_baseline = load_baseline_coverage()
snapshot_mutant = client_bugzoo.bugs[mutant.snapshot]

# restrict to tests that cover the perturbed file
filename = list(mutant.mutations)[0].location.filename
tests = [t for t in snapshot_mutant.tests \
if filename in coverage_baseline[t.name].lines.files]
logger.info("restricting coverage for mutant to following tests: %s",
', '.join([t.name for t in tests]))
logger.debug("restricting coverage for mutant to following tests: %s",
', '.join([t.name for t in tests]))

mutant_instrumented = None
try:
logger.info("creating temporary instrumented mutant")
logger.debug("creating temporary instrumented mutant")
mutant_instrumented = \
client_boggart.mutate(fetch_instrumentation_snapshot(client_bugzoo),
mutant.mutations)
snapshot_instrumented = \
client_bugzoo.bugs[mutant_instrumented.snapshot]
logger.info("created temporary instrumented mutant: %s",
mutant_instrumented)
logger.debug("created temporary instrumented mutant: %s",
mutant_instrumented)
coverage = compute_coverage(client_bugzoo,
snapshot_instrumented,
tests,
Expand Down Expand Up @@ -145,7 +145,7 @@ def load_baseline_coverage() -> TestSuiteCoverage:
if __BASELINE_COVERAGE:
return __BASELINE_COVERAGE

logger.info("attempting to load precomputed coverage for baseline A.")
logger.debug("attempting to load precomputed coverage for baseline A.")
try:
with open(BASELINE_COVERAGE_FN, 'r') as f:
jsn = json.load(f)
Expand All @@ -156,7 +156,7 @@ def load_baseline_coverage() -> TestSuiteCoverage:
# restrict to mutable files
files = [fn for fn in coverage.lines.files if is_file_mutable(fn)]
__BASELINE_COVERAGE = coverage.restricted_to_files(files)
logger.info("loaded precomputed coverage for baseline A.")
logger.debug("loaded precomputed coverage for baseline A.")
return __BASELINE_COVERAGE


Expand Down
6 changes: 4 additions & 2 deletions src/orchestrator/liveness.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ def mutant_fails_test(client_bugzoo: BugZooClient,
mutant.mutations)
locations = [r.location for r in replacements]
lines = [FileLine(l.filename, l.stop.line) for l in locations]
logger.info("lines changed by mutant: %s", lines)
logger.info("lines changed by mutant: %s",
sorted(set(l.num for l in lines)))

# restrict to the test outcomes that may be changed by the mutant
coverage = load_baseline_coverage()
# logger.info("coverage tests: %s", [t for t in coverage])
tests = list(snapshot.tests)
tests = [t for t in tests \
if any(line in coverage[t.name] for line in lines)]
logger.info("tests covered by mutant: %s", [t.name for t in tests])
logger.info("tests covered by mutant: %s",
sorted(set(t.name for t in tests)))

container = None
try:
Expand Down
5 changes: 3 additions & 2 deletions src/orchestrator/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ def suspiciousness(ep: int, np: int, ef: int, nf: int) -> float:

except darjeeling.exceptions.NoImplicatedLines:
raise FailedToComputeCoverage
logger.info("computed fault localization (%d files, %d lines):\n%s",
len(localization.files), len(localization), localization)
logger.info("computed fault localization (%d files, %d lines)",
len(localization.files), len(localization))
logger.debug("fault localization: %s", localization)
lines = FileLineSet.from_list([l for l in localization])
logger.info("suspicious lines:\n%s", indent(repr(lines), 2))
return localization
12 changes: 6 additions & 6 deletions src/orchestrator/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ def __init__(self,
self.__baseline_with_instrumentation = \
fetch_instrumentation_snapshot(self.__client_bugzoo)

logger.info("fetching coverage information for Baseline A.")
logger.debug("fetching coverage information for Baseline A.")
self.__coverage_for_baseline = \
load_baseline_coverage() # type: TestSuiteCoverage
logger.debug("mutable files: %s",
self.__coverage_for_baseline.lines.files)
logger.info("fetched coverage information for Baseline A.")
logger.info("line coverage for Baseline A: %d lines", len(self.lines))
logger.debug("fetched coverage information for Baseline A.")
logger.debug("line coverage for Baseline A: %d lines", len(self.lines))

def shutdown(self) -> None:
"""
Expand Down Expand Up @@ -342,7 +342,7 @@ def perturbations(self,
else:
restrict_to_lines = [line_num]
logger.info("Looking for perturbations at lines: %s",
restrict_to_lines)
sorted(set(restrict_to_lines)))

generator_mutations = \
boggartd.mutations(baseline,
Expand Down Expand Up @@ -433,10 +433,10 @@ def perturb(self, perturbation: Mutation) -> None:
try:
try:
# TODO capture unexpected errors during snapshot creation
logger.info("Applying perturbation to baseline snapshot.")
logger.debug("Applying perturbation to baseline snapshot.")
mutant = boggartd.mutate(baseline, [perturbation])
snapshot = bz.bugs[mutant.snapshot]
logger.info("Generated mutant snapshot: %s", snapshot)
logger.info("Generated mutant snapshot: %s", snapshot.name)
if not mutant_fails_test(bz, boggartd, mutant):
raise NeutralPerturbation
self.__problem = self._build_problem(mutant)
Expand Down

0 comments on commit e3c3f91

Please sign in to comment.