cxxproject 0.5.76 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/Rakefile.rb +116 -116
  2. data/bin/cxx +10 -10
  3. data/lib/cxxproject/buildingblocks/binary_library.rb +39 -39
  4. data/lib/cxxproject/buildingblocks/building_block.rb +251 -234
  5. data/lib/cxxproject/buildingblocks/command_line.rb +79 -86
  6. data/lib/cxxproject/buildingblocks/custom_building_block.rb +39 -39
  7. data/lib/cxxproject/buildingblocks/executable.rb +246 -258
  8. data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +83 -83
  9. data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -20
  10. data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +34 -34
  11. data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +371 -379
  12. data/lib/cxxproject/buildingblocks/makefile.rb +153 -153
  13. data/lib/cxxproject/buildingblocks/module.rb +35 -35
  14. data/lib/cxxproject/buildingblocks/single_source.rb +33 -33
  15. data/lib/cxxproject/buildingblocks/source_library.rb +124 -111
  16. data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -40
  17. data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +41 -41
  18. data/lib/cxxproject/errorparser/error_parser.rb +50 -71
  19. data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +35 -35
  20. data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +35 -35
  21. data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -30
  22. data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +30 -30
  23. data/lib/cxxproject/eval_context.rb +144 -144
  24. data/lib/cxxproject/ext/file.rb +71 -81
  25. data/lib/cxxproject/ext/filelist.rb +6 -6
  26. data/lib/cxxproject/ext/progressbar.rb +20 -0
  27. data/lib/cxxproject/ext/rake.rb +419 -434
  28. data/lib/cxxproject/ext/rake_dirty.rb +30 -30
  29. data/lib/cxxproject/ext/rake_listener.rb +59 -59
  30. data/lib/cxxproject/ext/stdout.rb +44 -44
  31. data/lib/cxxproject/ext/string.rb +9 -9
  32. data/lib/cxxproject/ide_interface.rb +187 -189
  33. data/lib/cxxproject/toolchain/clang.rb +39 -43
  34. data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -99
  35. data/lib/cxxproject/toolchain/diab.rb +1 -1
  36. data/lib/cxxproject/toolchain/gcc.rb +1 -1
  37. data/lib/cxxproject/toolchain/provider.rb +131 -143
  38. data/lib/cxxproject/toolchain/toolchain.rb +38 -38
  39. data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -23
  40. data/lib/cxxproject/torake.rb +259 -218
  41. data/lib/cxxproject/utils/cleanup.rb +20 -24
  42. data/lib/cxxproject/utils/console.rb +6 -6
  43. data/lib/cxxproject/utils/exit_helper.rb +40 -40
  44. data/lib/cxxproject/utils/graphstream.rb +154 -154
  45. data/lib/cxxproject/utils/optional.rb +16 -16
  46. data/lib/cxxproject/utils/printer.rb +50 -50
  47. data/lib/cxxproject/utils/process.rb +52 -58
  48. data/lib/cxxproject/utils/progress.rb +66 -0
  49. data/lib/cxxproject/utils/progress_helper.rb +77 -0
  50. data/lib/cxxproject/utils/rbcurse.rb +284 -0
  51. data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -0
  52. data/lib/cxxproject/utils/rbcurse_progress.rb +71 -0
  53. data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -0
  54. data/lib/cxxproject/utils/stats.rb +60 -60
  55. data/lib/cxxproject/utils/ubigraph.rb +228 -228
  56. data/lib/cxxproject/utils/utils.rb +37 -69
  57. data/lib/cxxproject/version.rb +7 -7
  58. data/lib/cxxproject.rb +23 -19
  59. data/lib/tools/Rakefile.rb.template +10 -10
  60. data/lib/tools/project.rb.template +6 -6
  61. data/lib/tools/project_wizard.rb +66 -66
  62. data/spec/building_block_spec.rb +56 -56
  63. data/spec/cxxproject_2_rake_spec.rb +186 -186
  64. data/spec/file_ext_spec.rb +30 -30
  65. data/spec/ide_interface_spec.rb +41 -41
  66. data/spec/object_dependency_spec.rb +83 -83
  67. data/spec/project_path_spec.rb +71 -71
  68. data/spec/rake_listener_ext_spec.rb +58 -58
  69. data/spec/spec_helper.rb +18 -18
  70. data/spec/string_spec.rb +11 -11
  71. data/spec/testdata/basic/exe12/project.rb +5 -5
  72. data/spec/testdata/basic/lib1/project.rb +5 -5
  73. data/spec/testdata/basic/lib2/project.rb +8 -8
  74. data/spec/testdata/multiple_levels/libs/lib1/project.rb +5 -5
  75. data/spec/testdata/multiple_levels/libs/lib2/project.rb +19 -19
  76. data/spec/testdata/multiple_levels/mainproject/basic/project.rb +8 -8
  77. data/spec/testdata/onlyOneHeader/Rakefile.rb +4 -4
  78. data/spec/testdata/onlyOneHeader/project.rb +4 -4
  79. data/spec/toolchain_spec.rb +29 -29
  80. metadata +116 -107
  81. checksums.yaml +0 -7
  82. data/lib/cxxproject/buildingblocks/lint.rb +0 -89
  83. data/lib/cxxproject/errorparser/gcc_lint_error_parser.rb +0 -34
  84. data/lib/cxxproject/errorparser/greenhills_compiler_error_parser.rb +0 -32
  85. data/lib/cxxproject/errorparser/greenhills_linker_error_parser.rb +0 -44
  86. data/lib/cxxproject/errorparser/keil_compiler_error_parser.rb +0 -40
  87. data/lib/cxxproject/errorparser/keil_linker_error_parser.rb +0 -30
  88. data/lib/cxxproject/toolchain/gcc_lint.rb +0 -21
  89. data/lib/cxxproject/toolchain/gcc_param.rb +0 -7
  90. data/lib/cxxproject/toolchain/greenhills.rb +0 -51
  91. data/lib/cxxproject/toolchain/keil.rb +0 -52
  92. data/lib/cxxproject/utils/valgrind.rb +0 -11
