@@ -31,12 +31,7 @@ def supports_trampoline_profiling():
3131 raise unittest .SkipTest ("perf trampoline profiling not supported" )
3232
3333
34- def samply_command_works ():
35- try :
36- cmd = ["samply" , "--help" ]
37- except (subprocess .SubprocessError , OSError ):
38- return False
39-
34+ def _samply_command_works ():
4035 # Check that we can run a simple samply run
4136 with temp_dir () as script_dir :
4237 try :
@@ -90,8 +85,10 @@ def run_samply(cwd, *args, **env_vars):
9085 with gzip .open (output_file , mode = "rt" , encoding = "utf-8" ) as f :
9186 return f .read ()
9287
88+ SAMPLY_COMMAND_WORKS = _samply_command_works ()
89+
9390
94- @unittest .skipUnless (samply_command_works () , "samply command doesn't work" )
91+ @unittest .skipUnless (SAMPLY_COMMAND_WORKS , "samply command doesn't work" )
9592class TestSamplyProfilerMixin :
9693 def run_samply (self , script_dir , perf_mode , script ):
9794 raise NotImplementedError ()
@@ -145,7 +142,7 @@ def baz(n):
145142 self .assertNotIn (f"py::baz:{ script } " , output )
146143
147144
148- @unittest .skipUnless (samply_command_works () , "samply command doesn't work" )
145+ @unittest .skipUnless (SAMPLY_COMMAND_WORKS , "samply command doesn't work" )
149146class TestSamplyProfiler (unittest .TestCase , TestSamplyProfilerMixin ):
150147 def run_samply (self , script_dir , script , activate_trampoline = True ):
151148 if activate_trampoline :
@@ -240,7 +237,7 @@ def compile_trampolines_for_all_functions():
240237 self .assertIn (line , child_perf_file_contents )
241238
242239
243- @unittest .skipUnless (samply_command_works () , "samply command doesn't work" )
240+ @unittest .skipUnless (SAMPLY_COMMAND_WORKS , "samply command doesn't work" )
244241class TestSamplyProfilerWithJitDump (unittest .TestCase , TestSamplyProfilerMixin ):
245242 # Regression test for gh-150723: exercises the binary jitdump backend
246243 # (-Xperf_jit) end to end through samply, unlike TestSamplyProfiler which
0 commit comments