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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b383b3471219b3c06826e6a31af6aa386e20d06c1d38d56253625e37364061d
4
- data.tar.gz: 2fa8f7a9a039a90146feed91e892a15f79e383466cef7eb7dbcb20e25cfa60d9
3
+ metadata.gz: a78a74ba91adeccae7b3eca4d2ebf43b323cf49efe3ba15d32f30551de2c516d
4
+ data.tar.gz: 66998fcda2ee10ab6e8d5e9502bcb270eb64cf4146af611239e375d26121ff44
5
5
  SHA512:
6
- metadata.gz: 7ec5d63b677a0105ee352ac1ec66f76b9f3e15faeab6e3e9270efd9dc1d33716047eeb878f7917846bcf6d185dff411b297e96d64406c4022d4fdb4e867f3def
7
- data.tar.gz: 66faf08083495bcbe027178a59146468835644128b99304d73ae98aee274277024960e2c2601985a2a0a07458bc9df9b5a1cf40d16f2d26290808cfb6eec8e84
6
+ metadata.gz: a996da9058eda150e0a8899d91b4dfabd712dca644d3551957c1ed0ace13a21d55fc6536b976a144f68da39db3fb12da4beffe3a9267cf61893b38a3dd15e69a
7
+ data.tar.gz: 61e9aa9289e29dca15d370afd8c96bc3b1c019a9f111d0157e1d6557b1c8b79bbb09ead4dbaecb041b218913968637411b04839185e1a8388909b291e9d34654
@@ -1,4 +1,4 @@
1
- class PhpFileHook < Mumukit::Templates::FileHook
1
+ class PhpFileHook < Mumukit::Templates::MultiFileHook
2
2
  isolated true
3
3
 
4
4
  def tempfile_extension
@@ -2,7 +2,8 @@ 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.4'
5
+ config.docker_image = 'mumuki/mumuki-php-worker:1.5'
6
+ config.multifile = true
6
7
  end
7
8
 
8
9
  require_relative './version'
@@ -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(filename)
6
- "run-tests-and-get-ast #{filename}"
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
- file = super request
13
- struct request.to_h.merge result: run!(file)
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
- compile_test_content(request) + BATCH_SEPARATOR + compile_ast_content(request)
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 compile_ast_content(request)
43
- "<?php\n#{request[:content]}"
56
+ def add_php_tag(content)
57
+ "<?php\n#{content}"
44
58
  end
45
59
  end
@@ -1,5 +1,5 @@
1
1
  class PhpTestHook < Mumukit::Defaults::TestHook
2
- TEST_NAME = 'AAAMumukiTestCaseAAA'
2
+ TEST_NAME = 'MumukiSubmissionTest'
3
3
  PASSED_REGEXP = /[✔☢] ([^\n]+)/
4
4
  FAILED_REGEXP = /✘ ([^\n]+)\n *\│\n *│ ([^イ]+│ \n )/
5
5
 
@@ -1,3 +1,3 @@
1
1
  module PhpVersionHook
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
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.0
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.21'
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.21'
26
+ version: '2.29'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mulang-php
29
29
  requirement: !ruby/object:Gem::Requirement