浏览代码

instrumentation: Load queries for postBuild hook after build is done

We launch a `ctest --wait-and-collect-instrumentation` daemon at the
beginning of a build to implement the `postBuild` hook.  It waits for
the build tool to terminate and then collects instrumentation data.
If the build re-runs `cmake`, the instrumentation `query/generated`
directory may be regenerated.  Previously the daemon loaded the
queries up front, but that races with regeneration during the build.
Delay loading queries until after the build finishes.

This was exposed by intermittent test failures since commit a249e820a8
(instrumentation: Add file lock for build daemon, 2025-08-05), which
added build-time regeneration of the build system to an instrumentation
test case.
Brad King 1 月之前
父节点
当前提交
67add75ad7
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 1 1
      Source/cmInstrumentation.cxx
  2. 2 2
      Source/ctest.cxx

+ 1 - 1
Source/cmInstrumentation.cxx

@@ -790,7 +790,7 @@ int cmInstrumentation::CollectTimingAfterBuild(int ppid)
   };
   int ret = this->InstrumentCommand(
     "build", {}, [waitForBuild]() { return waitForBuild(); }, cm::nullopt,
-    cm::nullopt, LoadQueriesAfter::No);
+    cm::nullopt, LoadQueriesAfter::Yes);
   this->CollectTimingData(cmInstrumentationQuery::Hook::PostBuild);
   return ret;
 }

+ 2 - 2
Source/ctest.cxx

@@ -194,8 +194,8 @@ int main(int argc, char const* const* argv)
   // Dispatch 'ctest --collect-instrumentation' once given PID finishes
   if (argc == 4 &&
       strcmp(argv[1], "--wait-and-collect-instrumentation") == 0) {
-    return cmInstrumentation(argv[2]).CollectTimingAfterBuild(
-      std::stoi(argv[3]));
+    return cmInstrumentation(argv[2], cmInstrumentation::LoadQueriesAfter::No)
+      .CollectTimingAfterBuild(std::stoi(argv[3]));
   }
 
   // Dispatch 'ctest --collect-instrumentation' mode directly.