rant 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/NEWS +12 -0
  2. data/README +3 -3
  3. data/Rantfile +7 -1
  4. data/doc/Untitled-1~ +7 -0
  5. data/doc/command.rdoc +1 -1
  6. data/doc/csharp.rdoc +49 -72
  7. data/doc/csharp.rdoc~ +37 -0
  8. data/doc/csharp_deprecated.rdoc +73 -0
  9. data/doc/homepage/index.html +5 -8
  10. data/doc/homepage/index.html~ +134 -0
  11. data/doc/sys.rdoc +14 -0
  12. data/lib/rant/coregen.rb~ +262 -0
  13. data/lib/rant/csharp/base_compiler_adapter.rb +125 -0
  14. data/lib/rant/csharp/base_compiler_adapter.rb~ +105 -0
  15. data/lib/rant/csharp/compiler_adapter_factory.rb +40 -0
  16. data/lib/rant/csharp/compiler_adapter_factory.rb~ +39 -0
  17. data/lib/rant/csharp/csc_compiler.rb +15 -0
  18. data/lib/rant/csharp/csc_compiler.rb~ +39 -0
  19. data/lib/rant/csharp/gmcs_compiler.rb +9 -0
  20. data/lib/rant/csharp/gmcs_compiler.rb~ +10 -0
  21. data/lib/rant/csharp/mcs_compiler.rb +13 -0
  22. data/lib/rant/csharp/mcs_compiler.rb~ +40 -0
  23. data/lib/rant/csharp/msc_compiler.rb~ +39 -0
  24. data/lib/rant/import/csharp.rb +48 -0
  25. data/lib/rant/import/csharp.rb~ +58 -0
  26. data/lib/rant/import/nunittest.rb +32 -0
  27. data/lib/rant/import/resgen.rb +21 -0
  28. data/lib/rant/import/resgen.rb~ +20 -0
  29. data/lib/rant/init.rb +1 -1
  30. data/lib/rant/rantlib.rb +1 -0
  31. data/lib/rant/rantlib.rb~ +1376 -0
  32. data/lib/rant/rantsys.rb +6 -0
  33. data/run_import +1 -1
  34. data/run_rant +1 -1
  35. data/test/import/package/test_package.rb~ +628 -0
  36. data/test/rule.rf +4 -0
  37. data/test/test_filetask.rb~ +97 -0
  38. data/test/test_rule.rb +10 -0
  39. data/test/test_sys_methods.rb +22 -0
  40. data/test/units/csharp/test_base_compiler_adapter.rb +107 -0
  41. data/test/units/csharp/test_base_compiler_adapter.rb~ +73 -0
  42. data/test/units/csharp/test_compiler_adapter_factory.rb +66 -0
  43. data/test/units/csharp/test_compiler_adapter_factory.rb~ +66 -0
  44. data/test/units/csharp/test_csc_compiler.rb +23 -0
  45. data/test/units/csharp/test_csc_compiler.rb~ +23 -0
  46. data/test/units/csharp/test_gmsc_compiler.rb +19 -0
  47. data/test/units/csharp/test_gmsc_compiler.rb~ +19 -0
  48. data/test/units/csharp/test_msc_compiler.rb +23 -0
  49. data/test/units/csharp/test_msc_compiler.rb~ +23 -0
  50. data/test/units/csharp_test_helper.rb +6 -0
  51. data/test/units/import/test_csharp.rb +127 -0
  52. data/test/units/import/test_csharp.rb~ +126 -0
  53. data/test/units/import/test_nunittest.rb +122 -0
  54. data/test/units/import/test_resgen.rb +107 -0
  55. data/test/units/import/test_resgen.rb~ +88 -0
  56. metadata +269 -224
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp_test_helper')
2
+ require File.expand_path(File.dirname(__FILE__) +
3
+ '/../../../lib/rant/csharp/csc_compiler')
4
+
5
+ class TestCscCompiler < Test::Unit::TestCase
6
+ def setup
7
+ @c = Rant::CSharp::CscCompiler.new
8
+ end
9
+
10
+ # Tests
11
+ def test_initialize_should_provide_csc_bin
12
+ assert_equal "csc /nologo", @c.bin
13
+ end
14
+
15
+ def test_initialize_should_allow_alternate_bin
16
+ c = Rant::CSharp::CscCompiler.new("altbin")
17
+ assert_equal "altbin", c.bin
18
+ end
19
+
20
+ def test_argument_prefix_should_be_slash
21
+ assert_equal "/", @c.argument_prefix
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/csharp_test_helper')
2
+ require File.expand_path(File.dirname(__FILE__) +
3
+ '/../../../lib/rant/csharp/csc_compiler')
4
+
5
+ class TestCscCompiler < Test::Unit::TestCase
6
+ def setup
7
+ @c = Rant::CSharp::CscCompiler.new
8
+ end
9
+
10
+ # Tests
11
+ def test_initialize_should_provide_csc_bin
12
+ assert_equal "csc /nologo", @c.bin
13
+ end
14
+
15
+ def test_initialize_should_allow_alternate_bin
16
+ c = Rant::CSharp::CscCompiler.new("altbin")
17
+ assert_equal "altbin", c.bin
18
+ end
19
+
20
+ def test_argument_prefix_should_be_slash
21
+ assert_equal "/", @c.argument_prefix
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp_test_helper')
2
+ require File.expand_path(File.dirname(__FILE__) +
3
+ '/../../../lib/rant/csharp/gmcs_compiler')
4
+
5
+ class TestGmcsCompiler < Test::Unit::TestCase
6
+ def setup
7
+ @c = Rant::CSharp::GmcsCompiler.new
8
+ end
9
+
10
+ # Tests
11
+ def test_initialize_should_provide_gmcs_bin
12
+ assert_equal "gmcs", @c.bin
13
+ end
14
+
15
+ def test_initialize_should_allow_alternate_bin
16
+ c = Rant::CSharp::GmcsCompiler.new("altbin")
17
+ assert_equal "altbin", c.bin
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/csharp_test_helper')
2
+ require File.expand_path(File.dirname(__FILE__) +
3
+ '/../../../lib/rant/csharp/gmcs_compiler')
4
+
5
+ class TestGmcsCompiler < Test::Unit::TestCase
6
+ def setup
7
+ @c = Rant::CSharp::GmcsCompiler.new
8
+ end
9
+
10
+ # Tests
11
+ def test_initialize_should_provide_gmcs_bin
12
+ assert_equal "gmcs", @c.bin
13
+ end
14
+
15
+ def test_initialize_should_allow_alternate_bin
16
+ c = Rant::CSharp::GmcsCompiler.new("altbin")
17
+ assert_equal "altbin", c.bin
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp_test_helper')
2
+ require File.expand_path(File.dirname(__FILE__) +
3
+ '/../../../lib/rant/csharp/mcs_compiler')
4
+
5
+ class TestMcsCompiler < Test::Unit::TestCase
6
+ def setup
7
+ @c = Rant::CSharp::McsCompiler.new
8
+ end
9
+
10
+ # Tests
11
+ def test_initialize_should_provide_mcs_bin
12
+ assert_equal "mcs", @c.bin
13
+ end
14
+
15
+ def test_initialize_should_allow_alternate_bin
16
+ c = Rant::CSharp::McsCompiler.new("altbin")
17
+ assert_equal "altbin", c.bin
18
+ end
19
+
20
+ def test_argument_prefix_should_be_dash
21
+ assert_equal "-", @c.argument_prefix
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/csharp_test_helper')
2
+ require File.expand_path(File.dirname(__FILE__) +
3
+ '/../../../lib/rant/csharp/mcs_compiler')
4
+
5
+ class TestMcsCompiler < Test::Unit::TestCase
6
+ def setup
7
+ @c = Rant::CSharp::McsCompiler.new
8
+ end
9
+
10
+ # Tests
11
+ def test_initialize_should_provide_mcs_bin
12
+ assert_equal "mcs", @c.bin
13
+ end
14
+
15
+ def test_initialize_should_allow_alternate_bin
16
+ c = Rant::CSharp::McsCompiler.new("altbin")
17
+ assert_equal "altbin", c.bin
18
+ end
19
+
20
+ def test_argument_prefix_should_be_dash
21
+ assert_equal "-", @c.argument_prefix
22
+ end
23
+ end
@@ -0,0 +1,6 @@
1
+ # Unit assumes this module/class is defined
2
+ module Rant;
3
+ class FileList; end;
4
+ end;
5
+
6
+ require 'test/unit'
@@ -0,0 +1,127 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp_test_helper')
2
+ module Rant::Generators; end;
3
+
4
+ require File.expand_path(File.dirname(__FILE__) +
5
+ '/../../../lib/rant/import/csharp')
6
+
7
+ begin
8
+ require 'mocha'
9
+
10
+ class TestCSharp < Test::Unit::TestCase
11
+ def setup
12
+ @csharp = Rant::Generators::CSharp
13
+ end
14
+
15
+ # Tests
16
+ def test_should_require_sources
17
+ rant = mock()
18
+ rant.expects(:abort_at
19
+ ).with({}, "CSharp requires sources"
20
+ ).raises(Exception
21
+ ).times(2)
22
+
23
+ assert_raise(Exception) {
24
+ @csharp.rant_gen(rant, {}, ["target", {}])
25
+ }
26
+
27
+ assert_raise(Exception) {
28
+ @csharp.rant_gen(rant, {}, ["target", {:sources => []}])
29
+ }
30
+ end
31
+
32
+ def test_should_require_target
33
+ rant = mock()
34
+ rant.expects(:abort_at
35
+ ).with({}, "CSharp requires a target"
36
+ ).raises(Exception)
37
+
38
+ assert_raise(Exception) {
39
+ @csharp.rant_gen(rant, {}, ["", {:sources => ["a"]}])
40
+ }
41
+ end
42
+
43
+ def test_should_create_file_task_depending_on_sources
44
+ rant = mock()
45
+ rant.expects(:file
46
+ ).with({"target" => ["a"]})
47
+
48
+ @csharp.rant_gen(rant, nil, ["target", {:sources => ["a"]}])
49
+ end
50
+
51
+ def test_file_task_should_depend_on_resources
52
+ rant = mock()
53
+ rant.expects(:file
54
+ ).with({"target" => ["a", "b"]})
55
+
56
+ @csharp.rant_gen(rant, nil, ["target", {:sources => ["a"],
57
+ :resources => ["b"]}])
58
+ end
59
+
60
+ def test_file_task_should_depend_on_libs
61
+ rant = mock()
62
+ rant.expects(:file
63
+ ).with({"target" => ["a", "b"]})
64
+
65
+ @csharp.rant_gen(rant, nil, ["target", {:sources => ["a"],
66
+ :libs => ["b"]}])
67
+ end
68
+
69
+ def test_file_task_should_call_shell_command
70
+ sys = mock()
71
+ sys.expects(:sh).with("command")
72
+
73
+ context = mock()
74
+ context.expects(:sys).returns(sys)
75
+
76
+ rant = mock()
77
+ rant.expects(:file).yields("target")
78
+ rant.expects(:context).at_least_once.returns(context)
79
+
80
+ compiler = mock()
81
+ compiler.expects(:cmd).returns("command")
82
+
83
+ @csharp.rant_gen(rant, nil, ["target", {:sources => ["a"],
84
+ :compiler => compiler}])
85
+ end
86
+
87
+ def test_get_compiler_should_use_given_compiler
88
+ compiler = Object.new
89
+
90
+ assert_equal compiler,
91
+ @csharp.get_compiler(nil, {:compiler => compiler}),
92
+ "Does not use given compiler"
93
+ end
94
+
95
+ def test_get_compiler_should_create_instance_of_given_compiler_class
96
+ klass = Class.new(Object)
97
+ ret = @csharp.get_compiler(nil, {:compiler => klass})
98
+ assert ret.kind_of?(klass),
99
+ "Created compiler was of class #{ret.class}, should have been #{klass}"
100
+ end
101
+
102
+ def test_get_compiler_should_remove_compiler_from attributes
103
+ args = {:compiler => Object}
104
+ @csharp.get_compiler(nil, args)
105
+ assert args.empty?, ":compiler should have been removed from arguments"
106
+ end
107
+
108
+ def test_get_compiler_should_use_default_if_no_compiler_specified
109
+ assert_equal "default_compiler", @csharp.get_compiler(nil, {})
110
+ end
111
+ end
112
+
113
+ # Mocks
114
+ class Rant::Generators::CSharp
115
+ class MockFactory
116
+ def compiler context
117
+ "default_compiler"
118
+ end
119
+ end
120
+
121
+ def self.compiler_adapter_factory
122
+ MockFactory.new
123
+ end
124
+ end
125
+ rescue LoadError
126
+ print "**** Could not test CSharp, requires mocha libary ****\n"
127
+ end
@@ -0,0 +1,126 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp_test_helper')
2
+ module Rant::Generators; end;
3
+
4
+ require File.expand_path(File.dirname(__FILE__) +
5
+ '/../../../lib/rant/import/csharp')
6
+
7
+ begin
8
+ require 'mocha'
9
+
10
+ class TestCSharp < Test::Unit::TestCase
11
+ def setup
12
+ @csharp = Rant::Generators::CSharp
13
+ end
14
+
15
+ # Tests
16
+ def test_should_require_sources
17
+ rant = mock()
18
+ rant.expects(:abort_at
19
+ ).with({}, "CSharp requires sources"
20
+ ).raises(Exception
21
+ ).times(2)
22
+
23
+ assert_raise(Exception) {
24
+ @csharp.rant_gen(rant, {}, ["target", {}])
25
+ }
26
+
27
+ assert_raise(Exception) {
28
+ @csharp.rant_gen(rant, {}, ["target", {:sources => []}])
29
+ }
30
+ end
31
+
32
+ def test_should_require_target
33
+ rant = mock()
34
+ rant.expects(:abort_at
35
+ ).with({}, "CSharp requires a target"
36
+ ).raises(Exception)
37
+
38
+ assert_raise(Exception) {
39
+ @csharp.rant_gen(rant, {}, ["", {:sources => ["a"]}])
40
+ }
41
+ end
42
+
43
+ def test_should_create_file_task_depending_on_sources
44
+ rant = mock()
45
+ rant.expects(:file
46
+ ).with({"target" => ["a"]})
47
+
48
+ @csharp.rant_gen(rant, nil, ["target", {:sources => ["a"]}])
49
+ end
50
+
51
+ def test_file_task_should_depend_on_resources
52
+ rant = mock()
53
+ rant.expects(:file
54
+ ).with({"target" => ["a", "b"]})
55
+
56
+ @csharp.rant_gen(rant, nil, ["target", {:sources => ["a"],
57
+ :resources => ["b"]}])
58
+ end
59
+
60
+ def test_file_task_should_depend_on_libs
61
+ rant = mock()
62
+ rant.expects(:file
63
+ ).with({"target" => ["a", "b"]})
64
+
65
+ @csharp.rant_gen(rant, nil, ["target", {:sources => ["a"],
66
+ :libs => ["b"]}])
67
+ end
68
+
69
+ def test_file_task_should_call_shell_command
70
+ sys = mock()
71
+ sys.expects(:sh).with("command")
72
+
73
+ context = mock()
74
+ context.expects(:sys).returns(sys)
75
+
76
+ rant = mock()
77
+ rant.expects(:file).yields("target")
78
+ rant.expects(:context).at_least_once.returns(context)
79
+
80
+ compiler = mock()
81
+ compiler.expects(:cmd).returns("command")
82
+
83
+ @csharp.rant_gen(rant, nil, ["target", {:sources => ["a"], :compiler => compiler}])
84
+ end
85
+
86
+ def test_get_compiler_should_use_given_compiler
87
+ compiler = Object.new
88
+
89
+ assert_equal compiler,
90
+ @csharp.get_compiler(nil, {:compiler => compiler}),
91
+ "Does not use given compiler"
92
+ end
93
+
94
+ def test_get_compiler_should_create_instance_of_given_compiler_class
95
+ klass = Class.new(Object)
96
+ ret = @csharp.get_compiler(nil, {:compiler => klass})
97
+ assert ret.kind_of?(klass),
98
+ "Created compiler was of class #{ret.class}, should have been #{klass}"
99
+ end
100
+
101
+ def test_get_compiler_should_remove_compiler_from attributes
102
+ args = {:compiler => Object}
103
+ @csharp.get_compiler(nil, args)
104
+ assert args.empty?, ":compiler should have been removed from arguments"
105
+ end
106
+
107
+ def test_get_compiler_should_use_default_if_no_compiler_specified
108
+ assert_equal "default_compiler", @csharp.get_compiler(nil, {})
109
+ end
110
+ end
111
+
112
+ # Mocks
113
+ class Rant::Generators::CSharp
114
+ class MockFactory
115
+ def compiler context
116
+ "default_compiler"
117
+ end
118
+ end
119
+
120
+ def self.compiler_adapter_factory
121
+ MockFactory.new
122
+ end
123
+ end
124
+ rescue LoadError
125
+ print "**** Could not test CSharp, requires mocha libary ****\n"
126
+ end
@@ -0,0 +1,122 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp_test_helper')
2
+ module Rant::Generators; end;
3
+
4
+ require File.expand_path(File.dirname(__FILE__) +
5
+ '/../../../lib/rant/import/nunittest')
6
+
7
+ begin
8
+ require 'mocha'
9
+
10
+ class TestNUnitTest < Test::Unit::TestCase
11
+ def setup
12
+ @nunit = Rant::Generators::NUnitTest
13
+ end
14
+
15
+ # Tests
16
+ def test_should_require_dlls
17
+ rant = mock()
18
+ rant.expects(:abort_at
19
+ ).with({}, "NUnitTest requires dlls"
20
+ ).raises(Exception
21
+ ).times(2)
22
+
23
+ assert_raise(Exception) {
24
+ @nunit.rant_gen(rant, {}, ["target", {}])
25
+ }
26
+
27
+ assert_raise(Exception) {
28
+ @nunit.rant_gen(rant, {}, ["target", {:dlls => []}])
29
+ }
30
+ end
31
+
32
+ def test_should_require_task_name
33
+ rant = mock()
34
+ rant.expects(:abort_at
35
+ ).with({}, "NUnitTest requires a task name"
36
+ ).raises(Exception)
37
+
38
+ assert_raise(Exception) {
39
+ @nunit.rant_gen(rant, {}, ["", {:dlls => ["a"]}])
40
+ }
41
+ end
42
+
43
+ def test_should_create_task
44
+ rant = mock()
45
+ rant.expects(:task)
46
+
47
+ @nunit.rant_gen(rant, nil, ["target", {:dlls => ["a"]}])
48
+ end
49
+
50
+ def test_task_should_call_shell_command
51
+ dll = "a"
52
+
53
+ sys = mock()
54
+ sys.expects(:sh).with("command a")
55
+ sys.expects(:sp).returns(dll)
56
+
57
+ context = mock()
58
+ context.expects(:sys).returns(sys).at_least_once
59
+
60
+ rant = mock()
61
+ rant.expects(:task).yields("target")
62
+ rant.expects(:context).at_least_once.returns(context)
63
+
64
+ @nunit.rant_gen(rant, nil, ["target", {:dlls => dll,
65
+ :bin => "command"}])
66
+ end
67
+
68
+ def test_should_accept_dlls_as_filelist
69
+ dll = mock()
70
+ dll.expects(:arglist).returns("a")
71
+
72
+ assert_equal "a", @nunit.process_dlls(nil, dll)
73
+ end
74
+
75
+ def test_should_accept_dlls_as_array
76
+ dll = ["a", "a"]
77
+
78
+ sys = mock()
79
+ sys.expects(:sp).returns("a").times(2)
80
+
81
+ context = mock()
82
+ context.expects(:sys).returns(sys).at_least_once
83
+
84
+ rant = mock()
85
+ rant.expects(:context).at_least_once.returns(context)
86
+
87
+ assert_equal "a a", @nunit.process_dlls(rant, dll)
88
+ end
89
+
90
+ def test_should_accept_dll_as_string
91
+ dll = "a"
92
+
93
+ sys = mock()
94
+ sys.expects(:sp).returns("a").times(1)
95
+
96
+ context = mock()
97
+ context.expects(:sys).returns(sys).at_least_once
98
+
99
+ rant = mock()
100
+ rant.expects(:context).at_least_once.returns(context)
101
+
102
+ assert_equal "a", @nunit.process_dlls(rant, dll)
103
+ end
104
+
105
+ def test_default_command_is_nunit_console
106
+ sys = mock()
107
+ sys.expects(:sp).returns("a").at_least_once
108
+ sys.expects(:sh).returns("nunit-console /nologo a")
109
+
110
+ context = mock()
111
+ context.expects(:sys).returns(sys).at_least_once
112
+
113
+ rant = mock()
114
+ rant.expects(:task).yields("target")
115
+ rant.expects(:context).at_least_once.returns(context)
116
+
117
+ @nunit.rant_gen(rant, nil, ["target", {:dlls => "a"}])
118
+ end
119
+ end
120
+ rescue LoadError
121
+ print "**** Could not test NUnitTest, requires mocha libary ****\n"
122
+ end