-
Notifications
You must be signed in to change notification settings - Fork 170
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
[bin] improve busted runner #418
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
local path = require('pl.path') | ||
local root = path.currentdir() | ||
|
||
return { | ||
_all = { | ||
helper = 'spec/spec_helper.lua', | ||
helper = path.join(root, 'spec/spec_helper.lua'), | ||
}, | ||
default = { | ||
verbose = true, | ||
['shuffle-tests'] = true, | ||
['shuffle-files'] = true, | ||
lpath = "./spec/?.lua;./apicast/src/?.lua;" | ||
lpath = path.join(root, 'spec/?.lua;') .. path.join(root, 'apicast/src/?.lua;'), | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
std = 'ngx_lua+lua52' -- lua52 has table.pack | ||
|
||
files["spec"] = {std = "+busted"} | ||
busted = {std = "+busted"} | ||
files["**/spec/**/*_spec.lua"] = busted | ||
|
||
globals = { 'ngx', 'unpack', 'rawlen' } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
#!/usr/bin/env sh | ||
#!/usr/bin/env perl | ||
|
||
exec resty --http-include spec/fixtures/echo.conf bin/busted.lua "$@" | ||
use strict; | ||
use warnings FATAL => 'all'; | ||
|
||
use File::Basename; | ||
use Cwd; | ||
|
||
my $dirname = dirname(__FILE__); | ||
my $cwd = getcwd(); | ||
|
||
chdir "$dirname/.."; | ||
|
||
my $apicast = getcwd(); | ||
|
||
exec '/usr/bin/env', 'resty', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are sure you want just exec Right? The big difference is that system() creates a fork process and waits to see if the command succeeds or fails - returning a value. exec() does not return anything, it simply executes the command. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well exec replaces the current process and that is exactly what I want. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just a wrapper to prepare some flags and execute different command. So to not have to handle error codes, input, output etc it is just nice to exec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perfect :) |
||
'--http-include', "$apicast/spec/fixtures/echo.conf", | ||
"$apicast/bin/busted.lua", | ||
'--config-file', "$apicast/.busted", | ||
'--directory', "$cwd", | ||
@ARGV; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
local _M = require 'cors' | ||
|
||
describe('cors', function() | ||
it('is', function() | ||
assert.match('CORS', _M._NAME) | ||
end) | ||
end) |
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.
Is always good to:
It protects you of a lot of stuff (https://perlmaven.com/always-use-warnings)
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.
Thx! Push'd.