Sequoia
Loading...
Searching...
No Matches
ProjectPaths.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2020. //
3// Distributed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. //
4// (See accompanying file LICENSE.md or copy at //
5// https://www.gnu.org/licenses/gpl-3.0.en.html) //
7
8#pragma once
9
14#include <filesystem>
15#include <optional>
16#include <span>
17#include <string>
18#include <vector>
19
20namespace sequoia::testing
21{
22 inline constexpr std::string_view seqpat{".seqpat"};
23
27 {
28 public:
29 discoverable_paths() = default;
30
31 discoverable_paths(int argc, char** argv);
32
33 [[nodiscard]]
34 const std::filesystem::path& root() const noexcept
35 {
36 return m_Root;
37 }
38
39 [[nodiscard]]
40 const std::filesystem::path& executable() const noexcept
41 {
42 return m_Executable;
43 }
44
45 [[nodiscard]]
46 const std::filesystem::path& cmake_cache() const noexcept
47 {
48 return m_CMakeCache;
49 }
50
51 [[nodiscard]]
52 friend bool operator==(const discoverable_paths&, const discoverable_paths&) noexcept = default;
53 private:
54 std::filesystem::path m_Root{}, m_Executable{}, m_CMakeCache{};
55
56 discoverable_paths(std::filesystem::path rt, std::filesystem::path exec, std::filesystem::path cmakeCache);
57
58 [[nodiscard]]
59 static discoverable_paths make(int argc, char** argv);
60 };
61
65 {
66 public:
67 main_paths() = default;
68
69 main_paths(std::filesystem::path file, std::filesystem::path commonIncludes);
70
71 explicit main_paths(std::filesystem::path file);
72
73 [[nodiscard]]
74 const std::filesystem::path& file() const noexcept { return m_File; }
75
76 [[nodiscard]]
77 const std::filesystem::path& dir() const noexcept { return m_Dir; }
78
79 [[nodiscard]]
80 const std::filesystem::path& common_includes() const noexcept { return m_CommonIncludes; }
81
82 [[nodiscard]]
83 std::filesystem::path cmake_lists() const;
84
85 [[nodiscard]]
86 static std::filesystem::path default_main_cpp_from_root();
87
88 [[nodiscard]]
89 static std::filesystem::path default_cmake_from_root();
90
91 [[nodiscard]]
92 friend bool operator==(const main_paths&, const main_paths&) noexcept = default;
93 private:
94 std::filesystem::path m_File{}, m_Dir{}, m_CommonIncludes{};
95 };
96
100 {
101 public:
102 source_paths() = default;
103
104 explicit source_paths(const std::filesystem::path& projectRoot, const std::optional<std::filesystem::path>& folderName = {});
105
106 [[nodiscard]]
107 const std::filesystem::path& project() const noexcept
108 {
109 return m_Project;
110 }
111
112 [[nodiscard]]
113 const std::filesystem::path& repo() const noexcept
114 {
115 return m_Repo;
116 }
117
118 [[nodiscard]]
119 std::filesystem::path cmake_lists() const;
120
121 [[nodiscard]]
122 friend bool operator==(const source_paths&, const source_paths&) noexcept = default;
123 private:
124 std::filesystem::path m_Repo, m_Project;
125
126 [[nodiscard]]
127 static std::filesystem::path repo(std::filesystem::path projectRoot);
128 };
129
133 {
134 public:
135 tests_paths() = default;
136
137 explicit tests_paths(std::filesystem::path projectRoot);
138
139 [[nodiscard]]
140 const std::filesystem::path& repo() const noexcept
141 {
142 return m_Repo;
143 }
144
145 [[nodiscard]]
146 std::filesystem::path project_root() const;
147
148 [[nodiscard]]
149 friend bool operator==(const tests_paths&, const tests_paths&) noexcept = default;
150 private:
151 std::filesystem::path m_Repo;
152 };
153
157 {
158 public:
159 dependencies_paths() = default;
160
161 explicit dependencies_paths(std::filesystem::path projectRoot);
162
163 [[nodiscard]]
164 const std::filesystem::path& repo() const noexcept
165 {
166 return m_Repo;
167 }
168
169 [[nodiscard]]
170 std::filesystem::path project_root() const;
171
172 [[nodiscard]]
173 std::filesystem::path sequoia_root() const;
174
175 [[nodiscard]]
176 friend bool operator==(const dependencies_paths&, const dependencies_paths&) noexcept = default;
177 private:
178 std::filesystem::path m_Repo;
179 };
180
184 {
185 public:
186 test_materials_paths() = default;
187
188 explicit test_materials_paths(std::filesystem::path projectRoot);
189
190 [[nodiscard]]
191 const std::filesystem::path& repo() const noexcept
192 {
193 return m_Repo;
194 }
195
196 [[nodiscard]]
197 friend bool operator==(const test_materials_paths&, const test_materials_paths&) noexcept = default;
198 private:
199 std::filesystem::path m_Repo;
200 };
201
205 {
206 public:
207 build_system_paths() = default;
208
209 explicit build_system_paths(std::filesystem::path projectRoot);
210
211 [[nodiscard]]
212 const std::filesystem::path& repo() const noexcept
213 {
214 return m_Repo;
215 }
216
217 [[nodiscard]]
218 friend bool operator==(const build_system_paths&, const build_system_paths&) noexcept = default;
219 private:
220 std::filesystem::path m_Repo;
221 };
222
226 {
227 public:
228 build_paths() = default;
229
230 build_paths(std::filesystem::path projectRoot, std::filesystem::path executableDir, std::filesystem::path cmakeCacheDir);
231
232 [[nodiscard]]
233 const std::filesystem::path& dir() const { return m_Dir; }
234
235 [[nodiscard]]
236 const std::filesystem::path& executable_dir() const noexcept
237 {
238 return m_ExecutableDir;
239 }
240
241 [[nodiscard]]
242 const std::filesystem::path& cmake_cache_dir() const noexcept
243 {
244 return m_CMakeCacheDir;
245 }
246
247 [[nodiscard]]
248 friend bool operator==(const build_paths&, const build_paths&) noexcept = default;
249 private:
250 std::filesystem::path m_Dir{}, m_ExecutableDir{}, m_CMakeCacheDir{};
251 };
252
256 {
257 public:
258 auxiliary_paths() = default;
259
260 auxiliary_paths(const std::filesystem::path& projectRoot);
261
262 [[nodiscard]]
263 const std::filesystem::path& repo() const noexcept
264 {
265 return m_Dir;
266 }
267
268 [[nodiscard]]
269 static std::filesystem::path repo(const std::filesystem::path& projectRoot);
270
271 [[nodiscard]]
272 const std::filesystem::path& test_templates() const noexcept
273 {
274 return m_TestTemplates;
275 }
276
277 [[nodiscard]]
278 static std::filesystem::path test_templates(const std::filesystem::path& projectRoot);
279
280 [[nodiscard]]
281 const std::filesystem::path& source_templates() const noexcept
282 {
283 return m_SourceTemplates;
284 }
285
286 [[nodiscard]]
287 static std::filesystem::path source_templates(const std::filesystem::path& projectRoot);
288
289 [[nodiscard]]
290 const std::filesystem::path& project_template() const noexcept
291 {
292 return m_ProjectTemplate;
293 }
294
295 [[nodiscard]]
296 static std::filesystem::path project_template(const std::filesystem::path& projectRoot);
297
298 [[nodiscard]]
299 friend bool operator==(const auxiliary_paths&, const auxiliary_paths&) noexcept = default;
300 private:
301 std::filesystem::path
302 m_Dir{},
303 m_TestTemplates{},
304 m_SourceTemplates{},
305 m_ProjectTemplate{};
306 };
307
314 {
315 public:
316 recovery_paths() = default;
317
318 explicit recovery_paths(const std::filesystem::path& outputDir);
319
320 [[nodiscard]]
321 const std::filesystem::path& dir() const noexcept
322 {
323 return m_Dir;
324 }
325
326 [[nodiscard]]
327 static std::filesystem::path dir(std::filesystem::path outputDir);
328
329 [[nodiscard]]
330 std::filesystem::path recovery_file() const;
331
332 [[nodiscard]]
333 std::filesystem::path dump_file() const;
334
335 [[nodiscard]]
336 friend bool operator==(const recovery_paths&, const recovery_paths&) noexcept = default;
337 private:
338 std::filesystem::path m_Dir{};
339 };
340
344 {
345 public:
346 prune_paths() = default;
347
348 prune_paths(std::filesystem::path outputDir, const std::filesystem::path& buildRoot, const std::filesystem::path& buildDir);
349
350 [[nodiscard]]
351 const std::filesystem::path& dir() const noexcept
352 {
353 return m_Dir;
354 }
355
356 [[nodiscard]]
357 std::filesystem::path stamp() const;
358
359 [[nodiscard]]
360 std::filesystem::path failures(std::optional<std::size_t> id) const;
361
362 [[nodiscard]]
363 std::filesystem::path selected_passes(std::optional<std::size_t> id) const;
364
365 [[nodiscard]]
366 std::filesystem::path external_dependencies() const;
367
368 [[nodiscard]]
369 std::filesystem::path instability_analysis() const;
370
371 [[nodiscard]]
372 friend bool operator==(const prune_paths&, const prune_paths&) noexcept = default;
373 private:
374 std::filesystem::path m_Dir{}, m_Stem{};
375
376 [[nodiscard]]
377 static std::filesystem::path make_stem(const std::filesystem::path& buildDir);
378
379 [[nodiscard]]
380 std::filesystem::path make_path(std::optional<std::size_t> id, std::string_view extension) const;
381 };
382
383
387 {
388 public:
389 output_paths() = default;
390
391 explicit output_paths(const std::filesystem::path& projectRoot);
392
393 [[nodiscard]]
394 const std::filesystem::path& dir() const noexcept
395 {
396 return m_Dir;
397 }
398
399 [[nodiscard]]
400 static std::filesystem::path dir(std::filesystem::path projectRoot);
401
402 [[nodiscard]]
403 const std::filesystem::path& tests_temporary_data() const noexcept
404 {
405 return m_TestsTemporaryData;
406 }
407
408 [[nodiscard]]
409 static std::filesystem::path tests_temporary_data(std::filesystem::path projectRoot);
410
411 [[nodiscard]]
412 const std::filesystem::path& diagnostics() const noexcept
413 {
414 return m_Diagnostics;
415 }
416
417 [[nodiscard]]
418 static std::filesystem::path diagnostics(std::filesystem::path projectRoot);
419
420 [[nodiscard]]
421 const std::filesystem::path& test_summaries() const noexcept
422 {
423 return m_TestSummaries;
424 }
425
426 [[nodiscard]]
427 static std::filesystem::path test_summaries(std::filesystem::path projectRoot);
428
429 [[nodiscard]]
430 const std::filesystem::path& instability_analysis() const noexcept
431 {
432 return m_InstabilityAnalysis;
433 }
434
435 [[nodiscard]]
436 static std::filesystem::path instability_analysis_file(std::filesystem::path projectRoot, std::filesystem::path source, std::string_view name, std::size_t index);
437
438 [[nodiscard]]
439 static std::filesystem::path instability_analysis(std::filesystem::path projectRoot);
440
441 [[nodiscard]]
442 recovery_paths recovery() const
443 {
444 return recovery_paths{dir()};
445 }
446
447 [[nodiscard]]
448 prune_paths prune(const std::filesystem::path& buildRoot, const std::filesystem::path& buildDir) const
449 {
450 return {dir(), buildRoot, buildDir};
451 }
452
453 [[nodiscard]]
454 friend bool operator==(const output_paths&, const output_paths&) noexcept = default;
455 private:
456 std::filesystem::path
457 m_Dir{},
458 m_TestsTemporaryData{},
459 m_Diagnostics{},
460 m_TestSummaries{},
461 m_InstabilityAnalysis{};
462 };
463
467 {
468 public:
470 {
471 std::optional<std::filesystem::path> source_folder{};
472
473 std::vector<std::filesystem::path> additional_dependency_analysis_paths{};
474
475 std::filesystem::path main_cpp{main_paths::default_main_cpp_from_root()};
476
477 std::vector<std::filesystem::path> ancillary_main_cpps{};
478
479 std::filesystem::path common_includes{main_paths::default_main_cpp_from_root()};
480 };
481
482 project_paths() = default;
483
484 project_paths(int argc, char** argv, const customizer& customization);
485
486 [[nodiscard]]
487 const std::filesystem::path& project_root() const noexcept
488 {
489 return m_Discovered.root();
490 }
491
492 [[nodiscard]]
493 const std::filesystem::path& executable() const noexcept
494 {
495 return m_Discovered.executable();
496 }
497
498 [[nodiscard]]
499 const source_paths& source() const noexcept
500 {
501 return m_Source;
502 }
503
504 [[nodiscard]]
505 const dependencies_paths& dependencies() const noexcept
506 {
507 return m_Dependencies;
508 }
509
510 [[nodiscard]]
511 const tests_paths& tests() const noexcept
512 {
513 return m_Tests;
514 }
515
516 [[nodiscard]]
517 const test_materials_paths& test_materials() const noexcept
518 {
519 return m_Materials;
520 }
521
522 [[nodiscard]]
523 const build_paths& build() const noexcept
524 {
525 return m_Build;
526 }
527
528 [[nodiscard]]
529 const build_system_paths& build_system() const noexcept
530 {
531 return m_BuildSystem;
532 }
533
534 [[nodiscard]]
535 const auxiliary_paths& aux_paths() const noexcept
536 {
537 return m_Auxiliary;
538 }
539
540 [[nodiscard]]
541 const output_paths& output() const noexcept
542 {
543 return m_Output;
544 }
545
546 [[nodiscard]]
547 const main_paths& main() const noexcept
548 {
549 return m_Main;
550 }
551
552 [[nodiscard]]
553 const std::vector<main_paths>& ancillary_main_cpps() const noexcept
554 {
555 return m_AncillaryMainCpps;
556 }
557
558 [[nodiscard]]
559 const discoverable_paths& discovered() const noexcept
560 {
561 return m_Discovered;
562 }
563
564 [[nodiscard]]
565 std::span<const std::filesystem::path> additional_dependency_analysis_paths() const noexcept { return m_AdditionalDependencyAnalysisPaths; }
566
567 [[nodiscard]]
568 prune_paths prune() const;
569
570 [[nodiscard]]
571 friend bool operator==(const project_paths&, const project_paths&) noexcept = default;
572 private:
573 discoverable_paths m_Discovered;
574 main_paths m_Main;
575 source_paths m_Source;
576 build_paths m_Build;
577 auxiliary_paths m_Auxiliary;
578 output_paths m_Output;
579 dependencies_paths m_Dependencies;
580 tests_paths m_Tests;
581 test_materials_paths m_Materials;
582 build_system_paths m_BuildSystem;
583
584 std::vector<main_paths> m_AncillaryMainCpps{};
585 std::vector<std::filesystem::path> m_AdditionalDependencyAnalysisPaths{};
586 };
587}
Paths for auxiliary materials, used in creating projects/tests.
Definition: ProjectPaths.hpp:256
Paths relating to the build directory.
Definition: ProjectPaths.hpp:226
Paths relating to the build_system directory.
Definition: ProjectPaths.hpp:205
Paths relating to the dependencies directory.
Definition: ProjectPaths.hpp:157
Paths which are potentially discoverable from the commandline arguments.
Definition: ProjectPaths.hpp:27
Paths relating to the main cpp.
Definition: ProjectPaths.hpp:65
Paths in the output directory.
Definition: ProjectPaths.hpp:387
Paths used by the project.
Definition: ProjectPaths.hpp:467
Paths used when using dependencies to prune the number of tests.
Definition: ProjectPaths.hpp:344
Holds details of the file to which the last successfully completed test is registered.
Definition: ProjectPaths.hpp:314
Paths relating to the source directory.
Definition: ProjectPaths.hpp:100
Paths relating to the TestMaterials directory.
Definition: ProjectPaths.hpp:184
Paths relating to the Tests directory.
Definition: ProjectPaths.hpp:133
Definition: ProjectPaths.hpp:470