-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtest_build_directives.cpp
More file actions
954 lines (849 loc) · 43.2 KB
/
Copy pathtest_build_directives.cpp
File metadata and controls
954 lines (849 loc) · 43.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
#include <gtest/gtest.h>
import std;
import mcpp.build.directives;
import mcpp.manifest;
import mcpp.toolchain.dialect;
// The directive table is the single definition of what a `build.mcpp`
// directive IS. Before it existed, a directive was defined in nine places and
// adding one meant editing all of them — the failure mode being that you edit
// eight, and the ninth surfaces much later as a flag that silently never
// reached the compiler. These tests hold the table's invariants so that a new
// row cannot be half-added.
namespace dirs = mcpp::build::directives;
namespace {
const mcpp::toolchain::CommandDialect& gnu() {
return mcpp::toolchain::gnu_dialect();
}
// A root that is genuinely absolute on the running platform. A literal "/pkg"
// is NOT absolute on Windows (no root name), so hardcoding POSIX strings makes
// these tests assert the wrong thing there rather than the right thing
// everywhere.
const std::filesystem::path& test_root() {
static const std::filesystem::path r =
(std::filesystem::current_path() / "pkg").lexically_normal();
return r;
}
// What the implementation should produce for a package-relative path —
// expressed through the same std::filesystem arithmetic, so the expectation is
// about the BEHAVIOUR ("relative resolves against the root") rather than about
// one platform's separator.
std::string under_root(std::string_view rel) {
return (test_root() / rel).lexically_normal().string();
}
dirs::Directives parse(std::string_view text) {
dirs::Directives d;
dirs::accept_output(d, gnu(), test_root(), text);
return d;
}
} // namespace
// ── Table integrity ────────────────────────────────────────────────────────
TEST(BuildDirectives, EveryRowIsInternallyConsistent) {
for (auto const& def : dirs::kTable) {
EXPECT_FALSE(def.wire.empty());
EXPECT_GT(def.sinceProtocol, 0) << def.wire;
EXPECT_LE(def.sinceProtocol, dirs::kProtocolVersion) << def.wire;
// A RerunKey directive feeds only the re-run key, so it must NOT be
// persisted as a `d` record; everything else must be, or a cache hit
// would silently apply less than the program asked for.
if (def.scope == dirs::Scope::RerunKey)
EXPECT_TRUE(def.tag.empty()) << def.wire;
else
EXPECT_FALSE(def.tag.empty()) << def.wire;
// The declared-output contract needs a diagnostic that says WHICH
// contract was broken.
if (def.mustExistAfterRun) {
EXPECT_FALSE(def.missingPrefix.empty()) << def.wire;
EXPECT_FALSE(def.missingSuffix.empty()) << def.wire;
}
}
}
TEST(BuildDirectives, WireNamesAreUnique) {
std::set<std::string_view> seen;
for (auto const& def : dirs::kTable)
EXPECT_TRUE(seen.insert(def.wire).second) << "duplicate wire " << def.wire;
}
TEST(BuildDirectives, RowsSharingATagShareASlot) {
// Cache deserialization resolves a tag to exactly one slot, so two rows
// with the same tag but different slots would round-trip to the wrong
// channel. link-lib and link-search legitimately share `ldflag`.
std::map<std::string_view, dirs::Slot> slotOfTag;
for (auto const& def : dirs::kTable) {
if (def.tag.empty()) continue;
auto [it, fresh] = slotOfTag.try_emplace(def.tag, def.slot);
if (!fresh) EXPECT_EQ(it->second, def.slot) << def.tag;
}
}
TEST(BuildDirectives, LookupsAgree) {
for (auto const& def : dirs::kTable) {
ASSERT_NE(dirs::find_by_wire(def.wire), nullptr) << def.wire;
EXPECT_EQ(dirs::find_by_wire(def.wire)->slot, def.slot) << def.wire;
if (!def.tag.empty()) {
ASSERT_NE(dirs::find_by_tag(def.tag), nullptr) << def.tag;
EXPECT_EQ(dirs::find_by_tag(def.tag)->slot, def.slot) << def.tag;
}
}
EXPECT_EQ(dirs::find_by_wire("no-such-directive"), nullptr);
// The empty tag belongs to the rerun rows and must never resolve, or a
// malformed cache line would be silently accepted into a slot.
EXPECT_EQ(dirs::find_by_tag(""), nullptr);
}
// ── Parsing ────────────────────────────────────────────────────────────────
TEST(BuildDirectives, NonDirectiveLinesAreIgnored) {
auto d = parse("hello\nmcpp is not a directive\n \n");
for (std::size_t i = 0; i < dirs::kSlotCount; ++i)
EXPECT_TRUE(d.slots[i].empty());
EXPECT_TRUE(d.unknownKeys.empty());
EXPECT_EQ(d.protocol, 0);
}
TEST(BuildDirectives, TransformsAreAppliedOnceAtParseTime) {
// An input that is already absolute ON THIS PLATFORM, so the "taken as-is"
// half of the assertion tests what it claims to.
const auto alreadyAbs =
(std::filesystem::current_path() / "abs" / "inc").lexically_normal();
auto d = parse(std::format("mcpp:cxxflag=-Wall\n"
"mcpp:link-lib=z\n"
"mcpp:link-search=vendor/lib\n"
"mcpp:cfg=HAVE_X\n"
"mcpp:include-dir=inc\n"
"mcpp:include-dir-after={}\n",
alreadyAbs.string()));
EXPECT_EQ(d.at(dirs::Slot::CxxFlags), (std::vector<std::string>{"-Wall"}));
// link-lib and link-search share the ldflags slot, in emission order.
EXPECT_EQ(d.at(dirs::Slot::LdFlags),
(std::vector<std::string>{"-lz", "-L" + under_root("vendor/lib")}));
EXPECT_EQ(d.at(dirs::Slot::Defines), (std::vector<std::string>{"-DHAVE_X"}));
// Relative resolves against the package root; absolute is taken as-is.
EXPECT_EQ(d.at(dirs::Slot::IncludeDirs),
(std::vector<std::string>{under_root("inc")}));
EXPECT_EQ(d.at(dirs::Slot::IncludeDirsAfter),
(std::vector<std::string>{alreadyAbs.string()}));
}
TEST(BuildDirectives, DialectDecidesTheSpelling) {
dirs::Directives d;
dirs::accept_output(d, mcpp::toolchain::msvc_dialect(), test_root(),
"mcpp:link-lib=z\nmcpp:cfg=HAVE_X\n");
EXPECT_EQ(d.at(dirs::Slot::LdFlags), (std::vector<std::string>{"z.lib"}));
EXPECT_EQ(d.at(dirs::Slot::Defines), (std::vector<std::string>{"/DHAVE_X"}));
}
TEST(BuildDirectives, ValuesMayContainSpacesAndEqualsSigns) {
// Everything after the FIRST '=' is the value — a path with a space or a
// define with an '=' must survive intact.
auto d = parse("mcpp:cxxflag=-DMSG=\"a b\"\n");
EXPECT_EQ(d.at(dirs::Slot::CxxFlags),
(std::vector<std::string>{"-DMSG=\"a b\""}));
}
// ── Protocol ───────────────────────────────────────────────────────────────
TEST(BuildDirectives, UnknownKeyWithoutAnAnnouncementIsTolerated) {
// A hand-written printf program announces nothing; its surface is frozen,
// so an unknown key is a typo the engine warns about rather than a
// forward-compat situation it must refuse.
auto d = parse("mcpp:no-such-thing=1\n");
EXPECT_EQ(d.protocol, 0);
EXPECT_EQ(d.unknownKeys, (std::vector<std::string>{"no-such-thing"}));
EXPECT_FALSE(dirs::protocol_error(d).has_value());
}
TEST(BuildDirectives, UnknownKeyWithAnAnnouncementIsFatal) {
auto d = parse("mcpp:protocol=1\nmcpp:no-such-thing=1\n");
EXPECT_EQ(d.protocol, 1);
auto err = dirs::protocol_error(d);
ASSERT_TRUE(err.has_value());
EXPECT_NE(err->find("no-such-thing"), std::string::npos);
}
TEST(BuildDirectives, NewerProtocolIsFatalAndSaysWhatToDo) {
auto d = parse("mcpp:protocol=999\n");
auto err = dirs::protocol_error(d);
ASSERT_TRUE(err.has_value());
EXPECT_NE(err->find("999"), std::string::npos);
// The message has to tell the user the actionable thing, not just that
// something is wrong.
EXPECT_NE(err->find("upgrade"), std::string::npos);
}
TEST(BuildDirectives, CurrentProtocolIsAccepted) {
auto d = parse(std::format("mcpp:protocol={}\nmcpp:cxxflag=-Wall\n",
dirs::kProtocolVersion));
EXPECT_FALSE(dirs::protocol_error(d).has_value());
EXPECT_EQ(d.at(dirs::Slot::CxxFlags), (std::vector<std::string>{"-Wall"}));
}
TEST(BuildDirectives, UnknownKeysAreDeduplicated) {
auto d = parse("mcpp:zzz=1\nmcpp:zzz=2\nmcpp:yyy=3\n");
EXPECT_EQ(d.unknownKeys, (std::vector<std::string>{"zzz", "yyy"}));
}
// ── Cache round-trip ───────────────────────────────────────────────────────
TEST(BuildDirectives, SerializeDeserializeRoundTrip) {
auto d = parse("mcpp:cxxflag=-Wall\n"
"mcpp:cflag=-std=c11\n"
"mcpp:link-lib=z\n"
"mcpp:link-search=vendor/lib\n"
"mcpp:cfg=HAVE_X\n"
"mcpp:generated=src/gen.cpp\n"
"mcpp:source=vendor/pick.cpp\n"
"mcpp:include-dir=inc\n"
"mcpp:include-dir-after=after\n"
"mcpp:fact=widget.driver=1.2\n"
"mcpp:floor=widget.driver >= 1.0\n"
"mcpp:pack-format=appimage\n"
"mcpp:windows-subsystem=gui:windows\n"
"mcpp:windows-entry=gui:wWinMain\n");
std::ostringstream os;
dirs::serialize(os, d);
dirs::Directives back;
std::istringstream is(os.str());
std::string line;
while (std::getline(is, line)) {
ASSERT_TRUE(line.starts_with("d "));
auto rest = line.substr(2);
auto sp = rest.find(' ');
ASSERT_NE(sp, std::string::npos);
EXPECT_TRUE(dirs::accept_cache_record(back, rest.substr(0, sp),
rest.substr(sp + 1)));
}
// Every persisted slot survives verbatim; the rerun slots deliberately do
// not (they are re-derived from their own cache records).
for (auto const& def : dirs::kTable) {
if (def.tag.empty()) continue;
EXPECT_EQ(back.at(def.slot), d.at(def.slot)) << def.wire;
}
}
// ── The probe channel ──────────────────────────────────────────────────────
//
// A rule package measures, the engine compares. What arrives on the wire is
// folded into the SAME runtime declarations a manifest could have written,
// so the version-floor check in prepare reads one list and never learns
// which spelling a claim came in.
TEST(BuildDirectives, FactsAndFloorsAreClaimsThatFoldIntoRuntimeDeclarations) {
auto d = parse("mcpp:fact=widget.driver=1.2\n"
"mcpp:floor=widget.driver >= 2.0\n");
EXPECT_EQ(d.at(dirs::Slot::Facts), (std::vector<std::string>{"widget.driver=1.2"}));
EXPECT_EQ(d.at(dirs::Slot::Floors), (std::vector<std::string>{"widget.driver >= 2.0"}));
mcpp::manifest::Manifest m;
dirs::apply(m, d);
ASSERT_EQ(m.runtimeConfig.provides.size(), 1u);
EXPECT_EQ(m.runtimeConfig.provides[0], "widget.driver=1.2");
ASSERT_EQ(m.runtimeConfig.requirements.size(), 1u);
EXPECT_EQ(m.runtimeConfig.requirements[0].kind, "version-floor");
EXPECT_EQ(m.runtimeConfig.requirements[0].value, "widget.driver >= 2.0");
// A claim about the build, not about the link or the run: the phase says
// when it is decided.
EXPECT_EQ(m.runtimeConfig.requirements[0].phase, "build");
}
TEST(BuildDirectives, APackFormatIsANameCarriedAndNotInterpreted) {
auto d = parse("mcpp:pack-format=appimage\n"
"mcpp:pack-format=msi\n");
EXPECT_EQ(d.at(dirs::Slot::PackFormats),
(std::vector<std::string>{"appimage", "msi"}));
mcpp::manifest::Manifest m;
dirs::apply(m, d);
EXPECT_EQ(m.buildConfig.packFormats,
(std::vector<std::string>{"appimage", "msi"}));
// The engine holds the DISPATCH and no format, so a name reaches neither
// the compile line nor the link line. A row that leaked into either would
// put dpkg's or WiX's vocabulary on a command line.
EXPECT_TRUE(m.buildConfig.cflags.empty());
EXPECT_TRUE(m.buildConfig.cxxflags.empty());
EXPECT_TRUE(m.buildConfig.ldflags.empty());
EXPECT_TRUE(m.buildConfig.sources.empty());
EXPECT_TRUE(m.buildConfig.actions.empty());
}
TEST(BuildDirectives, APackFormatDeclarationIsPersisted) {
// THE HALF THAT WOULD OTHERWISE BE MISSED. A build program's result is
// cached and a hit does not re-run it, and the pass that READS this set is
// `mcpp pack`, which is never a project's first build. A declaration that
// was not persisted would therefore be present exactly once and absent
// every time it mattered, and `--format <name>` would refuse naming
// nothing.
//
// `SerializeDeserializeRoundTrip` above asserts the round trip for every
// tagged row, so this only has to hold the field that puts the row in that
// set -- which is the field a new row is most likely to be added without.
const auto* def = dirs::find_by_wire("pack-format");
ASSERT_NE(def, nullptr);
EXPECT_FALSE(def->tag.empty()) << "a tag-less row is not replayed on a cache hit";
EXPECT_EQ(def->slot, dirs::Slot::PackFormats);
EXPECT_EQ(def->scope, dirs::Scope::Claim);
}
TEST(BuildDirectives, AClaimReachesNeitherCompileNorLink) {
auto d = parse("mcpp:fact=widget.driver=1.2\n"
"mcpp:floor=widget.driver >= 2.0\n");
mcpp::manifest::Manifest m;
dirs::apply(m, d);
EXPECT_TRUE(m.buildConfig.cflags.empty());
EXPECT_TRUE(m.buildConfig.cxxflags.empty());
EXPECT_TRUE(m.buildConfig.ldflags.empty());
EXPECT_TRUE(m.buildConfig.sources.empty());
for (auto const& def : dirs::kTable)
if (def.slot == dirs::Slot::Facts || def.slot == dirs::Slot::Floors)
EXPECT_EQ(def.scope, dirs::Scope::Claim) << def.wire;
}
TEST(BuildDirectives, RerunSlotsAreNotPersistedAsDirectives) {
auto d = parse("mcpp:rerun-if-changed=config.h\n"
"mcpp:rerun-if-env-changed=USE_FAST\n");
EXPECT_EQ(d.at(dirs::Slot::RerunFiles), (std::vector<std::string>{"config.h"}));
EXPECT_EQ(d.at(dirs::Slot::RerunEnv), (std::vector<std::string>{"USE_FAST"}));
std::ostringstream os;
dirs::serialize(os, d);
EXPECT_TRUE(os.str().empty());
}
TEST(BuildDirectives, UnknownCacheTagIsRejectedRatherThanDropped) {
// A cache written by a NEWER mcpp carries tags this one does not know.
// Silently skipping them would apply a strict subset of what the program
// asked for; the caller turns `false` into "entry is stale".
dirs::Directives d;
EXPECT_FALSE(dirs::accept_cache_record(d, "some-future-tag", "value"));
EXPECT_TRUE(dirs::accept_cache_record(d, "cxxflag", "-Wall"));
}
// ── Apply ──────────────────────────────────────────────────────────────────
TEST(BuildDirectives, ApplyRoutesEachSlotToItsManifestChannel) {
auto d = parse("mcpp:cxxflag=-Wall\n"
"mcpp:cflag=-std=c11\n"
"mcpp:link-lib=z\n"
"mcpp:cfg=HAVE_X\n"
"mcpp:generated=src/gen.cpp\n"
"mcpp:source=vendor/pick.cpp\n"
"mcpp:include-dir=inc\n"
"mcpp:include-dir-after=after\n");
mcpp::manifest::Manifest m;
dirs::apply(m, d);
auto const& bc = m.buildConfig;
EXPECT_NE(std::find(bc.cxxflags.begin(), bc.cxxflags.end(), "-Wall"),
bc.cxxflags.end());
EXPECT_NE(std::find(bc.cflags.begin(), bc.cflags.end(), "-std=c11"),
bc.cflags.end());
EXPECT_NE(std::find(bc.ldflags.begin(), bc.ldflags.end(), "-lz"),
bc.ldflags.end());
// A cfg define colours BOTH language channels — the one slot that fans out.
EXPECT_NE(std::find(bc.cflags.begin(), bc.cflags.end(), "-DHAVE_X"),
bc.cflags.end());
EXPECT_NE(std::find(bc.cxxflags.begin(), bc.cxxflags.end(), "-DHAVE_X"),
bc.cxxflags.end());
// generated= and source= must reach BOTH source lists: the scanner walks
// the legacy modules.sources mirror, and a file missing from it is
// invisible to the module scan.
for (auto const& s : {"src/gen.cpp", "vendor/pick.cpp"}) {
EXPECT_NE(std::find(bc.sources.begin(), bc.sources.end(), s),
bc.sources.end()) << s;
EXPECT_NE(std::find(m.modules.sources.begin(), m.modules.sources.end(), s),
m.modules.sources.end()) << s;
}
EXPECT_NE(std::find(bc.includeDirs.begin(), bc.includeDirs.end(),
std::filesystem::path(under_root("inc"))),
bc.includeDirs.end());
EXPECT_NE(std::find(bc.includeDirsAfter.begin(), bc.includeDirsAfter.end(),
std::filesystem::path(under_root("after"))),
bc.includeDirsAfter.end());
}
TEST(BuildDirectives, ApplyAppendsRatherThanReplaces) {
mcpp::manifest::Manifest m;
m.buildConfig.cxxflags.push_back("-O2");
dirs::apply(m, parse("mcpp:cxxflag=-Wall\n"));
EXPECT_EQ(m.buildConfig.cxxflags,
(std::vector<std::string>{"-O2", "-Wall"}));
}
// ── Private-scope fold ─────────────────────────────────────────────────────
namespace {
// UsageRequirements-shaped, so the fold can be exercised without importing
// the scanner into a unit test.
struct FakeUsage {
std::vector<std::filesystem::path> includeDirs;
std::vector<std::filesystem::path> includeDirsAfter;
std::vector<std::string> cflags;
std::vector<std::string> cxxflags;
};
} // namespace
TEST(BuildDirectives, FoldMovesOnlyTheTailAndOnlyPrivateChannels) {
mcpp::manifest::Manifest m;
m.buildConfig.cxxflags.push_back("-O2"); // pre-existing, not a directive
m.buildConfig.includeDirs.emplace_back("/pre");
auto before = dirs::mark(m);
dirs::apply(m, parse("mcpp:cxxflag=-Wall\n"
"mcpp:cfg=HAVE_X\n"
"mcpp:link-lib=z\n"
"mcpp:include-dir=inc\n"));
FakeUsage priv;
dirs::fold_private_tail(priv, m, before);
// Only what the program added, and only the private channels.
EXPECT_EQ(priv.cxxflags, (std::vector<std::string>{"-Wall", "-DHAVE_X"}));
EXPECT_EQ(priv.cflags, (std::vector<std::string>{"-DHAVE_X"}));
EXPECT_EQ(priv.includeDirs,
(std::vector<std::filesystem::path>{under_root("inc")}));
// Link flags are NOT private — they reach the final link through their own
// path, and folding them here would double-apply them.
EXPECT_TRUE(priv.includeDirsAfter.empty());
}
TEST(BuildDirectives, FoldIsIdempotentOnIncludeDirs) {
// Include dirs are unique-appended: the same dir emitted twice, or a fold
// replayed, must not grow the list.
mcpp::manifest::Manifest m;
auto before = dirs::mark(m);
dirs::apply(m, parse("mcpp:include-dir=inc\nmcpp:include-dir=inc\n"));
FakeUsage priv;
dirs::fold_private_tail(priv, m, before);
dirs::fold_private_tail(priv, m, before);
EXPECT_EQ(priv.includeDirs,
(std::vector<std::filesystem::path>{under_root("inc")}));
}
// ── Run bound ──────────────────────────────────────────────────────────────
// T-3. The precedence is a PURE function of two optionals, which is the whole
// reason `run_timeout` was split from `env_timeout_override`: this table can
// be walked without touching the process environment.
//
// Nine rows, and the two that matter most are the `nullopt` vs `0` pairs.
// With a plain `int` those two would be the same value, and since 0 MEANS "no
// limit", every project that never mentions the key would silently lose its
// bound. That is why both levels are optionals all the way down.
TEST(BuildDirectives, RunTimeoutPrecedenceIsEnvThenManifestThenDefault) {
using ms = std::chrono::milliseconds;
constexpr auto def = ms(dirs::kDefaultRunTimeoutSecs * 1000);
const std::optional<int> unset;
// env, manifest, expected
struct Row { std::optional<int> env, manifest; ms want; };
const Row rows[] = {
{ unset, unset, def }, // neither: the built-in bound
{ unset, 1800, ms(1800'000) },// manifest alone
{ unset, 0, ms(0) }, // manifest asks for no bound
{ 30, unset, ms(30'000)}, // env alone
{ 30, 1800, ms(30'000)}, // env WINS over the manifest
{ 0, 1800, ms(0) }, // env 0 wins too — "no bound, now"
{ 30, 0, ms(30'000)}, // ... and in the other direction
{ 0, unset, ms(0) },
{ 1, 1, ms(1'000) },
};
for (auto const& r : rows) {
EXPECT_EQ(dirs::run_timeout(r.env, r.manifest), r.want)
<< "env=" << (r.env ? std::to_string(*r.env) : "unset")
<< " manifest=" << (r.manifest ? std::to_string(*r.manifest) : "unset");
}
// Default: bounded. An unbounded build program is how a build hangs with
// no diagnostic at all.
EXPECT_GT(dirs::run_timeout(unset, unset).count(), 0);
}
// ── Glob inputs (#359) ─────────────────────────────────────────────────────
//
// A build program that globs its inputs was structurally unsafe: adding a
// .proto changed no declared file's hash, so the program did not re-run and
// the new file was silently never generated. Measured before the fix:
// `Finished dev in 0.01s`, zero artifacts.
//
// The fingerprint is the SET of matching paths. These tests pin what is in it
// and — just as importantly — what is not.
namespace {
struct GlobTree {
std::filesystem::path root;
explicit GlobTree(std::string_view name) {
root = std::filesystem::temp_directory_path() / name;
std::filesystem::remove_all(root);
std::filesystem::create_directories(root / "proto");
}
~GlobTree() { std::error_code ec; std::filesystem::remove_all(root, ec); }
void write(std::string_view rel, std::string_view text) {
auto p = root / rel;
std::filesystem::create_directories(p.parent_path());
std::ofstream os(p, std::ios::trunc);
os << text;
}
std::string fp(std::string_view pattern, std::string_view outDir = "target") {
return dirs::glob_fingerprint(root, pattern, outDir);
}
};
} // namespace
TEST(BuildDirectives, GlobFingerprintChangesWhenAFileAppearsOrDisappears) {
GlobTree t{"mcpp_glob_fp_membership"};
t.write("proto/a.proto", "syntax=\"proto3\";");
auto one = t.fp("proto/**/*.proto");
t.write("proto/b.proto", "syntax=\"proto3\";");
auto two = t.fp("proto/**/*.proto");
EXPECT_NE(one, two);
std::filesystem::remove(t.root / "proto/b.proto");
EXPECT_EQ(t.fp("proto/**/*.proto"), one);
}
TEST(BuildDirectives, GlobFingerprintIgnoresContentSizeAndTimestamp) {
// Contents are covered by the ordinary `rerun-if-changed` entry for that
// file. Folding them in here would only add false re-runs — and mtime is
// unstable across git checkout, container builds and rsync, which this
// project has already paid for once (the file_time_type epoch in the
// dependency cache).
GlobTree t{"mcpp_glob_fp_content"};
t.write("proto/a.proto", "syntax=\"proto3\";");
auto before = t.fp("proto/**/*.proto");
t.write("proto/a.proto", "syntax=\"proto3\"; message Much { string longer = 1; }");
std::filesystem::last_write_time(
t.root / "proto/a.proto",
std::filesystem::file_time_type::clock::now() + std::chrono::hours(1));
EXPECT_EQ(t.fp("proto/**/*.proto"), before);
}
TEST(BuildDirectives, GlobFingerprintNeverWalksTheBuildOutputTree) {
// A build program writes its outputs INSIDE the project. If a wide pattern
// included them the set would change on every build and the program would
// re-run forever — the classic Cargo footgun. Enforced by the engine
// rather than left to the author's pattern.
GlobTree t{"mcpp_glob_fp_outdir"};
t.write("proto/a.proto", "x");
auto before = t.fp("**");
t.write("target/.build-mcpp/out/a.pb.cc", "generated");
t.write("target/.build-mcpp/out/a.pb.h", "generated");
EXPECT_EQ(t.fp("**"), before);
// .git is excluded for the same reason: it changes on every commit and
// never means the build program's inputs changed.
t.write(".git/HEAD", "ref: refs/heads/main");
EXPECT_EQ(t.fp("**"), before);
}
TEST(BuildDirectives, GlobFingerprintIsIndependentOfDirectoryIterationOrder) {
// The set is sorted before hashing, so two trees with the same members
// agree regardless of the order the platform hands them back.
GlobTree a{"mcpp_glob_fp_order_a"};
GlobTree b{"mcpp_glob_fp_order_b"};
for (auto n : { "z.proto", "a.proto", "m.proto" }) a.write(std::string("proto/") + n, "x");
for (auto n : { "a.proto", "m.proto", "z.proto" }) b.write(std::string("proto/") + n, "y");
EXPECT_EQ(a.fp("proto/**/*.proto"), b.fp("proto/**/*.proto"));
}
TEST(BuildDirectives, GlobDirectiveParsesIntoItsOwnSlot) {
auto d = parse("mcpp:rerun-if-changed-glob=proto/**/*.proto\n");
ASSERT_EQ(d.at(dirs::Slot::RerunGlobs).size(), 1u);
EXPECT_EQ(d.at(dirs::Slot::RerunGlobs)[0], "proto/**/*.proto");
// A re-run key is not a build input, so it must not be persisted as a `d`
// record — otherwise a cache hit would replay it as one.
std::ostringstream os;
dirs::serialize(os, d);
EXPECT_EQ(os.str().find("proto/**"), std::string::npos) << os.str();
}
// ── link-script ────────────────────────────────────────────────────────────
//
// The row exists so a board-support package can hand a consumer the board's
// memory layout. Everything else that could carry it is either package-private
// (`cxxflag`) or cannot express the flag at all (`link-lib` emits `-l`,
// `link-search` emits `-L`) — so without it the one thing a user cannot write
// for themselves was the one thing they had to.
TEST(BuildDirectives, LinkScriptBecomesDashTWithAnAbsolutePath) {
auto d = parse("mcpp:link-script=board/link.ld\n");
auto& ld = d.at(dirs::Slot::LdFlags);
ASSERT_EQ(ld.size(), 1u);
// Absolute, because the link runs in the build directory: a relative path
// resolves against the wrong root and lld answers "cannot find linker
// script link.ld" (measured).
EXPECT_EQ(ld[0], "-T " + under_root("board/link.ld"));
}
TEST(BuildDirectives, LinkScriptIsLinkGlobalSoItReachesTheConsumer) {
// The whole point: a dependency's build.mcpp must be able to widen the
// LINK (as link-lib/link-search already do) without widening the public
// COMPILE interface (which include-dir deliberately cannot).
const dirs::Def* script = nullptr;
const dirs::Def* incdir = nullptr;
for (auto const& def : dirs::kTable) {
if (def.wire == "link-script") script = &def;
if (def.wire == "include-dir") incdir = &def;
}
ASSERT_NE(script, nullptr);
ASSERT_NE(incdir, nullptr);
EXPECT_EQ(script->scope, dirs::Scope::LinkGlobal);
EXPECT_EQ(incdir->scope, dirs::Scope::PackagePrivate);
}
TEST(BuildDirectives, LinkScriptDoesNotClaimADeclaredOutput) {
// `mustExistAfterRun` assumes the value IS a path; this row's transformed
// value is `-T <path>`, so the check would test the wrong string and
// reject a script that is right there.
for (auto const& def : dirs::kTable) {
if (def.wire != "link-script") continue;
EXPECT_FALSE(def.mustExistAfterRun);
}
}
// ── runner ─────────────────────────────────────────────────────────────────
//
// How the artifact is EXECUTED, when the host cannot execute it. Produced by
// a board-support package's build.mcpp, because the value is machine-specific:
// the emulator lives in a package payload whose path carries a home and a
// version, and only a build program can compute that.
TEST(BuildDirectives, RunnerBuildsAnArgvFromRepeatedLines) {
// argv is an ordered list and a directive is one line = one value, so the
// list is built by repetition. Order is the emission order.
auto d = parse("mcpp:runner=/payload/bin/qemu-system-riscv64\n"
"mcpp:runner=-machine\n"
"mcpp:runner=virt\n"
"mcpp:runner=-kernel\n");
auto& r = d.at(dirs::Slot::Runner);
ASSERT_EQ(r.size(), 4u);
EXPECT_EQ(r[0], "/payload/bin/qemu-system-riscv64");
EXPECT_EQ(r[1], "-machine");
EXPECT_EQ(r[3], "-kernel");
}
TEST(BuildDirectives, RunnerTokensAreVerbatim) {
// Not a path to normalize: `-bios` is a token, and the producer already
// resolved the executable absolutely (a bare name resolves through PATH to
// a shim that dispatches against its OWNER home — measured in CI).
auto d = parse("mcpp:runner=-bios\nmcpp:runner=none\n");
auto& r = d.at(dirs::Slot::Runner);
ASSERT_EQ(r.size(), 2u);
EXPECT_EQ(r[0], "-bios");
EXPECT_EQ(r[1], "none");
}
TEST(BuildDirectives, RunnerHasItsOwnSlotAndScope) {
const dirs::Def* runner = nullptr;
const dirs::Def* script = nullptr;
for (auto const& def : dirs::kTable) {
if (def.wire == "runner") runner = &def;
if (def.wire == "link-script") script = &def;
}
ASSERT_NE(runner, nullptr);
ASSERT_NE(script, nullptr);
// Its own slot: putting it in LdFlags would put an emulator's argv on the
// linker command line.
EXPECT_EQ(runner->slot, dirs::Slot::Runner);
EXPECT_NE(runner->slot, script->slot);
// Its own scope: RunGlobal propagates like LinkGlobal but carries an
// exactly-one-provider rule that LinkGlobal must not inherit — two
// dependencies' link flags concatenate correctly, two runners cannot.
EXPECT_EQ(runner->scope, dirs::Scope::RunGlobal);
EXPECT_EQ(script->scope, dirs::Scope::LinkGlobal);
}
TEST(BuildDirectives, RunnerLandsInBuildConfigNotInLdflags) {
auto d = parse("mcpp:runner=/qemu\nmcpp:runner=-kernel\n"
"mcpp:link-lib=c\n");
mcpp::manifest::Manifest m;
dirs::apply(m, d);
ASSERT_EQ(m.buildConfig.runner.size(), 2u);
EXPECT_EQ(m.buildConfig.runner[0], "/qemu");
// The link line must carry the library and nothing of the runner.
for (auto const& f : m.buildConfig.ldflags)
EXPECT_EQ(f.find("qemu"), std::string::npos) << f;
}
// ── Build-graph node decoding: `mcpp:action=` ───────────────────────────────
//
// `decode_action` is the other half of `mcpp::action::submit()` in
// src/build/hostprogram.cppm: the typed builder serialises one JSON object
// per action, and this is where it comes back. `depfile` is decoded the same
// way `blocking` is — a scalar read with `j.value(...)` and a default that
// matches "the field was never set" — so an action a build program submitted
// before this field existed decodes exactly as it always has.
TEST(BuildDirectives, DecodeActionRoundTripsDepfile) {
auto d = parse(
"mcpp:action={\"id\":\"shader\",\"role\":\"source\","
"\"description\":\"\",\"blocking\":false,\"depfile\":\"out/shader.spv.d\","
"\"inputs\":[],\"outputs\":[\"out/shader.spv\"],"
"\"command\":[\"glslc.sh\"],\"provides\":[],\"imports\":[],\"targets\":[]}\n");
ASSERT_EQ(d.at(dirs::Slot::Actions).size(), 1u);
auto a = dirs::decode_action(d.at(dirs::Slot::Actions).front());
ASSERT_TRUE(a.has_value());
EXPECT_EQ(a->depfile, "out/shader.spv.d");
}
// THE CONTROL — and the common case, since `depfile` is optional and
// `hostprogram.cppm`'s `submit()` omits the key entirely when it was never
// set (byte-identical payload to before the field existed). A decoder that
// required the key would reject every action submitted by that path.
TEST(BuildDirectives, DecodeActionDefaultsDepfileToEmptyWhenAbsent) {
auto d = parse(
"mcpp:action={\"id\":\"gen\",\"role\":\"source\","
"\"description\":\"\",\"blocking\":false,"
"\"inputs\":[],\"outputs\":[\"out/gen.cpp\"],"
"\"command\":[\"gen.sh\"],\"provides\":[],\"imports\":[],\"targets\":[]}\n");
ASSERT_EQ(d.at(dirs::Slot::Actions).size(), 1u);
auto a = dirs::decode_action(d.at(dirs::Slot::Actions).front());
ASSERT_TRUE(a.has_value());
EXPECT_EQ(a->depfile, "");
}
// The overflow marker. Until 2026.9.13.1 `mcpp::action` held its lists in
// fixed arrays and set the marker when a declaration did not fit; the lists
// now grow, and the marker means the build program could not allocate. The
// refusal stays -- an incomplete declaration must never be used -- and the
// message has to say what is now true: nothing about a buffer size, nothing
// recommending a response file for a list that no longer needs one.
TEST(BuildDirectives, OverflowMarkerIsRefusedAsAllocationFailure) {
auto d = parse(
"mcpp:action={\"id\":\"wide\",\"role\":\"source\","
"\"description\":\"\",\"blocking\":false,\"overflow\":true,"
"\"inputs\":[],\"outputs\":[\"out/a.txt\"],"
"\"command\":[\"gen\"],\"provides\":[],\"imports\":[],\"targets\":[]}\n");
auto err = dirs::action_error(d);
ASSERT_FALSE(err.empty());
EXPECT_NE(err.find("could not be stored"), std::string::npos);
EXPECT_NE(err.find("out of memory"), std::string::npos);
EXPECT_EQ(err.find("fixed buffer"), std::string::npos);
EXPECT_EQ(err.find("response file"), std::string::npos);
EXPECT_EQ(err.find("did not fit"), std::string::npos);
}
// ── #618: a named executable's subsystem and entry ──────────────────────────
//
// `windows-subsystem` and `windows-entry` name a target of the package being
// built. What is asserted: the value reaches that target's fields and nothing
// else, and every value `apply` could not honour is refused before it runs.
namespace {
mcpp::manifest::Manifest manifest_with_gui_and_core() {
mcpp::manifest::Manifest m;
m.package.name = "app";
mcpp::manifest::Target gui;
gui.name = "gui";
gui.kind = mcpp::manifest::Target::Binary;
mcpp::manifest::Target core;
core.name = "core";
core.kind = mcpp::manifest::Target::Library;
m.targets = {gui, core};
return m;
}
} // namespace
TEST(BuildDirectives, WindowsSubsystemReachesTheNamedExecutableOnly) {
auto d = parse("mcpp:protocol=10\n"
"mcpp:windows-subsystem=gui:windows\n"
"mcpp:windows-entry=gui:wWinMain\n");
ASSERT_FALSE(dirs::protocol_error(d).has_value());
auto m = manifest_with_gui_and_core();
ASSERT_EQ(dirs::target_directive_error(m, d), "");
dirs::apply(m, d);
EXPECT_EQ(m.targets[0].windowsSubsystem, "windows");
EXPECT_EQ(m.targets[0].windowsEntry, "wWinMain");
EXPECT_TRUE(m.targets[1].windowsSubsystem.empty());
EXPECT_TRUE(m.targets[1].windowsEntry.empty());
// Nothing reaches a flag channel another target or a consumer reads.
EXPECT_TRUE(m.buildConfig.ldflags.empty());
EXPECT_TRUE(m.buildConfig.cxxflags.empty());
}
// #622 A3: `windows-subsystem`/`windows-entry` reach an `app` target exactly
// as they reach a `bin` one -- `directives.cppm`'s `apply` and
// `target_directive_error` ask `is_program()`, not `kind == Binary`.
TEST(BuildDirectives, WindowsSubsystemReachesAnApplicationTargetToo) {
mcpp::manifest::Manifest m;
m.package.name = "app";
mcpp::manifest::Target myapp;
myapp.name = "myapp";
myapp.kind = mcpp::manifest::Target::Application;
m.targets = {myapp};
auto d = parse("mcpp:protocol=10\n"
"mcpp:windows-subsystem=myapp:windows\n"
"mcpp:windows-entry=myapp:wWinMain\n");
ASSERT_EQ(dirs::target_directive_error(m, d), "");
dirs::apply(m, d);
EXPECT_EQ(m.targets[0].windowsSubsystem, "windows");
EXPECT_EQ(m.targets[0].windowsEntry, "wWinMain");
}
TEST(BuildDirectives, WindowsSubsystemRowsHaveTheTargetLinkScope) {
for (auto wire : {"windows-subsystem", "windows-entry"}) {
auto def = dirs::find_by_wire(wire);
ASSERT_NE(def, nullptr) << wire;
EXPECT_EQ(def->scope, dirs::Scope::TargetLink) << wire;
EXPECT_EQ(def->sinceProtocol, 10) << wire;
EXPECT_FALSE(def->tag.empty()) << wire;
}
}
TEST(BuildDirectives, WindowsSubsystemRefusesWhatApplyCannotHonour) {
const std::pair<std::string_view, std::string_view> cases[] = {
{"mcpp:windows-subsystem=windows\n", "which is not `<target>:<value>`"},
{"mcpp:windows-subsystem=gui:\n", "which is not `<target>:<value>`"},
{"mcpp:windows-subsystem=gui:gui\n", "\"gui\" is not one of \"console\", \"windows\""},
{"mcpp:windows-entry=gui:main2\n",
"\"main2\" is not one of \"main\", \"wmain\", \"WinMain\", \"wWinMain\""},
{"mcpp:windows-subsystem=nosuch:windows\n",
"declares no target named `nosuch` (its targets: gui, core)"},
{"mcpp:windows-entry=core:wmain\n", "target `core` is not one"},
{"mcpp:windows-subsystem=gui:windows\nmcpp:windows-subsystem=gui:console\n",
"twice for target `gui`, as \"windows\" and as \"console\""},
};
for (auto [text, expected] : cases) {
auto d = parse(std::format("mcpp:protocol=10\n{}", text));
auto err = dirs::target_directive_error(manifest_with_gui_and_core(), d);
EXPECT_NE(err.find(expected), std::string::npos) << text << " -> " << err;
}
}
TEST(BuildDirectives, WindowsSubsystemThatContradictsTheManifestIsRefused) {
auto m = manifest_with_gui_and_core();
m.targets[0].windowsSubsystem = "console";
auto d = parse("mcpp:protocol=10\nmcpp:windows-subsystem=gui:windows\n");
auto err = dirs::target_directive_error(m, d);
EXPECT_NE(err.find("[targets.gui] windows_subsystem = \"console\""), std::string::npos)
<< err;
// Restating the manifest's own value is not a contradiction.
m.targets[0].windowsSubsystem = "windows";
EXPECT_EQ(dirs::target_directive_error(m, d), "");
}
// ── #622 A4: `mcpp::deploy(from, to)` ───────────────────────────────────────
//
// The build-program form of `[runtime] deploy` (#615): a file this program
// produced or selected, placed beside the artifact at `to`. What is asserted:
// `from` is resolved to an absolute path at PARSE time (so a package-relative
// `from` and an already-absolute one, an action's own declared output, land on
// the manifest the same way); `to` obeys the same rule the manifest key does,
// checked BEFORE `apply` so a bad value is refused on every replay, not only
// the run that first emitted it.
namespace {
mcpp::manifest::Manifest manifest_named(std::string name) {
mcpp::manifest::Manifest m;
m.package.name = std::move(name);
return m;
}
} // namespace
TEST(BuildDirectives, DeployRowIsProtocolElevenWithLinkGlobalScopeAndATag) {
auto def = dirs::find_by_wire("deploy");
ASSERT_NE(def, nullptr);
EXPECT_EQ(def->scope, dirs::Scope::LinkGlobal);
EXPECT_EQ(def->sinceProtocol, 11);
EXPECT_FALSE(def->tag.empty());
EXPECT_EQ(dirs::kProtocolVersion, 11);
}
TEST(BuildDirectives, ProtocolElevenIsAcceptedAndTwelveIsNot) {
auto ok = parse("mcpp:protocol=11\n");
EXPECT_FALSE(dirs::protocol_error(ok).has_value());
auto no = parse("mcpp:protocol=12\n");
EXPECT_TRUE(dirs::protocol_error(no).has_value());
}
TEST(BuildDirectives, DeployWithAnAbsoluteFromYieldsOneEntryOnTheManifest) {
const std::string from = under_root("gen/x.bin");
auto d = parse(std::format("mcpp:deploy={}\tres\n", from));
auto m = manifest_named("app");
ASSERT_EQ(dirs::deploy_directive_error(m, d), "");
dirs::apply(m, d);
ASSERT_EQ(m.runtimeConfig.linkIntent.deploy.size(), 1u);
EXPECT_EQ(m.runtimeConfig.linkIntent.deploy[0].from.string(), from);
EXPECT_EQ(m.runtimeConfig.linkIntent.deploy[0].to, "res");
}
// The manifest-sourced `from` rule (`deploy_path_problem`) refuses an absolute
// path. A directive's `from` is not run through that check at all: it is
// resolved to an absolute path by the table's own transform instead, because
// it may be an action's own declared output (#622 A4). This is the case that
// rule cannot see and must not reject.
TEST(BuildDirectives, DeployFromIsResolvedToAbsoluteEvenWhenTheWireValueAlreadyWasOne) {
const std::string absFrom = under_root("out/gen/res.bin");
auto d = parse(std::format("mcpp:deploy={}\tapp.resources\n", absFrom));
auto m = manifest_named("app");
EXPECT_EQ(dirs::deploy_directive_error(m, d), "");
dirs::apply(m, d);
ASSERT_EQ(m.runtimeConfig.linkIntent.deploy.size(), 1u);
EXPECT_EQ(m.runtimeConfig.linkIntent.deploy[0].from.string(), absFrom);
}
// A relative `from` resolves against the package root, exactly as
// `include-dir`'s AbsPath case does — the directive never leaves a relative
// path for a later stage to guess the base of.
TEST(BuildDirectives, DeployFromRelativeToTheRootIsMadeAbsolute) {
auto d = parse("mcpp:deploy=gen/x.bin\tres\n");
auto m = manifest_named("app");
ASSERT_EQ(dirs::deploy_directive_error(m, d), "");
dirs::apply(m, d);
ASSERT_EQ(m.runtimeConfig.linkIntent.deploy.size(), 1u);
EXPECT_EQ(m.runtimeConfig.linkIntent.deploy[0].from.string(), under_root("gen/x.bin"));
}
// The negative direction (#622 A4, and rule 8 of the design record): a `to`
// `apply` cannot honour is refused BEFORE apply, naming the directive and the
// package -- not only the path problem, which `deploy_path_problem` already
// states on its own.
TEST(BuildDirectives, DeployToDotDotIsRefusedNamingTheDirectiveAndThePackage) {
auto d = parse(std::format("mcpp:deploy={}\t../x\n", under_root("gen/x.bin")));
auto m = manifest_named("widget");
auto err = dirs::deploy_directive_error(m, d);
EXPECT_NE(err.find("deploy"), std::string::npos) << err;
EXPECT_NE(err.find("widget"), std::string::npos) << err;
EXPECT_NE(err.find("`.` or `..` component"), std::string::npos) << err;
}
TEST(BuildDirectives, DeployWithAMalformedWireValueIsRefused) {
auto d = parse("mcpp:deploy=onlyfromnotab\n");
auto m = manifest_named("app");
auto err = dirs::deploy_directive_error(m, d);
EXPECT_NE(err.find("deploy"), std::string::npos) << err;
EXPECT_NE(err.find("not `<from>"), std::string::npos) << err;
}
// A `to` that IS honourable does not stop the build, and the collected entry
// is the only thing `apply` touches -- no flag channel gains anything, unlike
// nothing here (deploy is not a compile/link flag).
TEST(BuildDirectives, DeployReachesOnlyTheRuntimeDeployListNotAnyFlagChannel) {
auto d = parse(std::format("mcpp:deploy={}\t.\n", under_root("gen/x.bin")));
auto m = manifest_named("app");
ASSERT_EQ(dirs::deploy_directive_error(m, d), "");
dirs::apply(m, d);
ASSERT_EQ(m.runtimeConfig.linkIntent.deploy.size(), 1u);
EXPECT_EQ(m.runtimeConfig.linkIntent.deploy[0].to, ".");
EXPECT_TRUE(m.buildConfig.ldflags.empty());
EXPECT_TRUE(m.buildConfig.cxxflags.empty());
}