mumuki-php-runner 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/php_file_hook.rb +1 -1
- data/lib/php_runner.rb +2 -1
- data/lib/precompile_hook.rb +24 -10
- data/lib/test_hook.rb +1 -1
- data/lib/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a78a74ba91adeccae7b3eca4d2ebf43b323cf49efe3ba15d32f30551de2c516d
|
4
|
+
data.tar.gz: 66998fcda2ee10ab6e8d5e9502bcb270eb64cf4146af611239e375d26121ff44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a996da9058eda150e0a8899d91b4dfabd712dca644d3551957c1ed0ace13a21d55fc6536b976a144f68da39db3fb12da4beffe3a9267cf61893b38a3dd15e69a
|
7
|
+
data.tar.gz: 61e9aa9289e29dca15d370afd8c96bc3b1c019a9f111d0157e1d6557b1c8b79bbb09ead4dbaecb041b218913968637411b04839185e1a8388909b291e9d34654
|
data/lib/php_file_hook.rb
CHANGED
data/lib/php_runner.rb
CHANGED
data/lib/precompile_hook.rb
CHANGED
@@ -2,19 +2,26 @@ class PhpPrecompileHook < PhpFileHook
|
|
2
2
|
BATCH_SEPARATOR = "\n/* ---Mumuki-Batch-Separator--- */\n"
|
3
3
|
RESULTS_SEPARATOR = "\n/* ---Mumuki-Results-Separator--- */\n"
|
4
4
|
|
5
|
-
def command_line(
|
6
|
-
"run-tests-and-get-ast #{
|
5
|
+
def command_line(*filenames)
|
6
|
+
"run-tests-and-get-ast #{filenames.join(' ')}"
|
7
7
|
end
|
8
8
|
|
9
9
|
def compile(request)
|
10
10
|
return request unless request[:query].nil?
|
11
11
|
|
12
|
-
|
13
|
-
struct request.to_h.merge result: run!(
|
12
|
+
files = super request
|
13
|
+
struct request.to_h.merge result: run!(files)
|
14
14
|
end
|
15
15
|
|
16
16
|
def compile_file_content(request)
|
17
|
-
|
17
|
+
test_content = compile_test_content request
|
18
|
+
|
19
|
+
if has_files?(request)
|
20
|
+
ast_content = request.content.values.join("\n")
|
21
|
+
add_php_tags(test_content).merge('submission_ast.json' => add_php_tag(ast_content))
|
22
|
+
else
|
23
|
+
add_php_tag(test_content) + BATCH_SEPARATOR + add_php_tag(request.content)
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
27
|
def post_process_file(_file, result, status)
|
@@ -24,12 +31,11 @@ class PhpPrecompileHook < PhpFileHook
|
|
24
31
|
end
|
25
32
|
|
26
33
|
def compile_test_content(request)
|
27
|
-
<<-EOF
|
28
|
-
<?php
|
34
|
+
test = <<-EOF
|
29
35
|
declare(strict_types=1);
|
30
36
|
|
31
37
|
#{request.extra}
|
32
|
-
#{request.content}
|
38
|
+
#{has_files?(request) ? '' : request.content}
|
33
39
|
|
34
40
|
use PHPUnit\\Framework\\TestCase;
|
35
41
|
|
@@ -37,9 +43,17 @@ final class #{PhpTestHook::TEST_NAME}Test extends TestCase {
|
|
37
43
|
#{request.test.lines.map {|it| ' ' + it}.join}
|
38
44
|
}
|
39
45
|
EOF
|
46
|
+
|
47
|
+
has_files?(request) ?
|
48
|
+
files_of(request).merge("#{PhpTestHook::TEST_NAME.downcase}.php" => test) :
|
49
|
+
test
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_php_tags(files)
|
53
|
+
Hash[files.map{|name, content| [name, add_php_tag(content)] } ]
|
40
54
|
end
|
41
55
|
|
42
|
-
def
|
43
|
-
"<?php\n#{
|
56
|
+
def add_php_tag(content)
|
57
|
+
"<?php\n#{content}"
|
44
58
|
end
|
45
59
|
end
|
data/lib/test_hook.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumuki-php-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Alfonso
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.29'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.29'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mulang-php
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|