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

Commit 829ff96

Browse files
authored
Code Cleanup (#452)
- docker images no longer use timeout as default entrypoint - ESLint fixes
1 parent 48e9f2a commit 829ff96

39 files changed

+170
-144
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
frameworks/javascript/angular/
2+
frameworks/java

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ services:
192192
entrypoint: ''
193193
command: bash
194194

195+
chapel-runner:
196+
image: codewars/chapel-runner
197+
volumes:
198+
- ./lib:/runner/lib
199+
- ./examples:/runner/examples
200+
- ./frameworks:/runner/frameworks
201+
- ./test:/runner/test
202+
entrypoint: ''
203+
command: bash
204+
195205
# LANGUAGE SPECIFIC HELPERS
196206
javascript:
197207
image: codewars/node-runner

docker/alt.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ RUN mocha -t 3000 test/runners/php_spec.js
4242

4343
#timeout is a fallback in case an error with node
4444
#prevents it from exiting properly
45-
ENTRYPOINT ["timeout", "15", "node"]
45+
ENTRYPOINT ["node"]

docker/chapel.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ WORKDIR /runner
3434
USER codewarrior
3535

3636
RUN mocha -t 10000 test/runners/chapel_spec.js
37-
ENTRYPOINT ["timeout", "15", "node"]
37+
ENTRYPOINT ["node"]

docker/crystal.docker

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ ADD frameworks/crystal/formatter.cr /home/codewarrior/crystal/formatter.cr
4444
USER codewarrior
4545

4646
RUN mocha -t 10000 test/runners/crystal_spec.js
47+
48+
ENTRYPOINT ["node"]

docker/dart.docker

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ RUN ln -s /home/codewarrior /workspace
4242
USER codewarrior
4343

4444
RUN mocha -t 10000 test/runners/dart_spec.js
45+
46+
ENTRYPOINT ["node"]

docker/dotnet.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ RUN mono -V
5757

5858
#timeout is a fallback in case an error with node
5959
#prevents it from exiting properly
60-
ENTRYPOINT ["timeout", "15", "node"]
60+
ENTRYPOINT ["node"]

docker/erlang.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ RUN mocha -t 5000 test/runners/{erlang,elixir}_spec.js
5656

5757
#timeout is a fallback in case an error with node
5858
#prevents it from exiting properly
59-
ENTRYPOINT ["timeout", "15", "node"]
59+
ENTRYPOINT ["node"]

docker/esolangs.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ RUN mocha -t 10000 test/runners/bf_spec.js
2525

2626
#timeout is a fallback in case an error with node
2727
#prevents it from exiting properly
28-
ENTRYPOINT ["timeout", "15", "node"]
28+
ENTRYPOINT ["node"]

docker/func.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ RUN mocha -t 5000 test/runners/{ocaml,racket}_spec.js
3434

3535
#timeout is a fallback in case an error with node
3636
#prevents it from exiting properly
37-
ENTRYPOINT ["timeout", "15", "node"]
37+
ENTRYPOINT ["node"]

docker/go.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ RUN mocha -t 5000 test/runners/go_spec.js
5252

5353
#timeout is a fallback in case an error with node
5454
#prevents it from exiting properly
55-
ENTRYPOINT ["timeout", "17", "node"]
55+
ENTRYPOINT ["node"]

docker/haskell.docker

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN cabal update
2828
RUN cabal install cabal-install
2929

3030
# Install Haskell Packages
31-
# To install additional packages use "RUN cabal install <pkg-name>"
31+
# To install additional packages use "RUN cabal install <pkg-name>"
3232
RUN cabal install split ifelse
3333
RUN cabal install persistent-sqlite persistent-template
3434
RUN cabal install haskell-src-exts lens
@@ -38,7 +38,7 @@ RUN cabal install hspec hspec-core hspec-discover
3838
# Haskell stuff end.
3939
# =========================================================================
4040

41-
# Add the package json first to a tmp directory and build,
41+
# Add the package json first to a tmp directory and build,
4242
# copy over so that we dont rebuild every time
4343
USER root
4444
ADD package.json /tmp/package.json
@@ -55,4 +55,4 @@ RUN mocha -t 10000 test/runners/haskell_spec.js
5555

5656
# timeout is a fallback in case an error with node
5757
# prevents it from exiting properly
58-
ENTRYPOINT ["timeout", "15", "node"]
58+
ENTRYPOINT ["node"]

docker/julia.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ RUN mocha -t 5000 test/runners/julia_spec.js
5151

5252
#timeout is a fallback in case an error with node
5353
#prevents it from exiting properly
54-
ENTRYPOINT ["timeout", "15", "node"]
54+
ENTRYPOINT ["node"]

docker/jvm.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ RUN mocha -t 10000 test/runners/{clojure,groovy,scala,kotlin}_spec.js
6262

6363
#timeout is a fallback in case an error with node
6464
#prevents it from exiting properly
65-
ENTRYPOINT ["timeout", "15", "node"]
65+
ENTRYPOINT ["node"]

docker/lua.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ RUN mocha -t 5000 test/runners/lua_spec.js
3232

3333
#timeout is a fallback in case an error with node
3434
#prevents it from exiting properly
35-
ENTRYPOINT ["timeout", "15", "node"]
35+
ENTRYPOINT ["node"]

docker/node.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ RUN mocha -t 10000 test/runners/typescript_spec.js
5858

5959
#timeout is a fallback in case an error with node
6060
#prevents it from exiting properly
61-
ENTRYPOINT ["timeout", "15", "node"]
61+
ENTRYPOINT ["node"]

docker/objc.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,4 @@ RUN mocha -t 5000 test/runners/objc_spec.js
149149

150150
# timeout is a fallback in case an error with node
151151
# prevents it from exiting properly
152-
ENTRYPOINT ["timeout", "15", "node"]
152+
ENTRYPOINT ["node"]

docker/ocaml.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ RUN /home/codewarrior/run_ocaml.sh mocha -t 5000 test/runners/ocaml_spec.js
4444

4545
#timeout is a fallback in case an error with node
4646
#prevents it from exiting properly
47-
ENTRYPOINT ["/home/codewarrior/run_ocaml.sh", "timeout", "15", "node"]
47+
ENTRYPOINT ["/home/codewarrior/run_ocaml.sh", "node"]

docker/python.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ RUN mocha -t 5000 test/runners/python_spec.js
102102

103103
#timeout is a fallback in case an error with node
104104
#prevents it from exiting properly
105-
ENTRYPOINT ["timeout", "15", "node"]
105+
ENTRYPOINT ["node"]

docker/ruby.docker

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ ENV USER codewarrior
179179
ENV HOME /home/codewarrior
180180

181181
RUN mocha -t 5000 test/runners/ruby_spec.js
182-
#RUN mocha -t 5000 test/runners/sql_spec.js
183182
RUN mocha -t 5000 test/runners/shell_spec.js
183+
#RUN mocha -t 5000 test/runners/sql_spec.js
184184
RUN sh /runner/lib/cleanup.sh
185185

186186
#timeout is a fallback in case an error with node
187187
#prevents it from exiting properly
188-
ENTRYPOINT ["timeout", "15", "node"]
188+
ENTRYPOINT ["node"]

docker/rust.docker

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ RUN ln -s /home/codewarrior /workspace
2626
USER codewarrior
2727

2828
RUN mocha -t 10000 test/runners/rust_spec.js
29+
30+
ENTRYPOINT ["node"]

docker/swift.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ RUN mocha -t 5000 test/runners/swift_spec.js
7272

7373
# timeout is a fallback in case an error with node
7474
# prevents it from exiting properly
75-
ENTRYPOINT ["timeout", "15", "node"]
75+
ENTRYPOINT ["node"]

docker/systems.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ RUN mocha -t 5000 test/runners/{c,cpp}_spec.js
6060

6161
#timeout is a fallback in case an error with node
6262
#prevents it from exiting properly
63-
ENTRYPOINT ["timeout", "15", "node"]
63+
ENTRYPOINT ["node"]

frameworks/javascript/cw-2.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,18 @@ try {
256256
// additional code is injected and line numbers will not match.
257257
trace: function(ex) {
258258
return (ex.stack || ex.toString() || '')
259-
.toString()
260-
// remove file names (ie: (/cli-runner/...))
261-
.replace(/\s\(.*\)/g, '')
262-
// remove at [eval] statements
263-
.replace(/(at)*( Object.)*\s*[(]?\[eval\].*(:\d*)*[)]?\n/g, '')
264-
// remove stack trace beyond the Module information
265-
.replace(/at Module[\w\s.:\d\n]*/g, '')
266-
// remove at Object.<anonymous>
267-
.replace(/\t*at Object.<\w*>\n/g, '')
268-
// handleError is used to wrap top level code, so lets remove it so that it doesn't
269-
// confuse users who won't understand why it is there.
270-
.replace('at Object.Test.handleError', '');
259+
.toString()
260+
// remove file names (ie: (/cli-runner/...))
261+
.replace(/\s\(.*\)/g, '')
262+
// remove at [eval] statements
263+
.replace(/(at)*( Object.)*\s*[(]?\[eval\].*(:\d*)*[)]?\n/g, '')
264+
// remove stack trace beyond the Module information
265+
.replace(/at Module[\w\s.:\d\n]*/g, '')
266+
// remove at Object.<anonymous>
267+
.replace(/\t*at Object.<\w*>\n/g, '')
268+
// handleError is used to wrap top level code, so lets remove it so that it doesn't
269+
// confuse users who won't understand why it is there.
270+
.replace('at Object.Test.handleError', '');
271271
},
272272
pass: function() {
273273
_expect(true);

frameworks/javascript/display.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ module.exports.format = function format(obj, options) {
134134
*/
135135
module.exports.escapeHtml = function escapeHtml(html) {
136136
return String(html)
137-
.replace(/&/g, '&amp;')
138-
.replace(/"/g, '&quot;')
139-
.replace(/'/g, '&#39;')
140-
.replace(/</g, '&lt;')
141-
.replace(/>/g, '&gt;');
137+
.replace(/&/g, '&amp;')
138+
.replace(/"/g, '&quot;')
139+
.replace(/'/g, '&#39;')
140+
.replace(/</g, '&lt;')
141+
.replace(/>/g, '&gt;');
142142
};
143143

144144
/**

lib/runners/arm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports.run = function run(opts, cb) {
1313
solutionFile = util.codeWriteSync('arm', opts.solution + '\n', dir, 'solution.s'),
1414
objectFile = solutionFile.replace(/\.[^\.]+$/, '.o'),
1515
armCommand = ['arm-linux-gnueabi-as', solutionFile, '-o', objectFile].join(' '),
16-
// Check for whether we need to link against libc
16+
// Check for whether we need to link against libc
1717
linker = opts.solution.search(/\.glob[a]?l\W+_start/) == -1 ? "arm-linux-gnueabi-gcc-4.7" : "arm-linux-gnueabi-ld",
1818
linkerCommand = [linker, objectFile, '-o', executable].join(' ');
1919
util.exec(armCommand, function() {

lib/runners/c.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ module.exports.run = function run(opts, cb) {
3636
},
3737
sanitizeStdErr: function(error) {
3838
error = error || '';
39-
return error.replace(/clang.*-std=c[^\s]+/g, '')
40-
.replace(/Error: Command failed:/g, '')
41-
.replace(/\/tmp.*(solution\.c|solution)[:0-9]*/g, '')
42-
.replace('\n', '')
43-
.replace(' ', ' ')
44-
.replace(opts.setup || '', '')
45-
.replace(opts.fixture || '', '');
39+
return error
40+
.replace(/clang.*-std=c[^\s]+/g, '')
41+
.replace(/Error: Command failed:/g, '')
42+
.replace(/\/tmp.*(solution\.c|solution)[:0-9]*/g, '')
43+
.replace('\n', '')
44+
.replace(' ', ' ')
45+
.replace(opts.setup || '', '')
46+
.replace(opts.fixture || '', '');
4647
}
4748
});
4849
};

lib/runners/chapel.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports.run = function run(opts, cb) {
1515
if (opts.setup) handleSetup(opts, dir);
1616
const executable = path.join(dir, 'solution');
1717
const solutionFile = util.codeWriteSync('chpl', opts.solution, dir, 'solution.chpl');
18+
1819
compile([solutionFile, '-o', executable], function(error, stdout, stderr) {
1920
if (error) return fail(error, stdout, stderr);
2021
opts.publish('stdout', stdout);
@@ -30,20 +31,23 @@ module.exports.run = function run(opts, cb) {
3031
opts.solution,
3132
opts.fixture,
3233
].join('\n'), dir, 'solution.chpl');
34+
3335
compile([solutionFile, '-o', executable], function(error, stdout, stderr) {
3436
if (error) return fail(error, stdout, stderr);
3537
opts.publish('stdout', stdout);
38+
3639
runCode({name: executable, args: []});
3740
});
3841
},
3942

4043
sanitizeStdErr: function(error) {
4144
error = error || '';
42-
return error.replace(/\/tmp.*(solution\.chpl|solution)[:0-9]*/g, '')
43-
.replace(/Error: Command failed:/g, '')
44-
.replace(/error: uncaught error/g, '')
45-
.replace('\n', '')
46-
.replace(' ', ' ');
45+
return error
46+
.replace(/\/tmp.*(solution\.chpl|solution)[:0-9]*/g, '')
47+
.replace(/Error: Command failed:/g, '')
48+
.replace(/error: uncaught error/g, '')
49+
.replace('\n', '')
50+
.replace(' ', ' ');
4751
}
4852
});
4953
};

lib/runners/clojure.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ module.exports.run = function run(opts, cb) {
2121
// HACK: don't know clojure well enough to fix issue within actual runner, but it is escaping line breaks when it shouldn't
2222
sanitizeStdOut: function(stdout) {
2323
return stdout
24-
.replace(/\<:LF:\>\<PASSED::\>/g, '\n<PASSED::>')
25-
.replace(/\<:LF:\>\<FAILED::\>/g, '\n<FAILED::>')
26-
.replace(/\<:LF:\>\<ERROR::\>/g, '\n<ERROR::>');
24+
.replace(/\<:LF:\>\<PASSED::\>/g, '\n<PASSED::>')
25+
.replace(/\<:LF:\>\<FAILED::\>/g, '\n<FAILED::>')
26+
.replace(/\<:LF:\>\<ERROR::\>/g, '\n<ERROR::>');
2727

2828
}
2929
});

