build-tool 0.5.7 → 0.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/.gitignore +1 -0
  2. data/.rvmrc +1 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +5 -0
  5. data/Gemfile.lock +56 -0
  6. data/History.txt +64 -0
  7. data/README.txt +0 -7
  8. data/Rakefile +8 -56
  9. data/bin/build-tool +4 -1
  10. data/build-tool.gemspec +62 -0
  11. data/db/migrations/20110703074000_add_command_logs.rb +17 -0
  12. data/db/migrations/20110703075000_add_module_logs.rb +20 -0
  13. data/db/migrations/20110815170000_add_features.rb +17 -0
  14. data/db/migrations/20120103204700_add_modules.rb +17 -0
  15. data/db/migrations/20120106181200_add_settings.rb +18 -0
  16. data/lib/build-tool.rb +3 -4
  17. data/lib/build-tool/application.rb +127 -37
  18. data/lib/build-tool/build-system/autoconf.rb +2 -8
  19. data/lib/build-tool/build-system/base.rb +12 -4
  20. data/lib/build-tool/build-system/cmake.rb +2 -0
  21. data/lib/build-tool/build-system/custom.rb +2 -0
  22. data/lib/build-tool/build-system/kdel10n.rb +2 -0
  23. data/lib/build-tool/build-system/make.rb +2 -0
  24. data/lib/build-tool/build-system/none.rb +2 -0
  25. data/lib/build-tool/build-system/qmake.rb +2 -0
  26. data/lib/build-tool/build-system/qt.rb +4 -0
  27. data/lib/build-tool/cfg/lexer.rex +40 -8
  28. data/lib/build-tool/cfg/lexer_base.rb +3 -1
  29. data/lib/build-tool/cfg/node.rb +17 -1
  30. data/lib/build-tool/cfg/parser.y +92 -10
  31. data/lib/build-tool/cfg/visitor.rb +202 -78
  32. data/lib/build-tool/command_actions.rb +26 -10
  33. data/lib/build-tool/commands.rb +289 -197
  34. data/lib/build-tool/commands/build.rb +13 -9
  35. data/lib/build-tool/commands/configuration.rb +25 -0
  36. data/lib/build-tool/commands/configuration/edit.rb +42 -0
  37. data/lib/build-tool/commands/configuration/list.rb +48 -0
  38. data/lib/build-tool/commands/configure.rb +9 -5
  39. data/lib/build-tool/commands/ctags.rb +8 -3
  40. data/lib/build-tool/commands/environments.rb +2 -4
  41. data/lib/build-tool/commands/environments/list.rb +13 -10
  42. data/lib/build-tool/commands/environments/set.rb +5 -1
  43. data/lib/build-tool/commands/features.rb +24 -0
  44. data/lib/build-tool/commands/features/disable.rb +70 -0
  45. data/lib/build-tool/commands/features/enable.rb +66 -0
  46. data/lib/build-tool/commands/features/list.rb +92 -0
  47. data/lib/build-tool/commands/fetch.rb +9 -3
  48. data/lib/build-tool/commands/files.rb +9 -5
  49. data/lib/build-tool/commands/gc.rb +48 -15
  50. data/lib/build-tool/commands/history.rb +21 -16
  51. data/lib/build-tool/commands/info.rb +16 -13
  52. data/lib/build-tool/commands/install.rb +8 -4
  53. data/lib/build-tool/commands/modules.rb +2 -4
  54. data/lib/build-tool/commands/modules/cleanup.rb +52 -0
  55. data/lib/build-tool/commands/modules/disable.rb +95 -0
  56. data/lib/build-tool/commands/modules/enable.rb +52 -0
  57. data/lib/build-tool/commands/modules/info.rb +44 -35
  58. data/lib/build-tool/commands/modules/list.rb +67 -15
  59. data/lib/build-tool/commands/modules/shell.rb +8 -2
  60. data/lib/build-tool/commands/rebase.rb +15 -7
  61. data/lib/build-tool/commands/recipes.rb +2 -4
  62. data/lib/build-tool/commands/recipes/add.rb +16 -2
  63. data/lib/build-tool/commands/recipes/edit.rb +72 -0
  64. data/lib/build-tool/commands/recipes/incoming.rb +11 -7
  65. data/lib/build-tool/commands/recipes/info.rb +12 -8
  66. data/lib/build-tool/commands/recipes/install.rb +37 -42
  67. data/lib/build-tool/commands/recipes/list.rb +6 -2
  68. data/lib/build-tool/configuration.rb +88 -3
  69. data/lib/build-tool/environment.rb +2 -0
  70. data/lib/build-tool/errors.rb +5 -0
  71. data/lib/build-tool/history.rb +3 -181
  72. data/lib/build-tool/model/command_log.rb +93 -0
  73. data/lib/build-tool/model/feature.rb +80 -0
  74. data/lib/build-tool/{module.rb → model/module.rb} +110 -29
  75. data/lib/build-tool/model/module_log.rb +64 -0
  76. data/lib/build-tool/model/setting.rb +84 -0
  77. data/lib/build-tool/recipe.rb +40 -18
  78. data/lib/build-tool/repository.rb +39 -33
  79. data/lib/build-tool/server.rb +27 -3
  80. data/lib/build-tool/singleton.rb +2 -0
  81. data/lib/build-tool/sshkey.rb +2 -0
  82. data/lib/build-tool/state_helper.rb +64 -0
  83. data/lib/build-tool/vcs/archive.rb +3 -1
  84. data/lib/build-tool/vcs/base.rb +13 -0
  85. data/lib/build-tool/vcs/git-svn.rb +36 -14
  86. data/lib/build-tool/vcs/git.rb +180 -44
  87. data/lib/build-tool/vcs/mercurial.rb +25 -13
  88. data/lib/build-tool/vcs/svn.rb +20 -15
  89. data/lib/build-tool/version.rb +30 -0
  90. data/lib/mj/error.rb +2 -0
  91. data/lib/mj/logging.rb +2 -0
  92. data/lib/mj/mixins/inherited_attributes.rb +73 -0
  93. data/lib/mj/tools/editor.rb +34 -0
  94. data/lib/mj/tools/ssh.rb +2 -0
  95. data/lib/mj/tools/subprocess.rb +2 -1
  96. data/lib/mj/vcs/git.rb +14 -2
  97. data/lib/mj/visitor.rb +22 -0
  98. data/tasks/db.rake +36 -0
  99. data/tasks/racc.rake +14 -0
  100. data/tasks/rdoc.rake +8 -0
  101. data/tasks/rexical.rake +14 -0
  102. data/tasks/test.rake +21 -0
  103. data/test/integration/history_test.rb +88 -0
  104. data/test/integration/parser_configuration.rb +36 -0
  105. data/test/integration/parser_environment_parser.rb +156 -0
  106. data/test/integration/parser_feature_test.rb +75 -0
  107. data/test/integration/parser_git-svn_test.rb +92 -0
  108. data/test/integration/parser_git_test.rb +97 -0
  109. data/test/integration/parser_mercurial_test.rb +77 -0
  110. data/test/integration/parser_module_test.rb +103 -0
  111. data/test/integration/parser_svn_test.rb +92 -0
  112. data/test/integration/parser_test.rb +73 -0
  113. data/test/test_helper.rb +61 -0
  114. data/test/unit/configuration_test.rb +36 -0
  115. data/test/unit/git_configuration_test.rb +163 -0
  116. data/test/unit/git_svn_configuration_test.rb +240 -0
  117. data/test/unit/mercurial_configuration_test.rb +64 -0
  118. data/test/unit/model/command_log_test.rb +103 -0
  119. data/test/unit/model/feature_test.rb +29 -0
  120. data/test/unit/model/module_log_test.rb +70 -0
  121. data/test/unit/model/module_test.rb +32 -0
  122. data/test/unit/repository_test.rb +110 -0
  123. data/test/unit/server_test.rb +66 -0
  124. data/test/unit/svn_configuration_test.rb +90 -0
  125. metadata +134 -93
  126. data/Manifest.txt +0 -80
  127. data/db/migrations/001_command_histories.rb +0 -20
  128. data/db/migrations/002_module_events.rb +0 -24
  129. data/db/migrations/003_command_histories_add_logfile.rb +0 -19
  130. data/lib/build-tool/GUI.rb +0 -360
  131. data/lib/build-tool/commands/help.rb +0 -22
  132. data/lib/build-tool/commands/lsfeatures.rb +0 -76
  133. data/lib/build-tool/feature.rb +0 -47