@@ -1,30 +1,30 @@
1
- require 'spec_helper'
2
- require 'cxxproject'
3
-
4
- describe File do
5
-
6
- it 'should calc if a pathname is absolute' do
7
- File.is_absolute?('/test').should eq(true)
8
- File.is_absolute?('a:test').should eq(true)
9
- File.is_absolute?('test').should eq(false)
10
- end
11
-
12
- it 'should find a good relative directory for subdirectories' do
13
- File.rel_from_to_project('x/main/a', 'x/main/b').should eq('../b/')
14
- File.rel_from_to_project('x/main/a/b', 'x/main').should eq('../../')
15
- File.rel_from_to_project('x/main', 'x/main/a/b').should eq('a/b/')
16
- File.rel_from_to_project('x/main', 'x/main').should eq('')
17
- File.rel_from_to_project('x/main', nil).should eq(nil)
18
- File.rel_from_to_project(nil, 'x/main').should eq(nil)
19
- File.rel_from_to_project('x/a', 'y/b').should eq("../../y/b/")
20
- File.rel_from_to_project('x/x', 'x/x').should eq('')
21
- end
22
-
23
- it 'add prefix only if file is not absolute' do
24
- File.add_prefix('abc/', '/usr/local').should eq('/usr/local')
25
- File.add_prefix('abc/', 'nix/usr/local').should eq('abc/nix/usr/local')
26
- File.add_prefix('abc/', 'c:/usr/local').should eq('c:/usr/local')
27
- File.add_prefix('abc/', 'c:\\usr/local').should eq('c:\\usr/local')
28
- end
29
-
30
- end
1
+ require 'spec_helper'
2
+ require 'cxxproject'
3
+
4
+ describe File do
5
+
6
+ it 'should calc if a pathname is absolute' do
7
+ File.is_absolute?('/test').should eq(true)
8
+ File.is_absolute?('a:test').should eq(true)
9
+ File.is_absolute?('test').should eq(false)
10
+ end
11
+
12
+ it 'should find a good relative directory for subdirectories' do
13
+ File.rel_from_to_project('x/main/a', 'x/main/b').should eq('../b/')
14
+ File.rel_from_to_project('x/main/a/b', 'x/main').should eq('../../')
15
+ File.rel_from_to_project('x/main', 'x/main/a/b').should eq('a/b/')
16
+ File.rel_from_to_project('x/main', 'x/main').should eq('')
17
+ File.rel_from_to_project('x/main', nil).should eq(nil)
18
+ File.rel_from_to_project(nil, 'x/main').should eq(nil)
19
+ File.rel_from_to_project('x/a', 'y/b').should eq("../../y/b/")
20
+ File.rel_from_to_project('x/x', 'x/x').should eq('')
21
+ end
22
+
23
+ it 'add prefix only if file is not absolute' do
24
+ File.add_prefix('abc/', '/usr/local').should eq('/usr/local')
25
+ File.add_prefix('abc/', 'nix/usr/local').should eq('abc/nix/usr/local')
26
+ File.add_prefix('abc/', 'c:/usr/local').should eq('c:/usr/local')
27
+ File.add_prefix('abc/', 'c:\\usr/local').should eq('c:\\usr/local')
28
+ end
29
+
30
+ end
@@ -1,41 +1,41 @@
1
- require 'spec_helper'
2
- require 'cxxproject/ide_interface'
3
- require 'cxxproject/utils/utils'
4
- require 'cxxproject/errorparser/error_parser'
5
-
6
- def check_long(e, l)
7
- e.next.should eq(l)
8
- e.next.should eq(0)
9
- e.next.should eq(0)
10
- e.next.should eq(0)
11
- end
12
- def check_string(e, s)
13
- s.bytes do |i|
14
- e.next.should eq(i)
15
- end
16
- end
17
-
18
- describe Cxxproject::IDEInterface do
19
-
20
- it 'should create a correct package from an error-array' do
21
- ide = Cxxproject::IDEInterface.new
22
- error = Cxxproject::ErrorDesc.new
23
- error.severity = 2
24
- error.line_number = 10
25
- error.file_name = 'filename'
26
- error.message = 'error'
27
- packet = ide.create_error_packet(error)
28
-
29
- if not Cxxproject::Utils.old_ruby? # in Ruby 1.8.6 there is no bytes methods...
30
- e = packet.bytes.to_enum
31
- e.next.should eq(1)
32
- check_long(e, 22)
33
- check_long(e, 8)
34
- check_string(e, 'filename')
35
- check_long(e, 10)
36
- e.next.should eq(2)
37
- check_string(e, 'error')
38
- end
39
- end
40
-
41
- end
1
+ require 'spec_helper'
2
+ require 'cxxproject/ide_interface'
3
+ require 'cxxproject/utils/utils'
4
+ require 'cxxproject/errorparser/error_parser'
5
+
6
+ def check_long(e, l)
7
+ e.next.should eq(l)
8
+ e.next.should eq(0)
9
+ e.next.should eq(0)
10
+ e.next.should eq(0)
11
+ end
12
+ def check_string(e, s)
13
+ s.bytes do |i|
14
+ e.next.should eq(i)
15
+ end
16
+ end
17
+
18
+ describe Cxxproject::IDEInterface do
19
+
20
+ it 'should create a correct package from an error-array' do
21
+ ide = Cxxproject::IDEInterface.new
22
+ error = Cxxproject::ErrorDesc.new
23
+ error.severity = 2
24
+ error.line_number = 10
25
+ error.file_name = 'filename'
26
+ error.message = 'error'
27
+ packet = ide.create_error_packet(error)
28
+
29
+ if not Cxxproject::Utils.old_ruby? # in Ruby 1.8.6 there is no bytes methods...
30
+ e = packet.bytes
31
+ e.next.should eq(1)
32
+ check_long(e, 22)
33
+ check_long(e, 8)
34
+ check_string(e, 'filename')
35
+ check_long(e, 10)
36
+ e.next.should eq(2)
37
+ check_string(e, 'error')
38
+ end
39
+ end
40
+
41
+ end
@@ -1,83 +1,83 @@
1
- require 'spec_helper'
2
- require 'cxxproject'
3
- require 'cxxproject/ext/rake_listener.rb'
4
- require 'cxxproject/utils/cleanup'
5
-
6
- describe Rake::Task do
7
-
8
- before(:each) do
9
- Rake::application.options.silent = true
10
- Cxxproject::Utils.cleanup_rake
11
- end
12
- after(:each) do
13
- Cxxproject::Utils.cleanup_rake
14
- end
15
-
16
- it 'should fail if source of object is missing' do
17
- file 'test.cc' => 'compiler'
18
- File.delete('test.cc') if File.exists?('test.cc')
19
- sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
20
- cxx = CxxProject2Rake.new([], 'build', GCCChain)
21
-
22
- task = Rake::application['lib:testlib']
23
- task.invoke
24
- task.failure.should eq(true)
25
-
26
- FileUtils.rm_rf('build')
27
- end
28
-
29
- it 'should not fail if include-dependency of object is missing' do
30
- File.open('test.cc', 'w') do |io|
31
- io.puts('#include "test.h"')
32
- end
33
-
34
- File.open('test.h', 'w') do |io|
35
- end
36
-
37
- sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
38
- CxxProject2Rake.new([], 'build', GCCChain)
39
-
40
- task = Rake::application['lib:testlib']
41
- task.invoke
42
- task.failure.should eq(false)
43
-
44
- Cxxproject::Utils.cleanup_rake
45
-
46
- FileUtils.rm_rf('test.h')
47
- File.open('test.cc', 'w') do |io|
48
- end
49
-
50
- sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
51
- CxxProject2Rake.new([], 'build', GCCChain)
52
-
53
- task = Rake::application['build/libs/libtestlib.a']
54
- task.invoke
55
- task.failure.should eq(false)
56
-
57
- FileUtils.rm_rf('test.cc')
58
- end
59
-
60
- it 'should not fail if generated headerfile is missing' do
61
- file 'test.h' do
62
- sh 'touch test.h'
63
- end
64
-
65
- file 'test.cc' => 'test.h' do |t|
66
- File.open(t.name, 'w') do |io|
67
- io.puts('#include "test.h"')
68
- end
69
- end
70
-
71
- sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
72
- CxxProject2Rake.new([], 'build', GCCChain)
73
-
74
- task = Rake::application['build/libs/libtestlib.a']
75
- task.invoke
76
- task.failure.should eq(false)
77
-
78
- FileUtils.rm_rf('build')
79
- FileUtils.rm_rf('test.cc')
80
- FileUtils.rm_rf('test.h')
81
- end
82
-
83
- end
1
+ require 'spec_helper'
2
+ require 'cxxproject'
3
+ require 'cxxproject/ext/rake_listener.rb'
4
+ require 'cxxproject/utils/cleanup'
5
+
6
+ describe Rake::Task do
7
+
8
+ before(:each) do
9
+ Rake::application.options.silent = true
10
+ Cxxproject::Utils.cleanup_rake
11
+ end
12
+ after(:each) do
13
+ Cxxproject::Utils.cleanup_rake
14
+ end
15
+
16
+ it 'should fail if source of object is missing' do
17
+ file 'test.cc' => 'compiler'
18
+ File.delete('test.cc') if File.exists?('test.cc')
19
+ sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
20
+ cxx = CxxProject2Rake.new([], 'build', GCCChain)
21
+
22
+ task = Rake::application['lib:testlib']
23
+ task.invoke
24
+ task.failure.should eq(true)
25
+
26
+ FileUtils.rm_rf('build')
27
+ end
28
+
29
+ it 'should not fail if include-dependency of object is missing' do
30
+ File.open('test.cc', 'w') do |io|
31
+ io.puts('#include "test.h"')
32
+ end
33
+
34
+ File.open('test.h', 'w') do |io|
35
+ end
36
+
37
+ sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
38
+ CxxProject2Rake.new([], 'build', GCCChain)
39
+
40
+ task = Rake::application['lib:testlib']
41
+ task.invoke
42
+ task.failure.should eq(false)
43
+
44
+ Cxxproject::Utils.cleanup_rake
45
+
46
+ FileUtils.rm_rf('test.h')
47
+ File.open('test.cc', 'w') do |io|
48
+ end
49
+
50
+ sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
51
+ CxxProject2Rake.new([], 'build', GCCChain)
52
+
53
+ task = Rake::application['build/libs/libtestlib.a']
54
+ task.invoke
55
+ task.failure.should eq(false)
56
+
57
+ FileUtils.rm_rf('test.cc')
58
+ end
59
+
60
+ it 'should not fail if generated headerfile is missing' do
61
+ file 'test.h' do
62
+ sh 'touch test.h'
63
+ end
64
+
65
+ file 'test.cc' => 'test.h' do |t|
66
+ File.open(t.name, 'w') do |io|
67
+ io.puts('#include "test.h"')
68
+ end
69
+ end
70
+
71
+ sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
72
+ CxxProject2Rake.new([], 'build', GCCChain)
73
+
74
+ task = Rake::application['build/libs/libtestlib.a']
75
+ task.invoke
76
+ task.failure.should eq(false)
77
+
78
+ FileUtils.rm_rf('build')
79
+ FileUtils.rm_rf('test.cc')
80
+ FileUtils.rm_rf('test.h')
81
+ end
82
+
83
+ end
@@ -1,71 +1,71 @@
1
- require 'spec_helper'
2
- require 'cxxproject'
3
- require 'cxxproject/utils/cleanup'
4
-
5
- RSPECDIR = File.dirname(__FILE__)
6
-
7
- describe CxxProject2Rake do
8
-
9
- def execute_all_tasks(tasks)
10
- tasks.each do |t|
11
- t.invoke
12
- end
13
- end
14
-
15
- def fresh_cxx(outputdir,base)
16
- Cxxproject::Utils.cleanup_rake
17
- project_configs = nil
18
- cd base do # have to be relative to base
19
- project_configs = Dir.glob('**/project.rb')
20
- end
21
- CxxProject2Rake.new(project_configs, outputdir, GCCChain, base)
22
- end
23
-
24
-
25
- # def is_older? fileA, fileB
26
- # File.mtime(fileA) < File.mtime(fileB)
27
- # end
28
-
29
- # def is_newer? fileA, fileB
30
- # File.mtime(fileA) > File.mtime(fileB)
31
- # end
32
-
33
- def test_on_level(base, outputdir)
34
- libOne = "#{outputdir}/libs/lib1.a"
35
- libTwo = "#{outputdir}/libs/lib2.a"
36
- exe = "#{outputdir}/basic.exe"
37
- exe2 = "#{outputdir}/debug.exe"
38
-
39
- rm_r outputdir if File.directory?(outputdir)
40
- tasks = fresh_cxx(outputdir, base).all_tasks
41
- CLOBBER.each { |fn| rm_r fn rescue nil }
42
-
43
- [libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_false }
44
-
45
- execute_all_tasks(tasks)
46
-
47
- [libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_true }
48
-
49
- # cleanup
50
- rm_r outputdir if File.directory?(outputdir)
51
- Cxxproject::Utils.cleanup_rake
52
- end
53
-
54
- it 'should resolve paths on different levels' do
55
- outputdir = 'output'
56
-
57
- cd("#{RSPECDIR}/testdata/multiple_levels", :verbose => false) do
58
- test_on_level(".", outputdir)
59
- end
60
-
61
- cd("#{RSPECDIR}/testdata/multiple_levels/mainproject", :verbose => false) do
62
- test_on_level("..", outputdir)
63
- end
64
-
65
- cd("#{RSPECDIR}/testdata", :verbose => false) do
66
- test_on_level("multiple_levels/", outputdir)
67
- end
68
- end
69
-
70
- end
71
-
1
+ require 'spec_helper'
2
+ require 'cxxproject'
3
+ require 'cxxproject/utils/cleanup'
4
+
5
+ RSPECDIR = File.dirname(__FILE__)
6
+
7
+ describe CxxProject2Rake do
8
+
9
+ def execute_all_tasks(tasks)
10
+ tasks.each do |t|
11
+ t.invoke
12
+ end
13
+ end
14
+
15
+ def fresh_cxx(outputdir,base)
16
+ Cxxproject::Utils.cleanup_rake
17
+ project_configs = nil
18
+ cd base do # have to be relative to base
19
+ project_configs = Dir.glob('**/project.rb')
20
+ end
21
+ CxxProject2Rake.new(project_configs, outputdir, GCCChain, base)
22
+ end
23
+
24
+
25
+ # def is_older? fileA, fileB
26
+ # File.mtime(fileA) < File.mtime(fileB)
27
+ # end
28
+
29
+ # def is_newer? fileA, fileB
30
+ # File.mtime(fileA) > File.mtime(fileB)
31
+ # end
32
+
33
+ def test_on_level(base, outputdir)
34
+ libOne = "#{outputdir}/libs/lib1.a"
35
+ libTwo = "#{outputdir}/libs/lib2.a"
36
+ exe = "#{outputdir}/basic.exe"
37
+ exe2 = "#{outputdir}/debug.exe"
38
+
39
+ rm_r outputdir if File.directory?(outputdir)
40
+ tasks = fresh_cxx(outputdir, base).all_tasks
41
+ CLOBBER.each { |fn| rm_r fn rescue nil }
42
+
43
+ [libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_false }
44
+
45
+ execute_all_tasks(tasks)
46
+
47
+ [libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_true }
48
+
49
+ # cleanup
50
+ rm_r outputdir if File.directory?(outputdir)
51
+ Cxxproject::Utils.cleanup_rake
52
+ end
53
+
54
+ it 'should resolve paths on different levels' do
55
+ outputdir = 'output'
56
+
57
+ cd("#{RSPECDIR}/testdata/multiple_levels", :verbose => false) do
58
+ test_on_level(".", outputdir)
59
+ end
60
+
61
+ cd("#{RSPECDIR}/testdata/multiple_levels/mainproject", :verbose => false) do
62
+ test_on_level("..", outputdir)
63
+ end
64
+
65
+ cd("#{RSPECDIR}/testdata", :verbose => false) do
66
+ test_on_level("multiple_levels/", outputdir)
67
+ end
68
+ end
69
+
70
+ end
71
+
@@ -1,58 +1,58 @@
1
- require 'spec_helper'
2
- require 'cxxproject'
3
- require 'cxxproject/ext/rake_listener.rb'
4
- require 'cxxproject/utils/cleanup'
5
-
6
- describe Rake::Task do
7
-
8
- before(:each) do
9
- Cxxproject::Utils.cleanup_rake
10
- end
11
- after(:each) do
12
- Cxxproject::Utils.cleanup_rake
13
- end
14
-
15
-
16
- it "should call a listener for prerequisites and execute" do
17
- task "mypre"
18
- t = task "test" => "mypre"
19
-
20
- l = mock
21
- Rake::add_listener(l)
22
-
23
- l.should_receive(:before_execute).with('mypre')
24
- l.should_receive(:after_execute).with('mypre')
25
- l.should_receive(:before_prerequisites).with('mypre')
26
- l.should_receive(:after_prerequisites).with('mypre')
27
- l.should_receive(:before_prerequisites).with('test')
28
- l.should_receive(:after_prerequisites).with('test')
29
- l.should_receive(:before_execute).with('test')
30
- l.should_receive(:after_execute).with('test')
31
- t.invoke
32
-
33
- Rake::remove_listener(l)
34
-
35
- t.invoke
36
- end
37
-
38
- class DummyListener
39
- def calls
40
- @calls ||= []
41
- end
42
- def after_execute(name)
43
- c = calls
44
- c << name
45
- end
46
- end
47
-
48
- it "should work with only half implemented rake-listener" do
49
- task "mypre"
50
- t = task "test" => "mypre"
51
- l = DummyListener.new
52
- Rake::add_listener(l)
53
- t.invoke
54
- Rake::remove_listener(l)
55
- l.calls.should eq(['mypre', 'test'])
56
- end
57
-
58
- end
1
+ require 'spec_helper'
2
+ require 'cxxproject'
3
+ require 'cxxproject/ext/rake_listener.rb'
4
+ require 'cxxproject/utils/cleanup'
5
+
6
+ describe Rake::Task do
7
+
8
+ before(:each) do
9
+ Cxxproject::Utils.cleanup_rake
10
+ end
11
+ after(:each) do
12
+ Cxxproject::Utils.cleanup_rake
13
+ end
14
+
15
+
16
+ it "should call a listener for prerequisites and execute" do
17
+ task "mypre"
18
+ t = task "test" => "mypre"
19
+
20
+ l = mock
21
+ Rake::add_listener(l)
22
+
23
+ l.should_receive(:before_execute).with('mypre')
24
+ l.should_receive(:after_execute).with('mypre')
25
+ l.should_receive(:before_prerequisites).with('mypre')
26
+ l.should_receive(:after_prerequisites).with('mypre')
27
+ l.should_receive(:before_prerequisites).with('test')
28
+ l.should_receive(:after_prerequisites).with('test')
29
+ l.should_receive(:before_execute).with('test')
30
+ l.should_receive(:after_execute).with('test')
31
+ t.invoke
32
+
33
+ Rake::remove_listener(l)
34
+
35
+ t.invoke
36
+ end
37
+
38
+ class DummyListener
39
+ def calls
40
+ @calls ||= []
41
+ end
42
+ def after_execute(name)
43
+ c = calls
44
+ c << name
45
+ end
46
+ end
47
+
48
+ it "should work with only half implemented rake-listener" do
49
+ task "mypre"
50
+ t = task "test" => "mypre"
51
+ l = DummyListener.new
52
+ Rake::add_listener(l)
53
+ t.invoke
54
+ Rake::remove_listener(l)
55
+ l.calls.should eq(['mypre', 'test'])
56
+ end
57
+
58
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,18 @@
1
- $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
-
3
- require 'cxxproject/utils/optional'
4
- initialize_simplecov = lambda do
5
- require 'simplecov'
6
- if ENV['COVERAGE']
7
- SimpleCov.start do
8
- add_group 'buildingblocks', 'lib/cxxproject/buildingblocks'
9
- add_group 'utils', 'lib/cxxproject/utils'
10
- add_group 'errorparser', 'lib/cxxproject/errorparser'
11
- add_group 'toolchain', 'lib/cxxproject/toolchain'
12
- add_group 'ext', 'lib/cxxproject/ext'
13
- end
14
- end
15
- end
16
- Cxxproject::Utils::optional_package(initialize_simplecov, nil)
17
-
18
- RakeFileUtils.send(:verbose, false)
1
+ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
+
3
+ require 'cxxproject/utils/optional'
4
+ initialize_simplecov = lambda do
5
+ require 'simplecov'
6
+ if ENV['COVERAGE']
7
+ SimpleCov.start do
8
+ add_group 'buildingblocks', 'lib/cxxproject/buildingblocks'
9
+ add_group 'utils', 'lib/cxxproject/utils'
10
+ add_group 'errorparser', 'lib/cxxproject/errorparser'
11
+ add_group 'toolchain', 'lib/cxxproject/toolchain'
12
+ add_group 'ext', 'lib/cxxproject/ext'
13
+ end
14
+ end
15
+ end
16
+ Cxxproject::Utils::optional_package(initialize_simplecov, nil)
17
+
18
+ RakeFileUtils.send(:verbose, false)
data/spec/string_spec.rb CHANGED
@@ -1,11 +1,11 @@
1
- require 'cxxproject'
2
-
3
- describe String do
4
- it 'should remove from start if matching' do
5
- s = "abcd"
6
- s.remove_from_start('abc').should == 'd'
7
- end
8
- it 'should not change the string if the start does not match' do
9
- "abcd".remove_from_start('z').should == 'abcd'
10
- end
11
- end
1
+ require 'cxxproject'
2
+
3
+ describe String do
4
+ it 'should remove from start if matching' do
5
+ s = "abcd"
6
+ s.remove_from_start('abc').should == 'd'
7
+ end
8
+ it 'should not change the string if the start does not match' do
9
+ "abcd".remove_from_start('z').should == 'abcd'
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
- cxx_configuration do
2
- exe "basic",
3
- :sources => FileList.new('**/*.cpp'),
4
- :dependencies => ['2']
5
- end
1
+ cxx_configuration do
2
+ exe "basic",
3
+ :sources => FileList.new('**/*.cpp'),
4
+ :dependencies => ['2']
5
+ end
@@ -1,5 +1,5 @@
1
- cxx_configuration do
2
- source_lib "1",
3
- :sources => ['lib1.cpp'],
4
- :includes => ['.']
5
- end
1
+ cxx_configuration do
2
+ source_lib "1",
3
+ :sources => ['lib1.cpp'],
4
+ :includes => ['.']
5
+ end