Skip to content

Commit

Permalink
Add real example test and update README for preset usage
Browse files Browse the repository at this point in the history
Added a new test in ReadmeTest to check if real examples of preset usage are correctly inserted in README. Updated README to offer users more detailed real-life example showcasing the benefits and scalability of using presets. The example is presented in an expandable details section for improved readability.
  • Loading branch information
SmetDenis committed Apr 6, 2024
1 parent 492a118 commit 912fd8e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ You can find launch examples in the [workflow demo](https://github.com/JBZoo/Csv
# Add flag `--profile` if you want to see profiling info. Add details with `-vvv`.
# Add flag `--debug` if you want to see more really deep details.
# Add flag `--dump-schema` if you want to see the final schema after all includes and inheritance.
# Default value: 'extra: --ansi'
# Default value: 'options: --ansi'
# You can skip it.
extra: 'extra: --ansi'
extra: 'options: --ansi'
```
<!-- auto-update:/github-actions-yml -->

Expand Down Expand Up @@ -1645,12 +1645,10 @@ However, to gain a general understanding of performance, refer to the table belo

Profiles:

- **[Quickest:](tests/Benchmarks/bench_0_quickest_combo.yml)** Focuses on the fastest rules, either cell or aggregation, providing a baseline for maximum throughput.
- **[Minimum:](tests/Benchmarks/bench_1_mini_combo.yml)** Uses a set of normal performance rules, with two instances of each, to simulate a lightweight validation
scenario.
- **[Realistic:](tests/Benchmarks/bench_2_realistic_combo.yml)** Represents a mix of rules likely encountered in typical use cases, offering a balanced view of
performance.
- **[All Aggregations:](tests/Benchmarks/bench_3_all_agg.yml)** Tests all aggregation rules simultaneously, illustrating the tool's behavior under maximum load.
- **[Quickest:](tests/Benchmarks/bench_0_quickest_combo.yml)** Focuses on the fastest rules, either cell or aggregation, providing a baseline.
- **[Minimum:](tests/Benchmarks/bench_1_mini_combo.yml)** Uses a set of normal performance rules, with two instances of each.
- **[Realistic:](tests/Benchmarks/bench_2_realistic_combo.yml)** Represents a mix of rules likely encountered in typical use cases.
- **[All Aggregations:](tests/Benchmarks/bench_3_all_agg.yml)** Tests all aggregation rules simultaneously, illustrating maximum load.

Divisions:

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ inputs:
Add flag `--profile` if you want to see profiling info. Add details with `-vvv`.
Add flag `--debug` if you want to see more really deep details.
Add flag `--dump-schema` if you want to see the final schema after all includes and inheritance.
default: 'extra: --ansi'
default: 'options: --ansi'

runs:
using: 'docker'
Expand Down
4 changes: 2 additions & 2 deletions src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ public static function fixArgv(array $originalArgs): array
continue;
}

if (\str_starts_with($argValue, 'extra:')) {
$extraArgs = \str_replace('extra:', '', $argValue);
if (\str_starts_with($argValue, 'extra:') || \str_starts_with($argValue, 'options:')) {
$extraArgs = \str_replace(['extra:', 'options:'], '', $argValue);
$flags = \array_filter(
\array_map('trim', \explode(' ', $extraArgs)),
static fn ($flag): bool => $flag !== '',
Expand Down
2 changes: 1 addition & 1 deletion tests/GithubActionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testGitHubActionsReadMe(): void
'report' => "'" . ErrorSuite::REPORT_DEFAULT . "'",
'quick' => "'no'",
'skip-schema' => "'no'",
'extra' => "'extra: --ansi'",
'extra' => "'options: --ansi'",
];

$expectedMessage = [
Expand Down
16 changes: 11 additions & 5 deletions tests/UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testColorsTags(): void
'i|c|q|e' .
'|comment|info|error|question' .
'|black|red|green|yellow|blue|magenta|cyan|white|default' .
'|bl|b|u|r|bg'.
'|bl|b|u|r|bg' .
'|details|summary',
);

Expand Down Expand Up @@ -158,20 +158,26 @@ public function testFixCliArguments(): void

isSame(
['cmd', '-h', '--ansi'],
Utils::fixArgv(['cmd', '', ' -h ', 'extra: --ansi']),
Utils::fixArgv(['cmd', '', ' -h ', 'options: --ansi']),
);
isSame(
['cmd', '-h'],
Utils::fixArgv(['cmd', '', ' -h ', 'extra:']),
Utils::fixArgv(['cmd', '', ' -h ', 'options:']),
);
isSame(
['cmd', '-h'],
Utils::fixArgv(['cmd', '', ' -h ', ' extra: ']),
Utils::fixArgv(['cmd', '', ' -h ', ' options: ']),
);
isSame(
['cmd', '-h', '--ansi', '--no'],
Utils::fixArgv(['cmd', '', ' -h ', 'extra: --ansi --no']),
Utils::fixArgv(['cmd', '', ' -h ', 'options: --ansi --no']),
);
isSame(
['cmd', '-h', '--ansi', '--no'],
Utils::fixArgv(['cmd', '', ' -h ', 'options: --ansi --no ']),
);

// Test legacy "extra:"
isSame(
['cmd', '-h', '--ansi', '--no'],
Utils::fixArgv(['cmd', '', ' -h ', 'extra: --ansi --no ']),
Expand Down

0 comments on commit 912fd8e

Please sign in to comment.