@@ -0,0 +1,240 @@
1
+ require 'test_helper'
2
+
3
+ require 'build-tool/vcs/git-svn'
4
+
5
+
6
+
7
+ class GitSvnConfigurationTest < ActiveSupport::TestCase
8
+
9
+ #######################
10
+ # THE GIT FUNCTIONALITY
11
+ #
12
+ test 'Constructor.' do
13
+ cfg = BuildTool::VCS::GitSvnConfiguration.new()
14
+ cfg.vcs( ModuleMock.new( 'test' ) )
15
+ assert_equal( 'git-svn', cfg.name )
16
+ assert_equal( {}, cfg.remote )
17
+ assert_equal( {}, cfg.global_options )
18
+ assert_equal( {}, cfg.options )
19
+ assert_equal( 'remotes/git-svn', cfg.track )
20
+ assert_raise( BuildTool::ConfigurationError ) { cfg.repository }
21
+ end
22
+
23
+ test 'Track is correctly split.' do
24
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
25
+ assert_equal( 'remotes', cfg.track_remote )
26
+ assert_equal( 'git-svn', cfg.track_branch )
27
+ cfg.track = 'myremote/mybranch'
28
+ assert_equal( 'myremote', cfg.track_remote )
29
+ assert_equal( 'mybranch', cfg.track_branch )
30
+ end
31
+
32
+ test 'Vcs() returns a git-svn instance.' do
33
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
34
+ # :TODO:
35
+ # assert( cfg.vcs.is_a?( BuildTool::VCS::Git ), "vcs() returns a instance of Git." )
36
+ end
37
+
38
+ test 'track() accessor works.' do
39
+ cfg = create_configuration
40
+ assert_equal( 'myremote/mybranch', cfg.track )
41
+ end
42
+
43
+ test 'track() accessor works with inheritance.' do
44
+ parent = create_configuration
45
+ # Create a empty object with a parent
46
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
47
+ cfg.parent = parent
48
+ # Value is taken from parent
49
+ assert_equal( 'myremote/mybranch', cfg.track )
50
+ # Unless we set it locally
51
+ cfg.track = 'repo1/test'
52
+ assert_equal( 'repo1/test', cfg.track )
53
+ # After a reset
54
+ cfg.track = nil
55
+ assert_equal( 'myremote/mybranch', cfg.track )
56
+ end
57
+
58
+ test 'options() accessor works.' do
59
+ cfg = create_configuration
60
+ assert_equal( 'option 1', cfg.options[:option1] )
61
+ assert_equal( 'option 2', cfg.options[:option2] )
62
+ assert_nil( cfg.options[:option3] )
63
+ end
64
+
65
+ test 'options() accessor works with inheritance.' do
66
+ parent = create_configuration
67
+ # Create a empty object with a parent
68
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
69
+ cfg.parent = parent
70
+ # Options are not merged.
71
+ assert_nil( cfg.options[:option1] )
72
+ assert_nil( cfg.options[:option2] )
73
+ assert_nil( cfg.options[:option3] )
74
+ # Merged_options is merged with the parent.
75
+ assert_equal( 'option 1', cfg.merged_options[:option1] )
76
+ assert_equal( 'option 2', cfg.merged_options[:option2] )
77
+ assert_nil( cfg.merged_options[:option3] )
78
+ # But ours have priority
79
+ cfg.options[:option1] = 'overwritten'
80
+ assert_equal( 'overwritten', cfg.merged_options[:option1] )
81
+ end
82
+
83
+ test 'options() accessor works with global configuration.' do
84
+ cfg = create_configuration
85
+ create_global_configuration
86
+ assert_equal( 'option 1', cfg.merged_options[:option1] )
87
+ assert_equal( 'option 2', cfg.merged_options[:option2] )
88
+ assert_equal( 'option 3(set globally)', cfg.merged_options[:option3] )
89
+ end
90
+
91
+ test 'options() accessor works with global configuration and inheritance.' do
92
+ parent = create_configuration
93
+ # Create a empty object with a parent
94
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
95
+ cfg.parent = parent
96
+ cfg.options[:option1] = 'overwritten'
97
+ # Merged_options is merged with the parent and global
98
+ create_global_configuration
99
+ assert_equal( 'overwritten', cfg.merged_options[:option1] )
100
+ assert_equal( 'option 2', cfg.merged_options[:option2] )
101
+ assert_equal( 'option 3(set globally)', cfg.merged_options[:option3] )
102
+ # And we can reset them
103
+ cfg.options.delete(:option1)
104
+ assert_equal( 'option 1', cfg.merged_options[:option1] )
105
+ end
106
+
107
+ test 'global_options() works.' do
108
+ cfg = create_configuration
109
+ assert_equal( {}, cfg.global_options )
110
+ end
111
+
112
+ test 'global_options() works with global configuration.' do
113
+ cfg = create_configuration
114
+ create_global_configuration
115
+ assert_equal( 'global option 1', cfg.merged_global_options[:globaloption1] )
116
+ assert_equal( 'global option 2', cfg.merged_global_options[:globaloption2] )
117
+ end
118
+
119
+ test 'remote() accessor works.' do
120
+ cfg = create_configuration
121
+ assert_equal( 'GitRemoteObject 1', cfg.remote['origin'] )
122
+ assert_equal( 'GitRemoteObject 1', cfg.merged_remote['origin'] )
123
+ end
124
+
125
+ test 'remote() accessor works with inheritance.' do
126
+ parent = create_configuration
127
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
128
+ cfg.parent = parent
129
+ cfg.remote['other'] = 'other'
130
+ assert_nil( cfg.remote['origin'] )
131
+ assert_equal( 'GitRemoteObject 1', cfg.merged_remote['origin'] )
132
+ assert_equal( 'other', cfg.merged_remote['other'] )
133
+ cfg.remote['origin'] = 'test'
134
+ assert_equal( 'test', cfg.merged_remote['origin'] )
135
+ assert_equal( 'other', cfg.merged_remote['other'] )
136
+ end
137
+
138
+ #######################
139
+ # THE GIT-SVN FUNCTIONALITY
140
+ #
141
+ test 'Constructor Git-SVN.' do
142
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
143
+ assert_equal( {}, cfg.externals )
144
+ assert_equal( {}, cfg.merged_externals )
145
+ end
146
+
147
+ test 'external() accessor works.' do
148
+ cfg = create_configuration
149
+ assert_equal( 'svn+ssh@user@example.com/remote/path', cfg.externals[ 'local/path' ] )
150
+ end
151
+
152
+ test 'external() accessor works with inheritance.' do
153
+ parent = create_configuration
154
+ # Create a empty object with a parent
155
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
156
+ cfg.parent = parent
157
+ # Value is taken from parent
158
+ assert_equal( 'svn+ssh@user@example.com/remote/path', cfg.merged_externals[ 'local/path' ] )
159
+ # Unless we set it locally
160
+ cfg.externals['local/path'] ='svn+ssh@user@example.com/remote/other/path'
161
+ assert_equal( 'svn+ssh@user@example.com/remote/other/path', cfg.merged_externals[ 'local/path' ] )
162
+ # After a reset
163
+ cfg.externals.delete( 'local/path' )
164
+ assert_equal( 'svn+ssh@user@example.com/remote/path', cfg.merged_externals[ 'local/path' ] )
165
+ end
166
+
167
+ test 'repository() accessor works.' do
168
+ cfg = create_configuration
169
+ assert_equal( 'repo', cfg.repository.name )
170
+ end
171
+
172
+ test 'repository() accessor works with inheritance.' do
173
+ parent = create_configuration
174
+ # Create a empty object with a parent
175
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
176
+ cfg.parent = parent
177
+ # Value is taken from parent
178
+ assert_equal( 'repo', cfg.repository.name )
179
+ # Unless we set it locally
180
+ cfg.repository = RepositoryMock.new( 'repo2' )
181
+ assert_equal( 'repo2', cfg.repository.name )
182
+ # After a reset
183
+ cfg.repository = nil
184
+ assert_equal( 'repo', cfg.repository.name )
185
+ end
186
+
187
+ test 'accessor remote_path() works.' do
188
+ cfg = create_configuration
189
+ assert_equal( 'remote/path', cfg.remote_path )
190
+ end
191
+
192
+ test 'accessor remote_path() works with inheritance.' do
193
+ parent = create_configuration
194
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
195
+ cfg.vcs( ModuleMock.new( 'test' ) )
196
+ cfg.parent = parent
197
+ # We get the value from the parent
198
+ assert_equal( 'remote/path', cfg.remote_path )
199
+ # Unless we override it
200
+ cfg.remote_path = 'remote/other_path'
201
+ assert_equal( 'remote/other_path', cfg.remote_path )
202
+ # And we can reset it
203
+ cfg.remote_path = nil
204
+ assert_equal( 'remote/path', cfg.remote_path )
205
+ end
206
+
207
+
208
+ private
209
+
210
+ def create_configuration
211
+ # Reset global configuration
212
+ BuildTool::VCS::GitConfiguration.global_config = nil
213
+ # Create a configuration object
214
+ cfg = BuildTool::VCS::GitSvnConfiguration.new
215
+ cfg.track = 'myremote/mybranch'
216
+ cfg.options = {
217
+ :option1 => "option 1",
218
+ :option2 => "option 2" }
219
+ cfg.remote['origin'] = 'GitRemoteObject 1'
220
+ cfg.remote['private'] = 'GitRemoteObject 2'
221
+ cfg.externals['local/path'] ='svn+ssh@user@example.com/remote/path'
222
+ cfg.repository = RepositoryMock.new( 'repo' )
223
+ cfg.remote_path = 'remote/path'
224
+ cfg
225
+ end
226
+
227
+ def create_global_configuration
228
+ # Add a global configuration object
229
+ global = BuildTool::VCS::GitConfiguration.new
230
+ BuildTool::VCS::GitConfiguration.global_config = global
231
+ global.options = {
232
+ :option1 => "option 1(set globally)",
233
+ :option3 => "option 3(set globally)" }
234
+ global.global_options = {
235
+ :globaloption1 => "global option 1",
236
+ :globaloption2 => "global option 2" }
237
+ global
238
+ end
239
+
240
+ end # class GitSvnConfigurationTest
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ require 'build-tool/vcs/mercurial'
4
+
5
+ class MercurialConfigurationTest < ActiveSupport::TestCase
6
+
7
+ test 'Constructor' do
8
+ cfg = BuildTool::VCS::MercurialConfiguration.new
9
+ cfg.vcs( ModuleMock.new( 'mercurial/test' ) )
10
+ assert_equal( cfg.name, 'mercurial' )
11
+ assert_nil( cfg.url )
12
+ assert_equal( 'default', cfg.track )
13
+ end
14
+
15
+ test 'accessor url() works.' do
16
+ cfg = create_configuration
17
+ assert_equal( 'some_branch', cfg.track )
18
+ end
19
+
20
+ test 'accessor url() works with inheritance.' do
21
+ parent = create_configuration
22
+ cfg = BuildTool::VCS::MercurialConfiguration.new
23
+ cfg.parent = parent
24
+ # We get the value from the parent
25
+ assert_equal( 'some_url', cfg.url )
26
+ # Unless we have it overriden
27
+ cfg.url = 'different_url'
28
+ assert_equal( 'different_url', cfg.url )
29
+ # But we can reset it
30
+ cfg.url = nil
31
+ assert_equal( 'some_url', cfg.url )
32
+ end
33
+
34
+ test 'accessor branch() works.' do
35
+ cfg = create_configuration
36
+ assert_equal( 'some_branch', cfg.track )
37
+ end
38
+
39
+ test 'accessor branch() works with inheritance.' do
40
+ parent = create_configuration
41
+ cfg = BuildTool::VCS::MercurialConfiguration.new
42
+ cfg.parent = parent
43
+ # We get the value from the parent
44
+ assert_equal( 'some_branch', cfg.track )
45
+ # Unless we have it overriden
46
+ cfg.track = 'different_branch'
47
+ assert_equal( 'different_branch', cfg.track )
48
+ # But we can reset it
49
+ cfg.track = nil
50
+ assert_equal( 'some_branch', cfg.track )
51
+ end
52
+
53
+ #######
54
+ private
55
+ #######
56
+
57
+ def create_configuration
58
+ cfg = BuildTool::VCS::MercurialConfiguration.new
59
+ cfg.url = 'some_url'
60
+ cfg.track = 'some_branch'
61
+ cfg
62
+ end
63
+
64
+ end
@@ -0,0 +1,103 @@
1
+ require 'test_helper'
2
+
3
+ setup_database()
4
+
5
+ require 'build-tool/history'
6
+
7
+ class TestCommandLog < ActiveSupport::TestCase
8
+
9
+ test 'Constructor works' do
10
+ cmd = nil
11
+
12
+ # The constructor does not save
13
+ assert_no_difference( 'BuildTool::History::CommandLog.count', 'new() does not save the object' ) do
14
+
15
+ cmd = BuildTool::History::CommandLog.new(
16
+ :command => 'my_special_command',
17
+ :logdir => '/home/build-tool/log')
18
+
19
+ # Check the initial values
20
+ assert_nil( cmd.started_at, 'started_at is initialized with nil.' )
21
+ assert_nil( cmd.finished_at, 'finished_at is initialized with nil.' )
22
+ assert_equal( BuildTool::History::CommandLog::STARTED, cmd.state, 'STARTED is the initial state.' )
23
+ assert_equal( '-----', cmd.duration, '"-----" is not yet feasible.' )
24
+
25
+ end
26
+
27
+ # Now save it
28
+ cmd.save
29
+
30
+ # And check we can load it back from the db
31
+ id = cmd.id
32
+ cmd = nil
33
+ cmd = BuildTool::History::CommandLog.find( id )
34
+
35
+ # Same values as before
36
+ assert_nil( cmd.started_at, 'started_at is initialized with nil.' )
37
+ assert_nil( cmd.finished_at, 'finished_at is initialized with nil.' )
38
+ assert_equal( BuildTool::History::CommandLog::STARTED, cmd.state, 'STARTED is the initial state.' )
39
+ assert_equal( '-----', cmd.duration, '"-----" is not yet feasible.' )
40
+ end
41
+
42
+
43
+
44
+ test 'Workflow works' do
45
+
46
+ cmd = BuildTool::History::CommandLog.new(
47
+ :command => 'my_other_command',
48
+ :logdir => '/home/build-tool/log')
49
+
50
+ assert_difference( 'BuildTool::History::CommandLog.count', 1, 'started() saves the object' ) do
51
+ cmd.started()
52
+ end
53
+
54
+ # Started sets started_at and state, duration is not yet calculable
55
+ assert_equal( BuildTool::History::CommandLog::STARTED, cmd.state )
56
+ assert_not_nil( cmd.started_at, 'CommandLog.started_at is set.' )
57
+ assert_equal( '-----', cmd.duration )
58
+
59
+ # Started sets started_at and state, duration is calculable
60
+ cmd.finished( BuildTool::History::CommandLog::FINISHED_WITH_ERRORS )
61
+ assert_equal( BuildTool::History::CommandLog::FINISHED_WITH_ERRORS, cmd.state )
62
+ assert_not_nil( cmd.finished_at , 'CommandLog.finished_at is set.' )
63
+ assert_match( /[0-9][0-9]:[0-9][0-9]/, cmd.duration )
64
+
65
+ end
66
+
67
+
68
+
69
+ test 'last() returns the last n entries.' do
70
+
71
+ cmds = BuildTool::History::CommandLog.last( 1 )
72
+ assert_equal( 1, cmds.count, 'one element is returned' )
73
+ assert_equal( 'my_other_command', cmds[0].command )
74
+
75
+ cmds = BuildTool::History::CommandLog.last( 2 )
76
+ assert_equal( 2, cmds.count, 'two element are returned' )
77
+ assert_equal( 'my_special_command', cmds[1].command )
78
+ assert_equal( 'my_other_command', cmds[0].command )
79
+
80
+ end
81
+
82
+
83
+
84
+ test 'older_than() returns all modules older that 10 days.' do
85
+
86
+ # :TODO: Create a real test
87
+ cmds = BuildTool::History::CommandLog.older_than()
88
+ assert_equal( 0, cmds.count, 'no element is returned' )
89
+
90
+ end
91
+
92
+
93
+
94
+ test 'last_by_module() returns the last n entries per module.' do
95
+
96
+ # :TODO: Create a real test
97
+ cmds = BuildTool::History::CommandLog.last_by_module( 'kdelibs' )
98
+ assert_equal( 0, cmds.count, 'no element is returned' )
99
+
100
+ end
101
+ end
102
+
103
+
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+
3
+ setup_database()
4
+
5
+ require 'build-tool/model/feature'
6
+
7
+ class FeatureTest < ActiveSupport::TestCase
8
+
9
+ test 'Constructor' do
10
+ feat = BuildTool::Feature.new
11
+ end
12
+
13
+ test 'Active logic' do
14
+ feat = BuildTool::Feature.new
15
+ assert( feat.default_active?, 'By default all features are active' )
16
+ assert( feat.active?, 'By default all features are active' )
17
+ feat.default_active = false
18
+ assert( !feat.default_active? )
19
+ assert( !feat.active?, 'By default active? uses default_active?' )
20
+ feat.active = true
21
+ assert( !feat.default_active? )
22
+ assert( feat.active? )
23
+ feat.active = nil
24
+ assert( !feat.default_active? )
25
+ assert( !feat.active? )
26
+ end
27
+
28
+ end # class FeatureTest
29
+
@@ -0,0 +1,70 @@
1
+ require 'test_helper'
2
+
3
+ setup_database()
4
+
5
+ require 'build-tool/history'
6
+
7
+ class TestModuleLog < ActiveSupport::TestCase
8
+
9
+ def setup
10
+ @cmd = BuildTool::History::CommandLog.new(
11
+ :command => 'my_special_command',
12
+ :logdir => '/home/build-tool/log')
13
+ @modA = BuildTool::Module.new( :name => 'modA' )
14
+ @modB = BuildTool::Module.new( :name => 'modB' )
15
+ @cmd.started
16
+ @cmd.finished( BuildTool::History::ModuleLog::FINISHED_SUCCESSFUL )
17
+ end
18
+
19
+
20
+
21
+ test 'Constructor works' do
22
+
23
+ mod = nil
24
+
25
+ # The constructor does not save
26
+ assert_no_difference( 'BuildTool::History::ModuleLog.count', 'new() does not save the object' ) do
27
+
28
+ mod = @cmd.module_logs.build(
29
+ :module => @modA,
30
+ :event => 'compile',
31
+ :logfile => '10_kdelibs_compile.log' )
32
+
33
+ end
34
+
35
+ assert_nil( mod.started_at, 'started_at is initialized with nil.' )
36
+ assert_nil( mod.finished_at, 'finished_at is initialized with nil.' )
37
+ assert_equal( BuildTool::History::ModuleLog::STARTED, mod.state )
38
+ assert_equal( '-----', mod.duration )
39
+ assert_equal( 'modA', mod.module.name )
40
+ assert_equal( 'compile', mod.event )
41
+ assert_equal( '10_kdelibs_compile.log', mod.logfile )
42
+ end
43
+
44
+
45
+
46
+ test 'Workflow works' do
47
+
48
+ mod = @cmd.module_logs.build(
49
+ :module => @modB,
50
+ :event => 'install',
51
+ :logfile => '50_kdebase-runtime_install.log' )
52
+
53
+ # Started sets started_at and state, duration is not yet calculable
54
+ assert_difference( 'BuildTool::History::ModuleLog.count', 1, 'started() saves the object' ) do
55
+ mod.started()
56
+ end
57
+ assert_equal( BuildTool::History::ModuleLog::STARTED, mod.state )
58
+ assert_not_nil( mod.started_at, 'ModuleLog.started_at is set.' )
59
+ assert_equal( '-----', mod.duration )
60
+
61
+ # Started sets started_at and state, duration is calculable
62
+ mod.finished( BuildTool::History::ModuleLog::FINISHED_WITH_ERRORS )
63
+ assert_equal( BuildTool::History::ModuleLog::FINISHED_WITH_ERRORS, mod.state )
64
+ assert_not_nil( mod.finished_at , 'ModuleLog.finished_at is set.' )
65
+ assert_match( /[0-9][0-9]:[0-9][0-9]/, mod.duration )
66
+
67
+ end
68
+
69
+ end
70
+