Skip to content

Commit 95b0327

Browse files
Merge pull request #129 from dreamer-coding/add_show
Add show
2 parents 00cb845 + ec35ab9 commit 95b0327

File tree

5 files changed

+504
-226
lines changed

5 files changed

+504
-226
lines changed

.github/workflows/meson_ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
run: meson setup builddir_msvc_${{ matrix.msvc_version }} --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3
5858

5959
- name: Run Tests
60-
run: meson test -C builddir_msvc_${{ matrix.msvc_version }} -v --test-args='verbose=ci'
60+
run: meson test -C builddir_msvc_${{ matrix.msvc_version }} -v --test-args='show --mode tree --verbose ci --result fail'
6161

6262
build_macosx:
6363
name: Building on macOS with Xcode ${{ matrix.xcode_version }}
@@ -87,7 +87,7 @@ jobs:
8787
run: meson setup builddir --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3
8888

8989
- name: Run Tests
90-
run: meson test -C builddir -v --test-args='verbose=ci'
90+
run: meson test -C builddir -v --test-args='show --mode tree --verbose ci --result fail'
9191

9292
build_msys:
9393
name: Building on MSYS ${{ matrix.architecture }}
@@ -124,7 +124,7 @@ jobs:
124124
run: meson setup builddir --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3
125125

126126
- name: Run Tests
127-
run: meson test -C builddir -v --test-args='verbose=ci'
127+
run: meson test -C builddir -v --test-args='show --mode tree --verbose ci --result fail'
128128

129129
build_mingw:
130130
name: Building on MinGW ${{ matrix.architecture }}
@@ -165,7 +165,7 @@ jobs:
165165
run: meson setup builddir --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3
166166

167167
- name: Run Tests
168-
run: meson test -C builddir -v --test-args='verbose=ci'
168+
run: meson test -C builddir -v --test-args='show --mode tree --verbose ci --result fail'
169169

170170
build_posix:
171171
name: Build on Linux ${{ matrix.distro }}
@@ -207,7 +207,7 @@ jobs:
207207
/bin/bash -c "
208208
sudo apt update
209209
meson setup builddir --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3
210-
meson test -C builddir -v --test-args='verbose=ci'"
210+
meson test -C builddir -v --test-args='show --mode tree --verbose ci --result fail'"
211211
212212
build_cross:
213213
name: Building on Bedrock ${{ matrix.architecture }}
@@ -305,5 +305,5 @@ jobs:
305305
306306
- name: Test the Project
307307
run: |
308-
meson test -C builddir -v --test-args='verbose=ci'
308+
meson test -C builddir -v --test-args='show --mode tree --verbose ci --result fail'
309309

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,16 @@ The Pizza Test CLI provides an efficient way to run and manage tests directly fr
8181
| `verbose=<level>` | Set verbosity level (plain, ci, doge). | Adjusts the level of detail in test output. |
8282
| `timeout=<seconds>` | Set a timeout for test execution. | Ensures tests do not exceed the specified duration, helping to identify long-running tests. |
8383

84-
### Run Command Options
84+
### Show Command Options
85+
| Option | Description | Notes |
86+
|--------------------------|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
87+
| `--test-name <name>` | Filter by test name. | Enables precise targeting of individual tests to show. |
88+
| `--suite-name <name>` | Filter by suite name. | Useful for displaying all tests within a specific suite. |
89+
| `--tag <tag>` | Filter by tag. | Allows grouping and showing tests based on custom tags. |
90+
| `--result <result>` | Filter by result (`empty`, `pass`, `fail`, `timeout`, `skipped`, `unexpected`). | Show tests based on their execution result. |
91+
| `--verbose <level>` | Set verbosity level (`plain`, `ci`, `doge`). | Adjusts the level of detail in the output. |
92+
| `--mode <mode>` | Show mode (`list`, `tree`, `graph`). | Controls the format in which test cases are displayed. |
93+
8594
| Option | Description | Notes |
8695
|----------------------|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
8796
| `--fail-fast` | Stop on the first failure. | Useful for quickly identifying and addressing critical issues. |

