protected function getSupportedOptions()

in src/HackTestCLI.hack [28:83]


  protected function getSupportedOptions(): vec<CLIOptions\CLIOption> {
    return vec[
      CLIOptions\with_required_string(
        $f ==> {
          $this->classFilter = $f;
        },
        'Filter test class names with the specified glob pattern',
        '--filter-classes',
      ),
      CLIOptions\with_required_string(
        $f ==> {
          $mf = $this->methodFilter;
          $impl = (mixed $_class, \ReflectionMethod $method) ==>
            \fnmatch($f, $method->getName());
          $this->methodFilter = $mf
            ? (
                (classname<HackTest> $c, \ReflectionMethod $m) ==>
                  $mf($c, $m) && $impl($c, $m)
              )
            : $impl;
        },
        'Filter test method names with the specified glob pattern',
        '--filter-methods',
      ),
      CLIOptions\with_required_string(
        $groups ==> {
          $groups = Str\split($groups, ',') |> keyset($$);
          $mf = $this->methodFilter;
          $impl = (mixed $_class, \ReflectionMethod $method) ==> {
            $attr = $method->getAttributeClass(TestGroup::class);
            if ($attr === null) {
              return false;
            }
            return C\any($groups, $group ==> $attr->contains($group));
          };
          $this->methodFilter = $mf
            ? (
                (classname<HackTest> $c, \ReflectionMethod $m) ==>
                  $mf($c, $m) && $impl($c, $m)
              )
            : $impl;
        },
        'Only run tests with a specified <<TestGroup>> (comma-separated)',
        '--filter-groups',
        '-g',
      ),
      CLIOptions\flag(
        () ==> {
          $this->verbose = true;
        },
        'Increase output verbosity',
        '--verbose',
        '-v',
      ),
    ];
  }