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

[bin] improve busted runner #418

Merged
merged 2 commits into from
Sep 1, 2017
Merged
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
7 changes: 5 additions & 2 deletions .busted
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;'),
},
}
3 changes: 2 additions & 1 deletion .luacheckrc
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' }
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- OIDC is now used based on settings on the API Manager [PR #405](https://github.com/3scale/apicast/pull/405)
- No limit on body size from the client sent to the server [PR #410](https://github.com/3scale/apicast/pull/410)
- Print module loading errors only when it failed to load [PR #415](https://github.com/3scale/apicast/pull/415)
- `bin/busted` rewritten to support different working directories [PR #418](https://github.com/3scale/apicast/pull/418)

## [3.1.0-beta2] - 2017-08-21

Expand Down
22 changes: 20 additions & 2 deletions bin/busted
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
#!/usr/bin/env sh
#!/usr/bin/env perl
Copy link

@maneta maneta Sep 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is always good to:

use warnings;
use strict;

It protects you of a lot of stuff (https://perlmaven.com/always-use-warnings)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx! Push'd.


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',
Copy link

@maneta maneta Sep 1, 2017

Choose a reason for hiding this comment

The 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.
Because maybe you want to eval the command execution

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link

Choose a reason for hiding this comment

The 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;
7 changes: 7 additions & 0 deletions examples/cors/spec/cors_spec.lua
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)