code/logic/common.c

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const char* G_PIZZA_ONLY = null;
3535
int G_PIZZA_REPEAT = 0;
3636
int G_PIZZA_THREADS = 1;
3737
fossil_pizza_cli_theme_t G_PIZZA_THEME = PIZZA_THEME_FOSSIL;
38-
fossil_pizza_cli_verbose_t G_PIZZA_VERBOSE = PIZZA_VERBOSE_PLAIN;
3938

4039
// *****************************************************************************
4140
// command pallet
@@ -61,8 +60,6 @@ static const char* VALID_CRITERIA[] = {
6160
null // Sentinel to mark the end
6261
};
6362

64-
// TODO add --options flag to show all options for commands that take options such as color or theme
65-
6663
static void _show_help(void) {
6764
pizza_io_printf("{blue}Usage: pizza [options] [command]{reset}\n");
6865
pizza_io_printf("{blue}Options:{reset}\n");
@@ -75,10 +72,10 @@ static void _show_help(void) {
7572
pizza_io_printf("{cyan} filter Filter tests based on criteria{reset}\n");
7673
pizza_io_printf("{cyan} sort Sort tests by specified criteria{reset}\n");
7774
pizza_io_printf("{cyan} shuffle Shuffle tests with optional parameters{reset}\n");
75+
pizza_io_printf("{cyan} show Show test cases with optional parameters{reset}\n");
7876
pizza_io_printf("{cyan} color=<mode> Set color mode (enable, disable, auto){reset}\n");
7977
pizza_io_printf("{cyan} config=<file> Specify a configuration file (must be pizza_test.ini){reset}\n");
8078
pizza_io_printf("{cyan} theme=<name> Set the theme (fossil, catch, doctest, etc.){reset}\n");
81-
pizza_io_printf("{cyan} verbose=<level> Set verbosity level (plain, ci, doge){reset}\n");
8279
pizza_io_printf("{cyan} timeout=<seconds> Set the timeout for commands (default: 60 seconds){reset}\n");
8380
exit(EXIT_SUCCESS);
8481
}
@@ -155,11 +152,14 @@ static void _show_subhelp_theme(void) {
155152
exit(EXIT_SUCCESS);
156153
}
157154

158-
static void _show_subhelp_verbose(void) {
159-
pizza_io_printf("{blue}Verbose command options:{reset}\n");
160-
pizza_io_printf("{cyan} plain Plain output{reset}\n");
161-
pizza_io_printf("{cyan} ci Continuous Integration output{reset}\n");
162-
pizza_io_printf("{cyan} doge High-transparency verbose output{reset}\n");
155+
static void _show_subhelp_show(void) {
156+
pizza_io_printf("{blue}Show command options:{reset}\n");
157+
pizza_io_printf("{cyan} --test-name <name> Filter by test name{reset}\n");
158+
pizza_io_printf("{cyan} --suite-name <name> Filter by suite name{reset}\n");
159+
pizza_io_printf("{cyan} --tag <tag> Filter by tag{reset}\n");
160+
pizza_io_printf("{cyan} --result <result> Filter by result (pass, fail, timeout, skipped, unexpected){reset}\n");
161+
pizza_io_printf("{cyan} --verbose <level> Set verbosity level (plain, ci, doge){reset}\n");
162+
pizza_io_printf("{cyan} --mode <mode> Show mode (list, tree, graph){reset}\n");
163163
exit(EXIT_SUCCESS);
164164
}
165165

@@ -168,8 +168,6 @@ static void _show_version(void) {
168168
exit(EXIT_SUCCESS);
169169
}
170170

171-
// TODO add architecture and CPU information
172-
173171
static void _show_host(void) {
174172
pizza_sys_hostinfo_system_t system_info;
175173
pizza_sys_hostinfo_memory_t memory_info;
@@ -214,6 +212,8 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
214212
fossil_pizza_pallet_t pallet = {0};
215213
int is_command = 0; // Variable to track if a command is being processed
216214

215+
pallet.show.enabled = 0; // Initialize show command enabled flag
216+
217217
// Parse command-line arguments
218218
for (int i = 1; i < argc; i++) {
219219
if (pizza_io_cstr_compare(argv[i], "--dry-run") == 0) {
@@ -416,29 +416,57 @@ fossil_pizza_pallet_t fossil_pizza_pallet_create(int argc, char** argv) {
416416
if (i + 1 < argc && pizza_io_cstr_compare(argv[i + 1], "--help") == 0) {
417417
_show_subhelp_theme();
418418
}
419-
} else if (strncmp(argv[i], "verbose=", 8) == 0) {
420-
const char* verbose_str = argv[i] + 8;
421-
if (pizza_io_cstr_compare(verbose_str, "plain") == 0) {
422-
pallet.verbose = PIZZA_VERBOSE_PLAIN;
423-
G_PIZZA_VERBOSE = PIZZA_VERBOSE_PLAIN;
424-
} else if (pizza_io_cstr_compare(verbose_str, "ci") == 0) {
425-
pallet.verbose = PIZZA_VERBOSE_CI;
426-
G_PIZZA_VERBOSE = PIZZA_VERBOSE_CI;
427-
} else if (pizza_io_cstr_compare(verbose_str, "doge") == 0) {
428-
pallet.verbose = PIZZA_VERBOSE_DOGE;
429-
G_PIZZA_VERBOSE = PIZZA_VERBOSE_DOGE;
430-
}
431-
} else if (pizza_io_cstr_compare(argv[i], "verbose") == 0) {
432-
if (i + 1 < argc && pizza_io_cstr_compare(argv[i + 1], "--help") == 0) {
433-
_show_subhelp_verbose();
434-
}
435419
} else if (strncmp(argv[i], "timeout=", 8) == 0) {
436420
G_PIZZA_TIMEOUT = atoi(argv[i] + 8);
437421
} else if (pizza_io_cstr_compare(argv[i], "timeout") == 0) {
438422
if (i + 1 < argc && pizza_io_cstr_compare(argv[i + 1], "--help") == 0) {
439423
_show_help();
440424
exit(EXIT_SUCCESS);
441425
}
426+
} else if (pizza_io_cstr_compare(argv[i], "show") == 0) {
427+
is_command = 1;
428+
pallet.show.test_name = null;
429+
pallet.show.suite_name = null;
430+
pallet.show.tag = null;
431+
pallet.show.result = "fail";
432+
pallet.show.mode = "list";
433+
pallet.show.verbose = "plain";
434+
pallet.show.enabled = 1; // Default to enabled
435+
436+
for (int j = i + 1; j < argc; j++) {
437+
if (!is_command) break;
438+
if (pizza_io_cstr_compare(argv[j], "--test-name") == 0 && j + 1 < argc) {
439+
pallet.show.test_name = argv[++j];
440+
} else if (pizza_io_cstr_compare(argv[j], "--suite-name") == 0 && j + 1 < argc) {
441+
pallet.show.suite_name = argv[++j];
442+
} else if (pizza_io_cstr_compare(argv[j], "--tag") == 0 && j + 1 < argc) {
443+
pallet.show.tag = argv[++j];
444+
} else if (pizza_io_cstr_compare(argv[j], "--result") == 0 && j + 1 < argc) {
445+
pallet.show.result = argv[++j];
446+
} else if (pizza_io_cstr_compare(argv[j], "--mode") == 0 && j + 1 < argc) {
447+
pallet.show.mode = argv[++j];
448+
// Validate mode (should be one of: list, tree, graph)
449+
if (pizza_io_cstr_compare(pallet.show.mode, "list") != 0 &&
450+
pizza_io_cstr_compare(pallet.show.mode, "tree") != 0 &&
451+
pizza_io_cstr_compare(pallet.show.mode, "graph") != 0) {
452+
pizza_io_printf("{red}Error: Invalid mode '%s'. Valid modes are: list, tree, graph.{reset}\n", pallet.show.mode);
453+
exit(EXIT_FAILURE);
454+
}
455+
} else if (pizza_io_cstr_compare(argv[j], "--verbose") == 0 && j + 1 < argc) {
456+
pallet.show.verbose = argv[++j];
457+
// Validate verbose (should be one of: plain, ci, doge)
458+
if (pizza_io_cstr_compare(pallet.show.verbose, "plain") != 0 &&
459+
pizza_io_cstr_compare(pallet.show.verbose, "ci") != 0 &&
460+
pizza_io_cstr_compare(pallet.show.verbose, "doge") != 0) {
461+
pizza_io_printf("{red}Error: Invalid verbose level '%s'. Valid levels are: plain, ci, doge.{reset}\n", pallet.show.verbose);
462+
exit(EXIT_FAILURE);
463+
}
464+
} else if (pizza_io_cstr_compare(argv[j], "--help") == 0) {
465+
_show_subhelp_show();
466+
} else {
467+
is_command = 0;
468+
}
469+
}
442470
}
443471
}
444472

@@ -535,14 +563,6 @@ int fossil_pizza_ini_parse(const char *filename, fossil_pizza_pallet_t *pallet)
535563
} else if (pizza_io_cstr_compare(value, "unity") == 0) {
536564
pallet->theme = PIZZA_THEME_UNITY;
537565
}
538-
} else if (pizza_io_cstr_compare(key, "verbose") == 0) {
539-
if (pizza_io_cstr_compare(value, "plain") == 0) {
540-
pallet->verbose = PIZZA_VERBOSE_PLAIN;
541-
} else if (pizza_io_cstr_compare(value, "ci") == 0) {
542-
pallet->verbose = PIZZA_VERBOSE_CI;
543-
} else if (pizza_io_cstr_compare(value, "doge") == 0) {
544-
pallet->verbose = PIZZA_VERBOSE_DOGE;
545-
}
546566
}
547567
} else if (pizza_io_cstr_compare(section, "test") == 0) {
548568
if (pizza_io_cstr_compare(key, "run.fail_fast") == 0) {

code/logic/fossil/pizza/common.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,18 @@ typedef struct {
224224
int count; // Value for --count
225225
const char* by; // Value for --by
226226
} shuffle; // Shuffle command flags
227+
228+
struct {
229+
const char* test_name; // Name of the test case to show
230+
const char* suite_name; // Name of the suite to show
231+
const char* tag; // Tag to filter which test cases to show
232+
const char* result; // Result to filter which test cases to show
233+
const char* mode; // Mode to filter which test cases to show (e.g., tree, list, graph)
234+
const char* verbose; // Verbosity level (plain, ci, doge)
235+
int enabled; // Flag to enable showing test cases
236+
} show; // Show command flags
237+
227238
fossil_pizza_cli_theme_t theme; // Theme option
228-
fossil_pizza_cli_verbose_t verbose; // Verbose option
229239
} fossil_pizza_pallet_t;
230240

231241
// *****************************************************************************
@@ -239,7 +249,6 @@ extern int G_PIZZA_SKIP;
239249
extern const char* G_PIZZA_ONLY;
240250
extern int G_PIZZA_REPEAT;
241251
extern fossil_pizza_cli_theme_t G_PIZZA_THEME;
242-
extern fossil_pizza_cli_verbose_t G_PIZZA_VERBOSE;
243252

244253
/**
245254
* @brief Parses command line arguments and populates the pallet structure.

0 commit comments

Comments
 (0)