diff --git a/CHANGES.md b/CHANGES.md index bafd37b1c9b7c3a62049ff0b6fe85a19066c36b7..915e4ad5ae87cf796eedf9b7a144d06eb15aead5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,8 @@ - Internal type `Test.SCHEDULER.response` changed. This change is very unlikely to impact you unless you wrote your own backend. +- `--match` now applies to both test title and test filename. + ### New Features - Added `?seed` to `Test.register` and the `--seed` command-line parameter diff --git a/lib_core/cli.ml b/lib_core/cli.ml index 781113c45fed7baf5da0931829a89822c7be3f0d..dddfd6e499d34837ea194cadc762774d39130249 100644 --- a/lib_core/cli.ml +++ b/lib_core/cli.ml @@ -304,8 +304,9 @@ let init ?args () = (fun pattern -> options.patterns_to_run <- Base.rex ~opts:[`Caseless] pattern :: options.patterns_to_run), - " Only run tests matching PERL_REGEXP (case \ - insensitive) (see SELECTING TESTS)." ); + " Only run tests for which 'FILE: TITLE' matches \ + PERL_REGEXP (case insensitive), where FILE is the source file of \ + the test and TITLE its title (see SELECTING TESTS)." ); ( "-m", Arg.String (fun pattern -> @@ -493,8 +494,8 @@ let init ?args () = It is what is printed after [SUCCESS] (or [FAILURE] or [ABORTED]) in \ the reports. Use --title (respectively --not-title) to select \ (respectively unselect) a test by its title on the command-line. You \ - can also select tests whose title matches one or several Perl regular \ - expressions using --match.\n\n\ + can also select tests for which 'filename: title' matches one or \ + several Perl regular expressions using --match.\n\n\ \ The file in which a test is implemented is specified by the ~__FILE__ \ argument of Test.register. In other words, it is the name of the file \ in which the test is defined, without directories. Use --file to select \ diff --git a/lib_core/test.ml b/lib_core/test.ml index 2de1eea79a199425a5860be9f7ea030e4e93aee5..d9728c0083065b8dd9d502a3c8b9d9efa0d7f9cf 100644 --- a/lib_core/test.ml +++ b/lib_core/test.ml @@ -351,7 +351,12 @@ let test_should_be_run ~file ~title ~tags = && (not (List.mem title Cli.options.tests_not_to_run)) && (match Cli.options.patterns_to_run with | [] -> true - | patterns -> List.exists (fun pattern -> title =~ pattern) patterns) + | patterns -> + List.exists + (fun pattern -> + let uid = file ^ ": " ^ title in + uid =~ pattern) + patterns) && match Cli.options.files_to_run with | [] -> true