rake-tester 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.markdown +7 -0
- data/LICENSE.txt +23 -0
- data/README.markdown +91 -0
- data/Rakefile +30 -0
- data/lib/rake/extensiontesttask.rb +114 -0
- metadata +60 -0
data/HISTORY.markdown
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2009 Fabian Streitel
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
data/README.markdown
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# rake-tester #
|
2
|
+
|
3
|
+
<http://www.github.com/karottenreibe/rake-tester>
|
4
|
+
|
5
|
+
An extension of the [rake-compiler][rakecompiler] that allows
|
6
|
+
for automatic compilation of C test suites, e.g. using
|
7
|
+
[cmockery].
|
8
|
+
|
9
|
+
|
10
|
+
## Features/Limitations ##
|
11
|
+
|
12
|
+
* Automatically compiles and executes test suites of
|
13
|
+
arbitrary C testing frameworks
|
14
|
+
* Can batch-execute all suites or selectively run a single suite
|
15
|
+
* Can only compile the tests for your current platform
|
16
|
+
* Thus, no cross compilation of the tests
|
17
|
+
* Support for running the tests with valgrind or gdb
|
18
|
+
|
19
|
+
|
20
|
+
## Installation ##
|
21
|
+
|
22
|
+
gem install rake-tester
|
23
|
+
|
24
|
+
|
25
|
+
## Usage ##
|
26
|
+
|
27
|
+
In the Rakefile:
|
28
|
+
|
29
|
+
require 'rake/extensiontask'
|
30
|
+
require 'rake/extensiontesttask'
|
31
|
+
|
32
|
+
Rake::ExtensionTask.new(...) do |ext|
|
33
|
+
# ... confgure as normal
|
34
|
+
|
35
|
+
ext.test_files = FileList['test/c/*']
|
36
|
+
ext.test_includes << '/usr/include/frood_stuff'
|
37
|
+
ext.test_libraries << 'zaphods_heads'
|
38
|
+
ext.test_lib_folders << '/usr/lib/floopy'
|
39
|
+
end
|
40
|
+
|
41
|
+
Write your tests.
|
42
|
+
|
43
|
+
To test everything:
|
44
|
+
|
45
|
+
$ rake test:c
|
46
|
+
|
47
|
+
To test one extension:
|
48
|
+
|
49
|
+
$ rake test:c:extension
|
50
|
+
|
51
|
+
To execute one test suite:
|
52
|
+
|
53
|
+
$ rake test:c:extension[test_feature]
|
54
|
+
|
55
|
+
To use valgrind:
|
56
|
+
|
57
|
+
$ rake test:valgrind:extension[test_feature]
|
58
|
+
|
59
|
+
To use gdb:
|
60
|
+
|
61
|
+
$ rake test:gdb:extension[test_feature]
|
62
|
+
|
63
|
+
|
64
|
+
## License ##
|
65
|
+
|
66
|
+
Copyright (c) 2009 Fabian Streitel
|
67
|
+
|
68
|
+
Permission is hereby granted, free of charge, to any person
|
69
|
+
obtaining a copy of this software and associated documentation
|
70
|
+
files (the "Software"), to deal in the Software without
|
71
|
+
restriction, including without limitation the rights to use,
|
72
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
73
|
+
copies of the Software, and to permit persons to whom the
|
74
|
+
Software is furnished to do so, subject to the following
|
75
|
+
conditions:
|
76
|
+
|
77
|
+
The above copyright notice and this permission notice shall be
|
78
|
+
included in all copies or substantial portions of the Software.
|
79
|
+
|
80
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
81
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
82
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
83
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
84
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
85
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
86
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
87
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
88
|
+
|
89
|
+
[rakecompiler]: http://github.com/luislavena/rake-compiler "The rake-compile project"
|
90
|
+
[cmockery]: http://code.google.com/p/cmockery/ "The cmockery C testing framework"
|
91
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
task :release do
|
3
|
+
sh "vim HISTORY.markdown"
|
4
|
+
sh "vim README.markdown"
|
5
|
+
sh "git commit -a -m 'prerelease adjustments'; true"
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'jeweler'
|
9
|
+
jeweler_tasks = Jeweler::Tasks.new do |gem|
|
10
|
+
gem.name = 'rake-tester'
|
11
|
+
gem.summary = 'rake-tester is an extension to the rake-compiler that maintains C test suites'
|
12
|
+
gem.description = gem.summary
|
13
|
+
gem.email = 'karottenreibe@gmail.com'
|
14
|
+
gem.homepage = 'http://github.com/karottenreibe/rake-tester'
|
15
|
+
gem.authors = ['Fabian Streitel']
|
16
|
+
gem.rubyforge_project = 'k-gems'
|
17
|
+
end
|
18
|
+
|
19
|
+
Jeweler::RubyforgeTasks.new
|
20
|
+
Jeweler::GemcutterTasks.new
|
21
|
+
|
22
|
+
|
23
|
+
require 'rake/rdoctask'
|
24
|
+
Rake::RDocTask.new do |rdoc|
|
25
|
+
rdoc.rdoc_dir = 'rdoc'
|
26
|
+
rdoc.title = 'Joker'
|
27
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
28
|
+
rdoc.rdoc_files.include('ext/**/*.rb')
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rake/extensiontask'
|
3
|
+
|
4
|
+
module Rake
|
5
|
+
|
6
|
+
class ExtensionTask
|
7
|
+
|
8
|
+
#
|
9
|
+
# The C files to compile.
|
10
|
+
#
|
11
|
+
attr_accessor :test_files
|
12
|
+
|
13
|
+
#
|
14
|
+
# The folders where includes for the test files are.
|
15
|
+
#
|
16
|
+
# Default: %w{/usr/include /usr/include/google}
|
17
|
+
#
|
18
|
+
attr_accessor :test_includes
|
19
|
+
|
20
|
+
#
|
21
|
+
# The libraries to link against.
|
22
|
+
#
|
23
|
+
# Default: %w{cmockery}
|
24
|
+
#
|
25
|
+
attr_accessor :test_libraries
|
26
|
+
|
27
|
+
#
|
28
|
+
# The folders where the libraries are
|
29
|
+
#
|
30
|
+
# Default: %w{/usr/lib}
|
31
|
+
#
|
32
|
+
attr_accessor :test_lib_folders
|
33
|
+
|
34
|
+
alias_method :initialize_old, :initialize
|
35
|
+
|
36
|
+
def initialize( *args, &block )
|
37
|
+
@test_files = Array.new
|
38
|
+
@test_includes = %w{/usr/include /usr/include/google}
|
39
|
+
@test_libraries = %w{cmockery}
|
40
|
+
@test_lib_folders = %w{/usr/lib}
|
41
|
+
|
42
|
+
initialize_old(*args, &block)
|
43
|
+
init_test_tasks()
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def init_test_tasks
|
49
|
+
# some stuff we need often later on
|
50
|
+
compile_dir = "#{@tmp_dir}/test"
|
51
|
+
compile_task = "compile:#{@name}:test"
|
52
|
+
test_task = "test:c:#{@name}"
|
53
|
+
valgrind_task = "test:valgrind:#{@name}"
|
54
|
+
gdb_task = "test:gdb:#{@name}"
|
55
|
+
|
56
|
+
directory compile_dir
|
57
|
+
|
58
|
+
desc "Compile #{@name} tests"
|
59
|
+
task compile_task => ["compile:#{@name}", compile_dir] do
|
60
|
+
# copy the test files into the compilation folder
|
61
|
+
@test_files.each { |file| cp file, compile_dir }
|
62
|
+
|
63
|
+
# start compilation
|
64
|
+
chdir(compile_dir) do
|
65
|
+
includes = (@test_includes + [
|
66
|
+
".",
|
67
|
+
"../../#{@ext_dir}",
|
68
|
+
"/usr/include/ruby-#{RUBY_VERSION}",
|
69
|
+
"/usr/include/ruby-#{RUBY_VERSION}/#{RUBY_PLATFORM}",
|
70
|
+
]).map { |l| '-I' + l }.join(' ')
|
71
|
+
|
72
|
+
# compile the test sources
|
73
|
+
FileList['*.c'].each do |cfile|
|
74
|
+
sh "gcc -g #{includes} -c #{cfile}"
|
75
|
+
end
|
76
|
+
|
77
|
+
source_objects = FileList["../#{RUBY_PLATFORM}/#{@name}/#{RUBY_VERSION}/*.o"]
|
78
|
+
libraries = (@test_libraries + %w{ruby pthread crypto}).map { |l| '-l' + l }.join(' ')
|
79
|
+
lib_folders = (@test_lib_folders + %w{/usr/lib .}).map { |l| '-L' + l }.join(' ')
|
80
|
+
|
81
|
+
# link the executables
|
82
|
+
FileList['*.o'].each do |ofile|
|
83
|
+
sh "gcc -g #{lib_folders} #{libraries} #{source_objects} #{ofile} -o #{ofile.ext}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "Execute valgrind for a #{@name} test"
|
89
|
+
task valgrind_task, :test, :needs => [compile_task] do |t,args|
|
90
|
+
sh "valgrind --num-callers=50 --error-limit=no --partial-loads-ok=yes --undef-value-errors=no --leak-check=full #{compile_dir}/#{args.test}"
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "Execute gdb for a #{@name} test"
|
94
|
+
task gdb_task, :test, :needs => [compile_task] do |t,args|
|
95
|
+
sh "gdb #{compile_dir}/#{args.test}"
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "Test #{@name}"
|
99
|
+
task test_task, :test, :needs => [compile_task] do |t,args|
|
100
|
+
if args.test
|
101
|
+
sh "#{compile_dir}/#{args.test}"
|
102
|
+
else
|
103
|
+
FileList["#{compile_dir}/*.o"].each do |ofile|
|
104
|
+
sh "#{ofile.ext}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
desc "Test all C extensions"
|
110
|
+
task 'test:c' => [test_task]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake-tester
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fabian Streitel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-15 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: rake-tester is an extension to the rake-compiler that maintains C test suites
|
17
|
+
email: karottenreibe@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.markdown
|
25
|
+
files:
|
26
|
+
- HISTORY.markdown
|
27
|
+
- LICENSE.txt
|
28
|
+
- README.markdown
|
29
|
+
- Rakefile
|
30
|
+
- lib/rake/extensiontesttask.rb
|
31
|
+
has_rdoc: true
|
32
|
+
homepage: http://github.com/karottenreibe/rake-tester
|
33
|
+
licenses: []
|
34
|
+
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options:
|
37
|
+
- --charset=UTF-8
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
requirements: []
|
53
|
+
|
54
|
+
rubyforge_project: k-gems
|
55
|
+
rubygems_version: 1.3.5
|
56
|
+
signing_key:
|
57
|
+
specification_version: 3
|
58
|
+
summary: rake-tester is an extension to the rake-compiler that maintains C test suites
|
59
|
+
test_files: []
|
60
|
+
|