Skip to content

Commit ade00fd

Browse files
refactor: change semantics to right exclusive
1 parent 48fff67 commit ade00fd

File tree

7 files changed

+10
-13
lines changed

7 files changed

+10
-13
lines changed

crates/moon/src/cli/bench.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ pub struct BenchSubcommand {
4141
#[clap(short, long, requires("package"))]
4242
pub file: Option<String>,
4343

44-
/// Run only the index-th test in the file. Accepts a single index or an inclusive
45-
/// range like `0-2`. Only valid when `--file` is also specified.
44+
/// Run only the index-th test in the file. Accepts a single index or a left-inclusive
45+
/// right-exclusive range like `0-2`. Only valid when `--file` is also specified.
4646
#[clap(short, long, requires("file"))]
4747
pub index: Option<TestIndexRange>,
4848

crates/moon/src/cli/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ pub struct TestSubcommand {
107107
#[clap(short, long)]
108108
pub file: Option<String>,
109109

110-
/// Run only the index-th test in the file. Accepts a single index or an inclusive
111-
/// range like `0-2`. Only valid when `--file` is also specified.
110+
/// Run only the index-th test in the file. Accepts a single index or a left-inclusive
111+
/// right-exclusive range like `0-2`. Only valid when `--file` is also specified.
112112
/// Implies `--include-skipped`.
113113
#[clap(short, long)]
114114
pub index: Option<TestIndexRange>,

crates/moon/tests/test_cases/test_filter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ fn test_moon_test_filter_index_range() {
836836
"-f",
837837
"hello.mbt",
838838
"-i",
839-
"0-1",
839+
"0-2",
840840
],
841841
),
842842
expect![[r#"

crates/moonutil/src/common.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,6 @@ impl FromStr for TestIndexRange {
596596
}
597597
let start = parse_index_bound(start, TestIndexRangeParseError::MissingStart)?;
598598
let end = parse_index_bound(end, TestIndexRangeParseError::MissingEnd)?;
599-
let end = end
600-
.checked_add(1)
601-
.ok_or(TestIndexRangeParseError::EndOverflow)?;
602599
if start >= end {
603600
return Err(TestIndexRangeParseError::InvalidRange);
604601
}

docs/dev/reference/tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Filtering is handled by `TestFilter` (`runtest/filter.rs`). It stores allowed
134134

135135
- `--index N` selects a single inline test (the index is taken from the generated
136136
metadata, displayed in failure output as `#N`).
137-
- `--index A-B` selects an inclusive range (end included).
137+
- `--index A-B` selects a left-inclusive right-exclusive range.
138138
- `--doc-index N` selects a single doc test block.
139139
- When a positional `PATH` points to a file, the indexes can be provided without an
140140
explicit `--file`. Otherwise, the CLI requires `--file` whenever `--index` or

docs/manual-zh/src/commands.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Test the current package
256256

257257
* `-p`, `--package <PACKAGE>` — Run test in the specified package
258258
* `-f`, `--file <FILE>` — Run test in the specified file. Only valid when `--package` is also specified
259-
* `-i`, `--index <INDEX>` — Run only the index-th test in the file. Accepts a single index or an inclusive range like `0-2`. Only valid when `--file` is also specified. Implies `--include-skipped`
259+
* `-i`, `--index <INDEX>` — Run only the index-th test in the file. Accepts a single index or a left-inclusive right-exclusive range like `0-2`. Only valid when `--file` is also specified. Implies `--include-skipped`
260260
* `--doc-index <DOC_INDEX>` — Run only the index-th doc test in the file. Only valid when `--file` is also specified. Implies `--include-skipped`
261261
* `-u`, `--update` — Update the test snapshot
262262
* `-l`, `--limit <LIMIT>` — Limit of expect test update passes to run, in order to avoid infinite loops
@@ -385,7 +385,7 @@ Run benchmarks in the current package
385385

386386
* `-p`, `--package <PACKAGE>` — Run test in the specified package
387387
* `-f`, `--file <FILE>` — Run test in the specified file. Only valid when `--package` is also specified
388-
* `-i`, `--index <INDEX>` — Run only the index-th test in the file. Accepts a single index or an inclusive range like `0-2`. Only valid when `--file` is also specified
388+
* `-i`, `--index <INDEX>` — Run only the index-th test in the file. Accepts a single index or a left-inclusive right-exclusive range like `0-2`. Only valid when `--file` is also specified
389389
* `--frozen` — Do not sync dependencies, assuming local dependencies are up-to-date
390390
* `--build-only` — Only build, do not bench
391391
* `--no-parallelize` — Run the benchmarks in a target backend sequentially

docs/manual/src/commands.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Test the current package
256256

257257
* `-p`, `--package <PACKAGE>` — Run test in the specified package
258258
* `-f`, `--file <FILE>` — Run test in the specified file. Only valid when `--package` is also specified
259-
* `-i`, `--index <INDEX>` — Run only the index-th test in the file. Accepts a single index or an inclusive range like `0-2`. Only valid when `--file` is also specified. Implies `--include-skipped`
259+
* `-i`, `--index <INDEX>` — Run only the index-th test in the file. Accepts a single index or a left-inclusive right-exclusive range like `0-2`. Only valid when `--file` is also specified. Implies `--include-skipped`
260260
* `--doc-index <DOC_INDEX>` — Run only the index-th doc test in the file. Only valid when `--file` is also specified. Implies `--include-skipped`
261261
* `-u`, `--update` — Update the test snapshot
262262
* `-l`, `--limit <LIMIT>` — Limit of expect test update passes to run, in order to avoid infinite loops
@@ -385,7 +385,7 @@ Run benchmarks in the current package
385385

386386
* `-p`, `--package <PACKAGE>` — Run test in the specified package
387387
* `-f`, `--file <FILE>` — Run test in the specified file. Only valid when `--package` is also specified
388-
* `-i`, `--index <INDEX>` — Run only the index-th test in the file. Accepts a single index or an inclusive range like `0-2`. Only valid when `--file` is also specified
388+
* `-i`, `--index <INDEX>` — Run only the index-th test in the file. Accepts a single index or a left-inclusive right-exclusive range like `0-2`. Only valid when `--file` is also specified
389389
* `--frozen` — Do not sync dependencies, assuming local dependencies are up-to-date
390390
* `--build-only` — Only build, do not bench
391391
* `--no-parallelize` — Run the benchmarks in a target backend sequentially

0 commit comments

Comments
 (0)