Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

[Lua] Add "Preloaded" code support #409

Merged
merged 3 commits into from
May 12, 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
3 changes: 0 additions & 3 deletions docker/lua.docker
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ RUN mkdir -p /runner && cp -a /tmp/node_modules /runner
COPY . /runner
WORKDIR /runner

COPY frameworks/lua /home/codewarrior/lua
RUN chown -R codewarrior:codewarrior /home/codewarrior/lua

USER codewarrior
ENV USER=codewarrior HOME=/home/codewarrior

Expand Down
22 changes: 11 additions & 11 deletions frameworks/lua/codewars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,45 @@ return function(options)
end

local function onDescribeStart(element, parent)
print('<DESCRIBE::>' .. element.name)
print('\n<DESCRIBE::>' .. element.name)
return nil, true
end
local function onDescribeEnd(element, parent)
local s = '<COMPLETEDIN::>%.4f'
local s = '\n<COMPLETEDIN::>%.4f'
print(s:format(1000*element.duration))
return nil, true
end

local function onTestStart(element, parent)
print('<IT::>' .. element.name)
print('\n<IT::>' .. element.name)
return nil, true
end
local function onTestEnd(element, parent, status, trace)
if status == 'success' then
print('<PASSED::>Test Passed')
print('\n<PASSED::>Test Passed')
end
local s = '<COMPLETEDIN::>%.4f'
local s = '\n<COMPLETEDIN::>%.4f'
print(s:format(1000*element.duration))
return nil, true
end

local function onTestFailure(element, parent, message, debug)
print('<FAILED::>Test Failed')
print('\n<FAILED::>Test Failed')
-- remove '/home/codewarrior/lua/fixture.lua:\d+: ' from message
print('<LOG:ESC:>' .. escape(message:sub(message:find(' ') + 1)))
print('\n<LOG:ESC:>' .. escape(message:sub(message:find(' ') + 1)))
return nil, true
end

local function onTestError(element, parent, message, debug)
print('<ERROR::>Test Error')
print('<LOG:ESC:Traceback>' .. escape(message))
print('\n<ERROR::>Test Error')
print('\n<LOG:ESC:Traceback>' .. escape(message))
return nil, true
end

local function onError(element, parent, message, debug)
if element.descriptor ~= 'it' then
print('<ERROR::>Error')
print('<LOG:ESC:>' .. escape(message))
print('\n<ERROR::>Error')
print('\n<LOG:ESC:>' .. escape(message))
end
return nil, true
end
Expand Down
24 changes: 14 additions & 10 deletions lib/runners/lua.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
var shovel = require('../shovel'),
writeFileSync = require('../util').writeFileSync;
"use strict";

const shovel = require('../shovel');
const writeFileSync = require('../util').writeFileSync;

module.exports.run = function run(opts, cb) {
const dir = '/home/codewarrior/lua';
shovel.start(opts, cb, {
solutionOnly: function(runCode) {
solutionOnly(runCode) {
runCode({
name: 'lua',
args: [writeFileSync(dir, 'solution.lua', opts.solution, true)]
args: [writeFileSync(opts.dir, 'solution.lua', opts.solution, true)],
options: {cwd: opts.dir}
});
},
testIntegration: function(runCode) {
writeFileSync(dir, 'solution.lua', opts.solution, true);

testIntegration(runCode) {
writeFileSync(opts.dir, 'solution.lua', opts.solution, true);
if (opts.setup) writeFileSync(opts.dir, 'setup.lua', opts.setup, true);
runCode({
name: 'busted',
args: [
writeFileSync(dir, 'fixture.lua', opts.fixture, true),
`--output=codewars.lua`,
writeFileSync(opts.dir, 'fixture.lua', opts.fixture, true),
'--output=/runner/frameworks/lua/codewars.lua'
],
options: {cwd: dir}
options: {cwd: opts.dir}
});
}
});
Expand Down
Loading