Skip to content
Merged
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
15 changes: 6 additions & 9 deletions Lib/test/test_samply_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ def supports_trampoline_profiling():
raise unittest.SkipTest("perf trampoline profiling not supported")


def samply_command_works():
try:
cmd = ["samply", "--help"]
except (subprocess.SubprocessError, OSError):
return False

def _samply_command_works():
# Check that we can run a simple samply run
with temp_dir() as script_dir:
try:
Expand Down Expand Up @@ -90,8 +85,10 @@ def run_samply(cwd, *args, **env_vars):
with gzip.open(output_file, mode="rt", encoding="utf-8") as f:
return f.read()

SAMPLY_COMMAND_WORKS = _samply_command_works()


@unittest.skipUnless(samply_command_works(), "samply command doesn't work")
@unittest.skipUnless(SAMPLY_COMMAND_WORKS, "samply command doesn't work")
class TestSamplyProfilerMixin:
def run_samply(self, script_dir, perf_mode, script):
raise NotImplementedError()
Expand Down Expand Up @@ -145,7 +142,7 @@ def baz(n):
self.assertNotIn(f"py::baz:{script}", output)


@unittest.skipUnless(samply_command_works(), "samply command doesn't work")
@unittest.skipUnless(SAMPLY_COMMAND_WORKS, "samply command doesn't work")
class TestSamplyProfiler(unittest.TestCase, TestSamplyProfilerMixin):
def run_samply(self, script_dir, script, activate_trampoline=True):
if activate_trampoline:
Expand Down Expand Up @@ -240,7 +237,7 @@ def compile_trampolines_for_all_functions():
self.assertIn(line, child_perf_file_contents)


@unittest.skipUnless(samply_command_works(), "samply command doesn't work")
@unittest.skipUnless(SAMPLY_COMMAND_WORKS, "samply command doesn't work")
class TestSamplyProfilerWithJitDump(unittest.TestCase, TestSamplyProfilerMixin):
# Regression test for gh-150723: exercises the binary jitdump backend
# (-Xperf_jit) end to end through samply, unlike TestSamplyProfiler which
Expand Down
Loading