mumuki-php-runner 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/expectations_hook.rb +41 -0
- data/lib/metadata_hook.rb +1 -1
- data/lib/php_runner.rb +3 -1
- data/lib/precompile_hook.rb +45 -0
- data/lib/test_hook.rb +11 -25
- data/lib/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8e53aafc19ead748877758997dde14238f71cb2049e786d432e616571c9d106
|
4
|
+
data.tar.gz: 966ec97d251cfe9111b8249fe2583970434f14fdd9c32658f02b3d06410b4fb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 897e4a8a031a71d22d773259de72d92f6273316f8d02eb00de96c9f655921a43fee2ea7aece4ce20a3c57322587c81e4adfe63633da6202fbff2d06a1f8d7d26
|
7
|
+
data.tar.gz: 5373842d85ce7a476bf68235ee29050585046642c9c27f40ca7f88fc5a29e58b95dc5dcf02835f6d9df6d21206792cbc8413e4f83f7ae5589a67f83f6498de76
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'mulang/php'
|
2
|
+
|
3
|
+
class PhpExpectationsHook < Mumukit::Templates::MulangExpectationsHook
|
4
|
+
SEPARATOR = '==> JSON dump:'
|
5
|
+
|
6
|
+
include_smells true
|
7
|
+
|
8
|
+
def language
|
9
|
+
'Mulang'
|
10
|
+
end
|
11
|
+
|
12
|
+
def mulang_code(request)
|
13
|
+
result = request.result[:ast]
|
14
|
+
|
15
|
+
Mulang::Code.new(mulang_language, to_mulang_ast(result))
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_mulang_ast(output)
|
19
|
+
unless output.include? SEPARATOR
|
20
|
+
return ['Unable to get Mulang AST - Command failed!', :errored]
|
21
|
+
end
|
22
|
+
|
23
|
+
json = output.split(SEPARATOR).last
|
24
|
+
ast = JSON.parse json, symbolize_names: true
|
25
|
+
|
26
|
+
Mulang::PHP.parse(ast)
|
27
|
+
rescue => e
|
28
|
+
raise Mumukit::CompilationError, e
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_smell_exceptions
|
32
|
+
LOGIC_SMELLS + FUNCTIONAL_SMELLS + OBJECT_ORIENTED_SMELLS
|
33
|
+
end
|
34
|
+
|
35
|
+
def domain_language
|
36
|
+
{
|
37
|
+
minimumIdentifierSize: 3,
|
38
|
+
jargon: []
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
data/lib/metadata_hook.rb
CHANGED
data/lib/php_runner.rb
CHANGED
@@ -2,11 +2,13 @@ require 'mumukit'
|
|
2
2
|
|
3
3
|
Mumukit.runner_name = 'php'
|
4
4
|
Mumukit.configure do |config|
|
5
|
-
config.docker_image = 'mumuki/mumuki-php-worker:1.
|
5
|
+
config.docker_image = 'mumuki/mumuki-php-worker:1.4'
|
6
6
|
end
|
7
7
|
|
8
8
|
require_relative './version'
|
9
9
|
require_relative './metadata_hook'
|
10
10
|
require_relative './php_file_hook'
|
11
|
+
require_relative './precompile_hook'
|
11
12
|
require_relative './test_hook'
|
13
|
+
require_relative './expectations_hook'
|
12
14
|
require_relative './query_hook'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class PhpPrecompileHook < PhpFileHook
|
2
|
+
BATCH_SEPARATOR = "\n/* ---Mumuki-Batch-Separator--- */\n"
|
3
|
+
RESULTS_SEPARATOR = "\n/* ---Mumuki-Results-Separator--- */\n"
|
4
|
+
|
5
|
+
def command_line(filename)
|
6
|
+
"run-tests-and-get-ast #{filename}"
|
7
|
+
end
|
8
|
+
|
9
|
+
def compile(request)
|
10
|
+
return request unless request[:query].nil?
|
11
|
+
|
12
|
+
file = super request
|
13
|
+
struct request.to_h.merge result: run!(file)
|
14
|
+
end
|
15
|
+
|
16
|
+
def compile_file_content(request)
|
17
|
+
compile_test_content(request) + BATCH_SEPARATOR + compile_ast_content(request)
|
18
|
+
end
|
19
|
+
|
20
|
+
def post_process_file(_file, result, status)
|
21
|
+
parts = result.split RESULTS_SEPARATOR
|
22
|
+
|
23
|
+
{ test: parts.first, ast: parts.last }
|
24
|
+
end
|
25
|
+
|
26
|
+
def compile_test_content(request)
|
27
|
+
<<-EOF
|
28
|
+
<?php
|
29
|
+
declare(strict_types=1);
|
30
|
+
|
31
|
+
#{request.extra}
|
32
|
+
#{request.content}
|
33
|
+
|
34
|
+
use PHPUnit\\Framework\\TestCase;
|
35
|
+
|
36
|
+
final class #{PhpTestHook::TEST_NAME}Test extends TestCase {
|
37
|
+
#{request.test.lines.map {|it| ' ' + it}.join}
|
38
|
+
}
|
39
|
+
EOF
|
40
|
+
end
|
41
|
+
|
42
|
+
def compile_ast_content(request)
|
43
|
+
"<?php\n#{request[:content]}"
|
44
|
+
end
|
45
|
+
end
|
data/lib/test_hook.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
|
-
class PhpTestHook <
|
2
|
-
structured true
|
3
|
-
|
1
|
+
class PhpTestHook < Mumukit::Defaults::TestHook
|
4
2
|
TEST_NAME = 'AAAMumukiTestCaseAAA'
|
5
3
|
PASSED_REGEXP = /[✔☢] ([^\n]+)/
|
6
4
|
FAILED_REGEXP = /✘ ([^\n]+)\n *\│\n *│ ([^イ]+│ \n )/
|
7
5
|
|
8
|
-
def
|
9
|
-
|
10
|
-
end
|
6
|
+
def run!(request)
|
7
|
+
result = request.result[:test]
|
11
8
|
|
12
|
-
|
13
|
-
|
9
|
+
unless result.include? TEST_NAME
|
10
|
+
return [mask_tempfile_references(result.strip), :errored]
|
11
|
+
end
|
14
12
|
|
15
|
-
|
13
|
+
[to_structured_result(result)]
|
16
14
|
end
|
17
15
|
|
18
16
|
def to_structured_result(result)
|
@@ -22,22 +20,6 @@ class PhpTestHook < PhpFileHook
|
|
22
20
|
passed_tests.concat(failed_tests)
|
23
21
|
end
|
24
22
|
|
25
|
-
def compile_file_content(req)
|
26
|
-
<<-EOF
|
27
|
-
<?php
|
28
|
-
declare(strict_types=1);
|
29
|
-
|
30
|
-
#{req.extra}
|
31
|
-
#{req.content}
|
32
|
-
|
33
|
-
use PHPUnit\\Framework\\TestCase;
|
34
|
-
|
35
|
-
final class #{TEST_NAME}Test extends TestCase {
|
36
|
-
#{req.test.lines.map {|it| ' ' + it}.join}
|
37
|
-
}
|
38
|
-
EOF
|
39
|
-
end
|
40
|
-
|
41
23
|
private
|
42
24
|
|
43
25
|
def to_passed_result(regexp_groups)
|
@@ -50,4 +32,8 @@ EOF
|
|
50
32
|
|
51
33
|
[regexp_groups.first, 'failed', reason]
|
52
34
|
end
|
35
|
+
|
36
|
+
def mask_tempfile_references(string)
|
37
|
+
string.gsub /\/tmp\/tmp\.\w+/, 'solution.php'
|
38
|
+
end
|
53
39
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumuki-php-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Alfonso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mumukit
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.21'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mulang-php
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,9 +115,11 @@ executables: []
|
|
101
115
|
extensions: []
|
102
116
|
extra_rdoc_files: []
|
103
117
|
files:
|
118
|
+
- lib/expectations_hook.rb
|
104
119
|
- lib/metadata_hook.rb
|
105
120
|
- lib/php_file_hook.rb
|
106
121
|
- lib/php_runner.rb
|
122
|
+
- lib/precompile_hook.rb
|
107
123
|
- lib/query_hook.rb
|
108
124
|
- lib/test_hook.rb
|
109
125
|
- lib/version.rb
|