bee_python 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/build/README +1 -1
- data/lib/bee_task_python.rb +26 -13
- data/test/tc_bee_task_python.rb +2 -2
- data/test/test_build_listener.rb +63 -15
- metadata +3 -3
data/build/README
CHANGED
data/lib/bee_task_python.rb
CHANGED
@@ -1,4 +1,19 @@
|
|
1
|
-
|
1
|
+
# Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'bee_task_package'
|
2
17
|
require 'fileutils'
|
3
18
|
|
4
19
|
module Bee
|
@@ -26,10 +41,9 @@ module Bee
|
|
26
41
|
script = File.join(File.expand_path(File.dirname(__FILE__)),
|
27
42
|
'..', 'tools', 'compile', 'compile.py')
|
28
43
|
for file in files
|
29
|
-
puts "Compiling Python source file '#{file}'" if
|
30
|
-
@build.listener.verbose
|
44
|
+
puts "Compiling Python source file '#{file}'" if @verbose
|
31
45
|
command = "python #{script} #{file}"
|
32
|
-
puts "Running command: '#{command}'" if @
|
46
|
+
puts "Running command: '#{command}'" if @verbose
|
33
47
|
ok = system(command)
|
34
48
|
error "Error compiling Python source file '#{file}'" unless ok
|
35
49
|
end
|
@@ -106,7 +120,7 @@ module Bee
|
|
106
120
|
command += " #{options}" if options
|
107
121
|
command += " --only" if only
|
108
122
|
command += " #{files.join(' ')}"
|
109
|
-
puts "Running command: '#{command}'" if @
|
123
|
+
puts "Running command: '#{command}'" if @verbose
|
110
124
|
ok = system(command)
|
111
125
|
error "Error checking Python source files" unless ok or lenient
|
112
126
|
end
|
@@ -186,7 +200,7 @@ module Bee
|
|
186
200
|
command += " --rcfile=#{config}" if config
|
187
201
|
command += " #{options}" if options
|
188
202
|
command += " #{files.join(' ')}"
|
189
|
-
puts "Running command: '#{command}'" if @
|
203
|
+
puts "Running command: '#{command}'" if @verbose
|
190
204
|
ok = system(command)
|
191
205
|
error "Error checking Python source files" unless ok or lenient
|
192
206
|
end
|
@@ -243,7 +257,7 @@ module Bee
|
|
243
257
|
command += " -o #{dest}"
|
244
258
|
command += " #{options}" if options
|
245
259
|
command += " #{files.join(' ')}"
|
246
|
-
puts "Running command: '#{command}'" if @
|
260
|
+
puts "Running command: '#{command}'" if @verbose
|
247
261
|
ok = system(command)
|
248
262
|
error "Error generating documentation for Python source files" unless
|
249
263
|
ok
|
@@ -268,7 +282,7 @@ module Bee
|
|
268
282
|
script = File.join(File.expand_path(File.dirname(__FILE__)),
|
269
283
|
'..', 'tools', 'test', 'suite.py')
|
270
284
|
command = "python #{script} #{files.join(' ')}"
|
271
|
-
puts "Running command: '#{command}'" if @
|
285
|
+
puts "Running command: '#{command}'" if @verbose
|
272
286
|
ok = system(command)
|
273
287
|
error "Error running Python test(s)" unless ok
|
274
288
|
end
|
@@ -353,7 +367,7 @@ module Bee
|
|
353
367
|
begin
|
354
368
|
Dir.chdir(dir)
|
355
369
|
command = "python #{coverage} -x -f #{data} #{test_file}"
|
356
|
-
puts "Running command: '#{command}'" if @
|
370
|
+
puts "Running command: '#{command}'" if @verbose
|
357
371
|
system(command) || error("Error running coverage report")
|
358
372
|
ensure
|
359
373
|
Dir.chdir(prev_dir)
|
@@ -363,11 +377,11 @@ module Bee
|
|
363
377
|
command = "python #{coverage} -r -f #{data} -m #{sources} > #{report}"
|
364
378
|
system(command) || error("Error generating coverage report")
|
365
379
|
command = "python #{coverage} -a -f #{data} -d #{dest} #{sources}"
|
366
|
-
puts "Running command: '#{command}'" if @
|
380
|
+
puts "Running command: '#{command}'" if @verbose
|
367
381
|
system(command) || error("Error generating coverage report")
|
368
382
|
else
|
369
383
|
command = "python #{coverage} -r -f #{data} -m #{sources}"
|
370
|
-
puts "Running command: '#{command}'" if @
|
384
|
+
puts "Running command: '#{command}'" if @verbose
|
371
385
|
system(command) || error("Error generating coverage report")
|
372
386
|
end
|
373
387
|
end
|
@@ -379,8 +393,7 @@ module Bee
|
|
379
393
|
def add_python_path(dirs)
|
380
394
|
if dirs and dirs.length > 0
|
381
395
|
dirs = Array(dirs)
|
382
|
-
puts "Adding to PYTHONPATH: '#{dirs.join(',')}'" if
|
383
|
-
@build.listener.verbose
|
396
|
+
puts "Adding to PYTHONPATH: '#{dirs.join(',')}'" if @verbose
|
384
397
|
if ENV['PYTHONPATH']
|
385
398
|
ENV['PYTHONPATH'] = dirs.join(File::PATH_SEPARATOR) +
|
386
399
|
File::PATH_SEPARATOR + ENV['PYTHONPATH'] if dirs.length > 0
|
data/test/tc_bee_task_python.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'bee'
|
4
3
|
require 'test/unit'
|
5
4
|
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__))))
|
5
|
+
require 'bee_context'
|
6
6
|
require 'test_build'
|
7
7
|
require 'test_build_listener'
|
8
8
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
@@ -14,7 +14,7 @@ class TestBeeTaskPython < Test::Unit::TestCase
|
|
14
14
|
# Create a context object and load tasks in it.
|
15
15
|
def setup
|
16
16
|
super
|
17
|
-
@context = Bee::Context.new(
|
17
|
+
@context = Bee::Context.new()
|
18
18
|
@listener = TestBuildListener.new
|
19
19
|
@build = TestBuild.new(@context, @listener)
|
20
20
|
@package = Bee::Task::Python.new(@build)
|
data/test/test_build_listener.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2006-
|
1
|
+
# Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,30 +12,29 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
|
15
|
+
require 'rubygems'
|
16
|
+
|
16
17
|
class TestBuildListener
|
17
18
|
|
19
|
+
attr_reader :formatter
|
18
20
|
attr_reader :started
|
19
21
|
attr_reader :finished
|
20
22
|
attr_reader :targets
|
21
23
|
attr_reader :tasks
|
22
24
|
attr_reader :success
|
23
25
|
attr_reader :errors
|
24
|
-
attr_accessor :
|
25
|
-
|
26
|
-
|
27
|
-
def initialize
|
28
|
-
|
29
|
-
@tasks = []
|
30
|
-
@output = ''
|
31
|
-
@verbose = false
|
26
|
+
attr_accessor :throw_error
|
27
|
+
attr_accessor :prompt
|
28
|
+
|
29
|
+
def initialize()
|
30
|
+
reset
|
32
31
|
end
|
33
|
-
|
34
|
-
def build_started(build)
|
32
|
+
|
33
|
+
def build_started(build, dry=false)
|
35
34
|
@started = true
|
36
35
|
end
|
37
36
|
|
38
|
-
def build_finished(
|
37
|
+
def build_finished()
|
39
38
|
@finished = true
|
40
39
|
end
|
41
40
|
|
@@ -44,11 +43,56 @@ class TestBuildListener
|
|
44
43
|
end
|
45
44
|
|
46
45
|
def task(task)
|
47
|
-
@tasks <<
|
46
|
+
@tasks << task
|
48
47
|
end
|
49
48
|
|
50
49
|
def error(exception)
|
51
|
-
|
50
|
+
if throw_error
|
51
|
+
raise exception
|
52
|
+
else
|
53
|
+
@errors << exception
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def recover
|
58
|
+
@success = true
|
59
|
+
end
|
60
|
+
|
61
|
+
def reset
|
62
|
+
@formatter = TestBuildFormatter.new(self)
|
63
|
+
@started = false
|
64
|
+
@finished = false
|
65
|
+
@targets = []
|
66
|
+
@tasks = []
|
67
|
+
@success = false
|
68
|
+
@errors = []
|
69
|
+
@throw_error = false
|
70
|
+
@prompt = ''
|
71
|
+
end
|
72
|
+
|
73
|
+
def output()
|
74
|
+
return @formatter.output
|
75
|
+
end
|
76
|
+
|
77
|
+
def clear()
|
78
|
+
@formatter.clear()
|
79
|
+
end
|
80
|
+
|
81
|
+
def error?
|
82
|
+
return @errors.length > 0
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
class TestBuildFormatter
|
88
|
+
|
89
|
+
attr_reader :verbose
|
90
|
+
attr_reader :output
|
91
|
+
|
92
|
+
def initialize(listener)
|
93
|
+
@listener = listener
|
94
|
+
@verbose = false
|
95
|
+
@output = ''
|
52
96
|
end
|
53
97
|
|
54
98
|
def print(text)
|
@@ -59,4 +103,8 @@ class TestBuildListener
|
|
59
103
|
@output << text + "\n"
|
60
104
|
end
|
61
105
|
|
106
|
+
def clear()
|
107
|
+
@output = ''
|
108
|
+
end
|
109
|
+
|
62
110
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bee_python
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Casabianca
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2011-02-17 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.11.0
|
24
24
|
version:
|
25
25
|
description:
|
26
26
|
email: michel.casabianca@gmail.com
|