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