From 3b0787fdecc21edf9ad22b82f547363c1aa79b15 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 5 Aug 2026 03:58:11 +0900 Subject: test(plugin): compare plugin-provided command execution against upstream A Shirabe-authored CommandProvider fixture plugin (greet) runs under both implementations: exit codes, the command's own output, help/list rendering, alias resolution, a validation failure, and a file recording the shared object graph the command observed (root package, strict application FQCN, and the exit code of the built-in about command it invoked) must match. Co-Authored-By: Claude Fable 5 --- .../fixtures/e2e-command/plugin/composer.json | 17 ++++++++ .../e2e-command/plugin/src/GreetCommand.php | 48 ++++++++++++++++++++++ .../plugin/src/GreetCommandProvider.php | 13 ++++++ .../fixtures/e2e-command/plugin/src/Plugin.php | 30 ++++++++++++++ .../fixtures/e2e-command/project/composer.json | 24 +++++++++++ 5 files changed, 132 insertions(+) create mode 100644 crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/composer.json create mode 100644 crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommand.php create mode 100644 crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommandProvider.php create mode 100644 crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/Plugin.php create mode 100644 crates/shirabe/tests/plugin/fixtures/e2e-command/project/composer.json (limited to 'crates/shirabe/tests/plugin/fixtures') diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/composer.json b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/composer.json new file mode 100644 index 00000000..76cf19e9 --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/composer.json @@ -0,0 +1,17 @@ +{ + "name": "shirabe-test/command-provider", + "version": "1.0.0", + "type": "composer-plugin", + "description": "Fixture plugin providing a command through the CommandProvider capability.", + "autoload": { + "psr-4": { + "ShirabeTest\\CommandProvider\\": "src/" + } + }, + "require": { + "composer-plugin-api": "^2.0" + }, + "extra": { + "class": "ShirabeTest\\CommandProvider\\Plugin" + } +} diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommand.php b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommand.php new file mode 100644 index 00000000..51b3e765 --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommand.php @@ -0,0 +1,48 @@ +setName('greet') + ->setAliases(['hi']) + ->setDescription('Greets someone from a plugin-provided command.') + ->setHelp('The greet command exercises plugin-provided command execution.') + ->addArgument('who', InputArgument::REQUIRED, 'Who to greet') + ->addOption('shout', 's', InputOption::VALUE_NONE, 'Uppercase the greeting') + ->addOption('out', null, InputOption::VALUE_REQUIRED, 'File the command writes its observations to'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $message = 'Hello ' . $input->getArgument('who'); + if ($input->getOption('shout')) { + $message = strtoupper($message); + } + $this->getIO()->write('greet: ' . $message); + + $composer = $this->requireComposer(); + $lines = [ + 'root=' . $composer->getPackage()->getName(), + 'app=' . get_class($this->getApplication()), + ]; + $aboutExit = $this->getApplication()->find('about')->run(new ArrayInput(['command' => 'about']), $output); + $lines[] = 'about=' . $aboutExit; + $out = $input->getOption('out'); + if ($out !== null) { + file_put_contents($out, implode("\n", $lines) . "\n"); + } + + return 0; + } +} diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommandProvider.php b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommandProvider.php new file mode 100644 index 00000000..ce36e062 --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommandProvider.php @@ -0,0 +1,13 @@ + GreetCommandProvider::class, + ]; + } +} diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-command/project/composer.json b/crates/shirabe/tests/plugin/fixtures/e2e-command/project/composer.json new file mode 100644 index 00000000..e68a53de --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e-command/project/composer.json @@ -0,0 +1,24 @@ +{ + "name": "shirabe/e2e-command-provider", + "description": "E2E fixture project: run a plugin-provided command against upstream Composer and Shirabe.", + "repositories": [ + { + "type": "path", + "url": "../plugin", + "options": { + "symlink": false + } + }, + { + "packagist.org": false + } + ], + "require": { + "shirabe-test/command-provider": "1.0.0" + }, + "config": { + "allow-plugins": { + "shirabe-test/command-provider": true + } + } +} -- cgit v1.3.1