@@ -207,6 +207,12 @@ namespace
207207 {
208208 const fs::path presetsPath = projectDir / " CMakePresets.json" ;
209209
210+ auto fallback_build_dir = [&]() -> fs::path
211+ {
212+ std::error_code ec2;
213+ return fs::weakly_canonical (projectDir / " build" , ec2);
214+ };
215+
210216 std::error_code ec;
211217 if (!fs::exists (presetsPath, ec))
212218 {
@@ -216,21 +222,25 @@ namespace
216222 projectDir / " bld" / presetName,
217223 projectDir / " bld" ,
218224 projectDir / (" cmake-build-" + presetName),
225+ projectDir / " build" ,
219226 };
220227
221228 for (const auto &c : candidates)
222229 {
223230 if (fs::exists (c, ec) && fs::is_directory (c, ec))
224- return fs::weakly_canonical (c);
231+ {
232+ std::error_code ec2;
233+ return fs::weakly_canonical (c, ec2);
234+ }
225235 }
226236
227- return projectDir ;
237+ return fallback_build_dir () ;
228238 }
229239
230240 std::ifstream in (presetsPath);
231241 if (!in)
232242 {
233- return projectDir ;
243+ return fallback_build_dir () ;
234244 }
235245
236246 nlohmann::json j;
@@ -240,13 +250,13 @@ namespace
240250 }
241251 catch (...)
242252 {
243- return projectDir ;
253+ return fallback_build_dir () ;
244254 }
245255
246256 try
247257 {
248258 if (!j.contains (" configurePresets" ) || !j[" configurePresets" ].is_array ())
249- return projectDir ;
259+ return fallback_build_dir () ;
250260
251261 for (const auto &p : j[" configurePresets" ])
252262 {
@@ -265,14 +275,14 @@ namespace
265275 if (!buildDirectory.empty ())
266276 return normalize_binary_dir (projectDir, buildDirectory);
267277
268- return projectDir ;
278+ return fallback_build_dir () ;
269279 }
270280
271- return projectDir ;
281+ return fallback_build_dir () ;
272282 }
273283 catch (...)
274284 {
275- return projectDir ;
285+ return fallback_build_dir () ;
276286 }
277287 }
278288
@@ -355,6 +365,16 @@ namespace
355365 return 1 ;
356366 }
357367
368+ const fs::path ctestFile = buildDir / " CTestTestfile.cmake" ;
369+ if (!fs::exists (ctestFile, ec) || ec)
370+ {
371+ error (" No CTest configuration found in build directory." );
372+ hint (" This project is not configured/built yet (or tests are disabled)." );
373+ hint (" Run first: vix check (or vix build), then re-run: vix tests" );
374+ step (std::string (" Expected file: " ) + ctestFile.string ());
375+ return 1 ;
376+ }
377+
358378 info (" Running tests (CTest)." );
359379 hint (std::string (" Preset: " ) + presetName);
360380 hint (std::string (" Build dir: " ) + buildDir.string ());
0 commit comments