@@ -174,6 +174,8 @@ inline bool ends_with(std::string_view str, std::string_view with) {
174
174
return str.substr (str.size () - with.size (), with.size ()) == with;
175
175
}
176
176
177
+ constexpr std::string_view default_cmd_suffix = " ASDFG" ;
178
+
177
179
struct TempFileScanTest : public TempFileTest {
178
180
private:
179
181
cppm::ScanItemSet item_set;
@@ -224,7 +226,8 @@ struct TempFileScanTest : public TempFileTest {
224
226
.target_idx = target_idx,
225
227
.is_header_unit = ends_with (file, " .h" )
226
228
});
227
- std::string cmd = fmt::format (" {} /Fo\" {}.{}.obj\" " , default_command, file, item_set.targets [target_idx]);
229
+ std::string cmd = fmt::format (" {} /Fo\" {}.{}.obj\" /D {}" ,
230
+ default_command, file, item_set.targets [target_idx], default_cmd_suffix);
228
231
item_set.commands .emplace_back (std::move (cmd));
229
232
}
230
233
@@ -240,6 +243,16 @@ struct TempFileScanTest : public TempFileTest {
240
243
add_item (file, target_idx);
241
244
}
242
245
246
+ void set_command_suffix (cppm::scan_item_idx_t idx, std::string_view suffix) {
247
+ // by construction, cmd idx == item idx
248
+ std::string& cmd = item_set.commands [id_cast<cppm::cmd_idx_t >(idx)];
249
+ auto d_pos = cmd.rfind (" /D " );
250
+ assert (d_pos != std::string::npos);
251
+ auto prev_suffix_pos = d_pos + 3 ;
252
+ auto prev_suffix_length = cmd.size () - prev_suffix_pos;
253
+ cmd.replace (prev_suffix_pos, prev_suffix_length, suffix);
254
+ }
255
+
243
256
void scan () {
244
257
auto item_set_owned_view = cppm::ScanItemSetOwnedView::from (item_set);
245
258
auto item_set_view = cppm::ScanItemSetView::from (item_set_owned_view);
@@ -495,7 +508,13 @@ TEST_CASE("test1", "[scanner]") {
495
508
496
509
test.scan_check ({}); // no changes again
497
510
498
- // todo: test command changed
511
+ test.set_command_suffix (a, " TTRTETRRE" );
512
+ test.scan_check ({ a }); // the command changed for a
513
+ test.set_command_suffix (b, " JFDJD" );
514
+ test.set_command_suffix (a, default_cmd_suffix);
515
+ test.scan_check ({ a, b });
516
+ test.set_command_suffix (b, default_cmd_suffix);
517
+ test.scan_check ({ b });
499
518
}
500
519
}
501
520
@@ -717,7 +736,7 @@ export module c;
717
736
test.scan_check ({ a }, { a });
718
737
}
719
738
720
- #if 0
739
+ #if 0 // todo:
721
740
SECTION("missing modules") {
722
741
723
742
}
0 commit comments