-
Notifications
You must be signed in to change notification settings - Fork 106
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
Put load_module directives before the stream block #84
base: master
Are you sure you want to change the base?
Conversation
This is just a wild guess. Feel free to correct me if it's wrong or too hacky. |
lib/Test/Nginx/Util.pm
Outdated
@@ -906,7 +906,7 @@ sub write_config_file ($$) { | |||
if ($LoadModules) { | |||
my @modules = map { "load_module $_;" } grep { $_ } split /\s+/, $LoadModules; | |||
if (@modules) { | |||
$main_config .= join " ", @modules; | |||
substr $main_config, 0, 0, join " ", @modules; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's more readable to say $main_config = (join " ", @modules) . " " . $main_config
?
@@ -906,7 +906,7 @@ sub write_config_file ($$) { | |||
if ($LoadModules) { | |||
my @modules = map { "load_module $_;" } grep { $_ } split /\s+/, $LoadModules; | |||
if (@modules) { | |||
$main_config .= join " ", @modules; | |||
$main_config = join " ", @modules, $main_config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better add a space between these two things to make the resulting nginx.conf look a bit better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, never mind, a space is already used as a delimiter in the join()
call :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This produces the following output:
load_module foo; load_module bar; stream {
server {
listen 1985;
...
}
}
I would be in favor of having the following output, which makes debugging easier when inspecting the generated nginx.conf
:
load_module foo;
load_module bar;
stream {
server {
listen 1985;
...
}
}
This simple change is my suggestion:
$main_config = join " ", @modules, $main_config; | |
$main_config = join "\n", @modules, $main_config; |
@thibaultcha Will you have a look at this. If it looks good to you, then feel free to merge this :) Thanks! |
One concern is the 1 offset in the line numbers for the subsequent lines. This may break existing tests. |
@agentzh Tests usually refer to the Lua snippet within the |
@thibaultcha Some tests may reference nginx.conf line numbers printed in the error log messages, like this:
|
@agentzh Indeed, I have found the following cases of tests such as you described:
If you don't mind, I would like to update them to use Once updated, we can safely apply my suggestion and merge this. What do you think? |
@thibaultcha Actually some tests really want to check the nginx.conf line numbers. That's part of the things we want to check accurately. |
I think it is fine since we don't use |
Fixes #69.