Skip to content

Commit b7d4a96

Browse files
add skip command
1 parent 8e8ef9d commit b7d4a96

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ The Pizza Test CLI provides an efficient way to run and manage tests directly fr
8686
|----------------------|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
8787
| `--fail-fast` | Stop on the first failure. | Useful for quickly identifying and addressing critical issues. |
8888
| `--only <test>` | Run only the specified test. | Focuses execution on a single test for debugging or validation purposes. |
89+
| `--skip <test>` | Skip the specified test. | Allows excluding specific tests from execution. |
8990
| `--repeat <count>` | Repeat the test a specified number of times. | Useful for stress testing or verifying consistency across multiple runs. |
9091
| `--help` | Show help for the run command. | Provides detailed usage instructions for the `run` command. |
9192
### Filter Command Options

code/logic/common.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static void _show_subhelp_run(void) {
9191
pizza_io_printf("{blue}Run command options:{reset}\n");
9292
pizza_io_printf("{cyan} --fail-fast Stop on the first failure{reset}\n");
9393
pizza_io_printf("{cyan} --only <test> Run only the specified test{reset}\n");
94+
pizza_io_printf("{cyan} --skip <test> Skip the specified test{reset}\n");
9495
pizza_io_printf("{cyan} --repeat <count> Repeat the test a specified number of times{reset}\n");
9596
pizza_io_printf("{cyan} --help Show help for run command{reset}\n");
9697
exit(EXIT_SUCCESS);
@@ -201,7 +202,8 @@ static void _show_host(void) {
201202

202203
fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
203204
fossil_pizza_pallet_t pallet = {0};
204-
205+
int is_command = 0; // Variable to track if a command is being processed
206+
205207
// Parse command-line arguments
206208
for (int i = 1; i < argc; i++) {
207209
if (pizza_io_cstr_compare(argv[i], "--dry-run") == 0) {
@@ -213,12 +215,14 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
213215
} else if (pizza_io_cstr_compare(argv[i], "--host") == 0) {
214216
_show_host();
215217
} else if (pizza_io_cstr_compare(argv[i], "run") == 0) {
218+
is_command = 1;
216219
pallet.run.fail_fast = 0;
217220
pallet.run.only = null;
218221
pallet.run.skip = null;
219222
pallet.run.repeat = 1;
220223

221224
for (int j = i + 1; j < argc; j++) {
225+
if (!is_command) break;
222226
if (pizza_io_cstr_compare(argv[j], "--fail-fast") == 0) {
223227
pallet.run.fail_fast = 1;
224228
G_PIZZA_FAIL_FAST = 1;
@@ -235,15 +239,17 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
235239
} else if (pizza_io_cstr_compare(argv[j], "--help") == 0) {
236240
_show_subhelp_run();
237241
} else {
238-
break;
242+
is_command = 0;
239243
}
240244
}
241245
} else if (pizza_io_cstr_compare(argv[i], "filter") == 0) {
246+
is_command = 1;
242247
pallet.filter.test_name = null;
243248
pallet.filter.suite_name = null;
244249
pallet.filter.tag = null;
245250

246251
for (int j = i + 1; j < argc; j++) {
252+
if (!is_command) break;
247253
if (pizza_io_cstr_compare(argv[j], "--test-name") == 0 && j + 1 < argc) {
248254
pallet.filter.test_name = argv[++j];
249255
} else if (pizza_io_cstr_compare(argv[j], "--suite-name") == 0 && j + 1 < argc) {
@@ -272,14 +278,16 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
272278
}
273279
exit(EXIT_SUCCESS);
274280
} else {
275-
break;
281+
is_command = 0;
276282
}
277283
}
278284
} else if (pizza_io_cstr_compare(argv[i], "sort") == 0) {
285+
is_command = 1;
279286
pallet.sort.by = null;
280287
pallet.sort.order = null;
281288

282289
for (int j = i + 1; j < argc; j++) {
290+
if (!is_command) break;
283291
if (pizza_io_cstr_compare(argv[j], "--by") == 0 && j + 1 < argc) {
284292
const char* criteria = argv[++j];
285293
int is_valid_criteria = 0;
@@ -306,15 +314,17 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
306314
}
307315
exit(EXIT_SUCCESS);
308316
} else {
309-
break;
317+
is_command = 0;
310318
}
311319
}
312320
} else if (pizza_io_cstr_compare(argv[i], "shuffle") == 0) {
321+
is_command = 1;
313322
pallet.shuffle.seed = null;
314323
pallet.shuffle.count = 0;
315324
pallet.shuffle.by = null;
316325

317326
for (int j = i + 1; j < argc; j++) {
327+
if (!is_command) break;
318328
if (pizza_io_cstr_compare(argv[j], "--seed") == 0 && j + 1 < argc) {
319329
pallet.shuffle.seed = argv[++j];
320330
} else if (pizza_io_cstr_compare(argv[j], "--count") == 0 && j + 1 < argc) {
@@ -330,7 +340,7 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
330340
}
331341
exit(EXIT_SUCCESS);
332342
} else {
333-
break;
343+
is_command = 0;
334344
}
335345
}
336346
} else if (strncmp(argv[i], "color=", 6) == 0) {

0 commit comments

Comments
 (0)