Skip to content

Commit b75ec68

Browse files
authored
test: execute multiple subdirectories of examples at once (#378)
![image](https://github.com/user-attachments/assets/35aead37-88ee-4335-b5ea-2093bea7426a)
1 parent 3460407 commit b75ec68

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

example

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,25 @@ require_once __DIR__.'/vendor/autoload.php';
1717

1818
$app = (new SingleCommandApplication('LLM Chain Example Runner'))
1919
->setDescription('Runs all LLM Chain examples in folder examples/')
20-
->addArgument('subdirectory', InputArgument::OPTIONAL, 'Subdirectory to run examples from, e.g. "anthropic" or "huggingface".')
20+
->addArgument('subdirectories', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'List of subdirectories to run examples from, e.g. "anthropic" and/or "huggingface".')
2121
->addOption('filter', 'f', InputOption::VALUE_REQUIRED, 'Filter examples by name, e.g. "audio" or "toolcall".')
2222
->setCode(function (InputInterface $input, OutputInterface $output) {
2323
$io = new SymfonyStyle($input, $output);
2424
$io->title('LLM Chain Examples');
2525

26-
$directory = __DIR__.'/examples';
26+
$findIn = __DIR__.'/examples';
2727

28-
if ($subdirectory = $input->getArgument('subdirectory')) {
29-
$directory .= '/'.$subdirectory;
30-
if (!is_dir($directory)) {
31-
$io->error(sprintf('Subdirectory "%s" does not exist.', $subdirectory));
32-
return Command::FAILURE;
28+
if ($subdirectories = $input->getArgument('subdirectories')) {
29+
foreach ($subdirectories as $key => $subdirectory) {
30+
$directory = $findIn.'/'.$subdirectory;
31+
32+
if (!is_dir($directory)) {
33+
$io->error(sprintf('Subdirectory "%s" does not exist.', $subdirectory));
34+
}
35+
36+
$subdirectories[$key] = $directory;
3337
}
38+
$findIn = $subdirectories;
3439
}
3540

3641
$filter = '*.php';
@@ -39,7 +44,7 @@ $app = (new SingleCommandApplication('LLM Chain Example Runner'))
3944
}
4045

4146
$examples = (new Finder())
42-
->in($directory)
47+
->in($findIn)
4348
->name($filter)
4449
->sortByName()
4550
->files();

0 commit comments

Comments
 (0)