lib/runners/cpp.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ module.exports.run = function run(opts, cb) {
4141

4242
sanitizeStdErr: function(error) {
4343
error = error || '';
44-
return error.replace(/clang.*-std=c[^\s]+/g, '')
45-
.replace(/Error: Command failed:/g, '')
46-
.replace(/\/tmp.*(solution\.cpp|solution)[:0-9]*/g, '')
47-
.replace('\n', '')
48-
.replace(' ', ' ')
49-
.replace(opts.setup || '', '')
50-
.replace(opts.fixture || '', '');
44+
return error
45+
.replace(/clang.*-std=c[^\s]+/g, '')
46+
.replace(/Error: Command failed:/g, '')
47+
.replace(/\/tmp.*(solution\.cpp|solution)[:0-9]*/g, '')
48+
.replace('\n', '')
49+
.replace(' ', ' ')
50+
.replace(opts.setup || '', '')
51+
.replace(opts.fixture || '', '');
5152
}
5253
});
5354
};

lib/runners/fsharp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var shovel = require('../shovel'),
55
csharpFrameworksPath = path.resolve(__dirname, '..', '..', 'frameworks', 'csharp'),
66
fuchuPath = path.resolve(fsharpFrameworksPath, 'Fuchu', 'lib', 'Fuchu'),
77

