Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add exported perl functions add_global_init_processor #81

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Test/Nginx/Socket.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ our @EXPORT = qw( env_to_nginx is_str plan run_tests run_test
server_name
server_addr server_root html_dir server_port server_port_for_client
timeout no_nginx_manager check_accum_error_log
add_block_preprocessor bail_out add_cleanup_handler
add_block_preprocessor add_global_init_processor bail_out add_cleanup_handler
add_response_body_check
);

Expand Down
12 changes: 10 additions & 2 deletions lib/Test/Nginx/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ sub no_nginx_manager () {

our @CleanupHandlers;
our @BlockPreprocessors;
our @GlobalInitProcessors;

sub bail_out (@);

Expand Down Expand Up @@ -444,6 +445,7 @@ our @EXPORT = qw(
$Benchmark
$BenchmarkWarmup
add_block_preprocessor
add_global_init_processor
timeout
worker_connections
workers
Expand Down Expand Up @@ -487,6 +489,10 @@ sub add_block_preprocessor(&) {
unshift @BlockPreprocessors, shift;
}

sub add_global_init_processor(&) {
unshift @GlobalInitProcessors, shift;
}

#our ($PrevRequest)
our $PrevConfig;

Expand Down Expand Up @@ -708,6 +714,10 @@ sub run_tests () {
$ENV{TEST_NGINX_SERVER_PORT} = $ServerPort;
}

for my $gi (@GlobalInitProcessors) {
$gi->();
}

for my $block ($NoShuffle ? Test::Base::blocks() : shuffle Test::Base::blocks()) {
for my $hdl (@BlockPreprocessors) {
$hdl->($block);
Expand Down Expand Up @@ -2473,8 +2483,6 @@ retry:
END {
return if $InSubprocess;

cleanup();

if ($UseStap || $UseValgrind || !$ENV{TEST_NGINX_NO_CLEAN}) {
local $?; # to avoid confusing Test::Builder::_ending
if (defined $PidFile && -f $PidFile) {
Expand Down