PAX
view release on metacpan or search on metacpan
t/standalone_runtime.t view on Meta::CPAN
. 'exec { $^X } $^X, $core, $command, @ARGV;' . "\n", '/tmp/shell')
if $name eq 'shell';
return ("print join(q{|}, q{core}, \@ARGV), qq{\\n}; 0;\n", '/tmp/_dashboard-core')
if $name eq '_dashboard-core';
die "unexpected helper asset lookup for $name";
};
my ($stdout, $stderr, $result) = capture {
PAX::StandaloneRuntime::_run_standalone_managed_helper('shell', 'bash');
};
is($result, 0, 'delegating standalone helper execution returns success');
is($stderr, '', 'delegating standalone helper execution keeps stderr empty');
like($stdout, qr{\Acore\|shell\|bash\n\z}, 'delegating standalone helper execution routes through dashboard core with helper name');
is_deeply(\@asset_requests, ['shell', '_dashboard-core'], 'delegating standalone helper execution loads helper asset and dashboard core');
}
{
no warnings 'redefine';
my $entrypoint = 't/tmp-standalone-runtime-cli-router.json';
open my $fh, '>', $entrypoint or die "cannot write cli router fixture: $!";
print {$fh} encode_json({
version_module => 'Example::App',
suggest_class => 'Example::Suggest',
});
close $fh;
my @helper_calls;
my $switchboard_calls = 0;
local *PAX::StandaloneRuntime::_run_standalone_managed_helper = sub {
my ($name, @argv) = @_;
push @helper_calls, [$name, @argv];
return 'direct-helper';
};
local *PAX::StandaloneRuntime::_virtual_entrypoint_path = sub {
my ($path) = @_;
return $path;
};
local *PAX::StandaloneRuntime::_code_for = sub {
my ($name) = @_;
return sub { return 1 } if $name eq 'main::_load_runtime_env';
return sub { return 1 } if $name eq 'main::_prime_command_result_env';
return sub {
my ($cmd) = @_;
return '/tmp/runtime-helpers/ps1' if $cmd eq 'ps1';
return '/tmp/runtime-helpers/skills' if $cmd eq 'skills';
return '';
} if $name eq 'main::_builtin_helper_path';
return sub { return '' } if $name eq 'main::_custom_command_path';
return sub {
my ($cmd) = @_;
return ('sample-skill', 'run-test') if $cmd eq 'sample-skill.run-test';
return;
} if $name eq 'main::_skill_dotted_command_parts';
return sub {
$switchboard_calls++;
die 'switchboard path should not run';
} if $name eq 'main::_exec_switchboard_command';
return;
};
{
local @ARGV = ('ps1', '--jobs', '1');
my $rv = PAX::StandaloneRuntime::_run_cli_router_unit($entrypoint);
is($rv, 'direct-helper', 'cli router routes built-in helper commands through the standalone helper fast path');
}
{
local @ARGV = ('sample-skill.run-test', '--verbose');
my $rv = PAX::StandaloneRuntime::_run_cli_router_unit($entrypoint);
is($rv, 'direct-helper', 'cli router routes dotted skill commands through the standalone helper fast path');
}
is_deeply(
\@helper_calls,
[
['ps1', '--jobs', '1'],
['skills', '_exec', 'sample-skill', 'run-test', '--verbose'],
],
'cli router fast path preserves helper name and argv for built-in and skill helper dispatch',
);
is($switchboard_calls, 0, 'cli router helper fast path skips switchboard execution');
unlink $entrypoint or die "cannot remove cli router fixture $entrypoint: $!";
}
done_testing;
=pod
=head1 NAME
t/standalone_runtime.t - regression coverage for standalone runtime dispatch, helper routing, and bootstrap behavior
=head1 DESCRIPTION
This test exercises standalone runtime dispatch, helper routing, and bootstrap behavior. It exists so PAX changes can be checked against a
repeatable behavioral contract instead of informal manual runs.
=head1 TEST PLAN
The assertions in this file cover the specific success, failure, and edge-case
paths needed for standalone runtime dispatch, helper routing, and bootstrap behavior. Extend this file when behavior changes in that area.
=head1 HOW TO RUN
prove -lv t/standalone_runtime.t
=head1 WHY IT EXISTS
PAX uses this test to keep standalone runtime dispatch, helper routing, and bootstrap behavior from regressing while the compiler,
standalone runtime, and packaging logic continue to evolve.
=cut
( run in 0.621 second using v1.01-cache-2.11-cpan-364913b4093 )