8-
// Fuchu references exception classes from these libs
8+
// Fuchu references exception classes from these libs
99
nunitAssemblies = ['nunit.core.dll', 'nunit.core.interfaces.dll', 'nunit.util.dll', 'nunit.framework.dll', 'Newtonsoft.Json.dll', 'Qualified.dll'],
1010
nunitPath = path.resolve(csharpFrameworksPath, 'nunit', 'bin'),
1111
gallioPath = path.resolve(fsharpFrameworksPath, 'Gallio', 'lib', 'NET40'),

lib/runners/gas.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports.run = function(opts, cb) {
1313
solutionFile = util.codeWriteSync('gas', opts.solution + '\n', dir, 'solution.s'),
1414
objectFile = solutionFile.replace(/\.[^\.]+$/, '.o'),
1515
gasCommand = ['gcc', '-c', solutionFile, '-o', objectFile].join(' '),
16-
// Check for whether we need to link against libc
16+
// Check for whether we need to link against libc
1717
linker = opts.solution.search(/\.global\W+_start/) == -1 ? "gcc" : "ld",
1818
linkerCommand = [linker, objectFile, '-o', executable].join(' ');
1919
util.exec(gasCommand, function() {

lib/runners/haskell.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ module.exports.run = function run(opts, cb) {
2020
if (opts.setup) codeWriteSync('haskell', opts.setup, haskellCodeDir);
2121
var solutionFileName = codeWriteSync('haskell', opts.solution, haskellCodeDir, "Main.hs"),
2222
fixtureFileName = solutionFileName.split('/').pop() == "Main.hs" ?
23-
codeWriteSync('haskell', opts.fixture, haskellCodeDir) :
24-
codeWriteSync('haskell', opts.fixture, haskellCodeDir, "Main.hs");
23+
codeWriteSync('haskell', opts.fixture, haskellCodeDir) :
24+
codeWriteSync('haskell', opts.fixture, haskellCodeDir, "Main.hs");
25+
2526
process.env["solutionFileName"] = solutionFileName;
2627

2728
runCode({

lib/runners/javascript.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ module.exports.run = function run(opts, cb) {
4040
},
4141
sanitizeStdErr: function(error) {
4242
error = error || '';
43-
return error.replace(/(\()?\/codewars\/[(\w\/-\d.js:) ;]*/g, '')
44-
.replace(/( Object. )?[\(]?\[eval\][-:\w\d\)]* at/g, '')
45-
.replace(/Module._compile.*/g, '')
46-
.replace('Object.Test.handleError ', '')
47-
.replace(opts.setup || '', '')
48-
.replace(opts.fixture || '', '');
43+
return error
44+
.replace(/(\()?\/codewars\/[(\w\/-\d.js:) ;]*/g, '')
45+
.replace(/( Object. )?[\(]?\[eval\][-:\w\d\)]* at/g, '')
46+
.replace(/Module._compile.*/g, '')
47+
.replace('Object.Test.handleError ', '')
48+
.replace(opts.setup || '', '')
49+
.replace(opts.fixture || '', '');
4950
},
5051
sanitizeStdOut: function(stdout) {
5152
return this.sanitizeStdErr(stdout);

lib/runners/lisp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports.run = function run(opts, cb) {
77
var lispCodeDir = temp.mkdirSync('lisp'),
88
args = [
99
'--noinform', // Disable banner
10-
'--disable-ldb', // Disable the low-level debugger
10+
'--disable-ldb', // Disable the low-level debugger
1111
'--lose-on-corruption', // Don't try to recover
1212
'--non-interactive' // No REPL
1313
];

lib/runners/nasm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports.run = function run(opts, cb) {
1414
solutionFile = util.codeWriteSync('nasm', opts.solution + '\n', dir, 'solution.asm'),
1515
nasmCommand = ['nasm', '-felf64', solutionFile].join(' '),
1616
objectFile = solutionFile.replace(/\.[^\.]+$/, '.o'),
17-
// Check for whether we need to link against libc
17+
// Check for whether we need to link against libc
1818
linker = opts.solution.search(/global\W+_start/) == -1 ? "gcc" : "ld",
1919
linkerCommand = [linker, objectFile, '-o', executable].join(' ');
2020
util.exec(nasmCommand, function() {

0 commit comments

Comments
 (0)