build-tool 0.1.4 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -3
- data/History.txt +29 -0
- data/Manifest.txt +39 -10
- data/README.txt +5 -8
- data/Rakefile +14 -6
- data/bin/build-tool +3 -35
- data/db/migrations/001_command_histories.rb +20 -0
- data/db/migrations/002_module_events.rb +24 -0
- data/db/migrations/003_command_histories_add_logfile.rb +19 -0
- data/lib/build-tool.rb +1 -1
- data/lib/build-tool/application.rb +103 -30
- data/lib/build-tool/build-system/autoconf.rb +69 -6
- data/lib/build-tool/build-system/base.rb +2 -25
- data/lib/build-tool/build-system/custom.rb +6 -19
- data/lib/build-tool/build-system/kdel10n.rb +39 -0
- data/lib/build-tool/build-system/none.rb +82 -0
- data/lib/build-tool/cfg/lexer.rb +133 -7
- data/lib/build-tool/cfg/lexer.rex +58 -6
- data/lib/build-tool/cfg/node.rb +13 -1
- data/lib/build-tool/cfg/parser.rb +519 -333
- data/lib/build-tool/cfg/parser.y +74 -11
- data/lib/build-tool/cfg/visitor.rb +182 -20
- data/lib/build-tool/command_actions.rb +202 -0
- data/lib/build-tool/commands.rb +193 -49
- data/lib/build-tool/commands/build.rb +13 -8
- data/lib/build-tool/commands/configure.rb +8 -3
- data/lib/build-tool/commands/environments.rb +4 -8
- data/lib/build-tool/commands/environments/list.rb +8 -0
- data/lib/build-tool/commands/fetch.rb +7 -2
- data/lib/build-tool/commands/gc.rb +53 -0
- data/lib/build-tool/commands/history.rb +111 -0
- data/lib/build-tool/commands/install.rb +6 -1
- data/lib/build-tool/commands/lsfeatures.rb +73 -0
- data/lib/build-tool/commands/modules.rb +3 -7
- data/lib/build-tool/commands/modules/info.rb +15 -6
- data/lib/build-tool/commands/modules/list.rb +10 -5
- data/lib/build-tool/commands/rebase.rb +6 -1
- data/lib/build-tool/commands/recipes.rb +3 -7
- data/lib/build-tool/configuration.rb +24 -1
- data/lib/build-tool/environment.rb +17 -3
- data/lib/build-tool/feature.rb +47 -0
- data/lib/build-tool/history.rb +173 -0
- data/lib/build-tool/module.rb +49 -90
- data/lib/build-tool/recipe.rb +5 -0
- data/lib/build-tool/vcs/archive.rb +140 -0
- data/lib/build-tool/vcs/base.rb +5 -5
- data/lib/build-tool/vcs/git-svn.rb +4 -0
- data/lib/build-tool/vcs/git.rb +4 -0
- data/lib/mj/logging.rb +11 -0
- data/recipes/{kdeqt4.6 → kde}/custom/qt/qtscriptgenerator/compile.sh +0 -0
- data/recipes/{kdeqt4.6 → kde}/custom/qt/qtscriptgenerator/configure.sh +0 -0
- data/recipes/{kdeqt4.6 → kde}/custom/qt/qtscriptgenerator/install.sh +0 -0
- data/recipes/kde/custom/scripting/pyqt4/compile.sh +10 -0
- data/recipes/kde/custom/scripting/pyqt4/configure.sh +14 -0
- data/recipes/kde/custom/scripting/pyqt4/install.sh +10 -0
- data/recipes/kde/custom/scripting/sip/compile.sh +10 -0
- data/recipes/kde/custom/scripting/sip/configure.sh +13 -0
- data/recipes/kde/custom/scripting/sip/install.sh +10 -0
- data/recipes/kde/files/xsession +8 -4
- data/recipes/kde/kde-bindings.recipe +22 -0
- data/recipes/kde/kde-core.recipe +104 -0
- data/recipes/kde/kde-devel.recipe +38 -0
- data/recipes/kde/kde-finance.recipe +17 -0
- data/recipes/kde/kde-graphics.recipe +27 -0
- data/recipes/kde/kde-kdevelop.recipe +116 -0
- data/recipes/kde/kde-l10n.recipe +14 -0
- data/recipes/kde/kde-multimedia.recipe +31 -0
- data/recipes/kde/kde-network.recipe +55 -0
- data/recipes/kde/kde-office.recipe +28 -0
- data/recipes/kde/kde-plasma.recipe +117 -0
- data/recipes/{kdeqt4.6/recipe → kde/kde-qt.recipe} +25 -57
- data/recipes/kde/kde-scripting.recipe +63 -0
- data/recipes/kde/kde-support.recipe +73 -0
- data/recipes/kde/kde-utils.recipe +22 -0
- data/recipes/kde/kde-webdev.recipe +41 -0
- data/recipes/kde/recipe +92 -532
- data/recipes/kde/recipe-local +58 -2
- data/recipes/kde/settings.yaml +17 -0
- data/recipes/kde43/recipe-local +58 -2
- data/test/test_configuration_parser.rb +76 -21
- data/test/test_feature.rb +34 -0
- data/test/test_history.rb +149 -0
- metadata +185 -30
- metadata.gz.sig +0 -0
- data/lib/build-tool/pluginbase.rb +0 -43
- data/recipes/kdeqt4.6/info.yaml +0 -7
- data/recipes/kdeqt4.6/recipe-local +0 -30
- data/recipes/kdeqt4.6/settings.yaml +0 -27
- data/tasks/rdoc.rake +0 -34
- data/test.rb +0 -28
data/recipes/kde/recipe-local
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# See http://techbase.kde.org/Contribute/Get_a_SVN_Account
|
2
|
+
# vim: textwidth=80
|
2
3
|
#############################################################################
|
3
4
|
# SSH-KEYS
|
4
5
|
#############################################################################
|
@@ -16,7 +17,7 @@
|
|
16
17
|
# server "svn.kde.org"
|
17
18
|
# protocol "svn+ssh"
|
18
19
|
# host "svn.kde.org"
|
19
|
-
# path "home/kde
|
20
|
+
# path "home/kde"
|
20
21
|
# end
|
21
22
|
|
22
23
|
#############################################################################
|
@@ -44,6 +45,36 @@
|
|
44
45
|
# use ssh-key "user(at)example.com"
|
45
46
|
# end
|
46
47
|
|
48
|
+
#############################################################################
|
49
|
+
# FEATURES
|
50
|
+
#############################################################################
|
51
|
+
# Enable or disable features the recipe provides. Have a look at
|
52
|
+
# > lsfeatures
|
53
|
+
# > lsfeature [feature]
|
54
|
+
# to get more information what each feature provides.
|
55
|
+
|
56
|
+
# Only disable the support feature if you know what you do. For trunk it's
|
57
|
+
# normally recommended to use kdesupport trunk.
|
58
|
+
# disable feature "support" # It's recommended to use kdesupport for trunk development
|
59
|
+
|
60
|
+
disable feature "bindings"
|
61
|
+
disable feature "devel"
|
62
|
+
disable feature "devel/icecream"
|
63
|
+
disable feature "finance"
|
64
|
+
disable feature "graphics"
|
65
|
+
disable feature "kdeqt"
|
66
|
+
disable feature "kdevelop"
|
67
|
+
disable feature "kdevelop/plugins"
|
68
|
+
disable feature "l10n"
|
69
|
+
disable feature "multimedia"
|
70
|
+
disable feature "network"
|
71
|
+
disable feature "office"
|
72
|
+
disable feature "plasma"
|
73
|
+
disable feature "scripting/python"
|
74
|
+
disable feature "utils"
|
75
|
+
disable feature "webdev"
|
76
|
+
disable feature "webkit"
|
77
|
+
|
47
78
|
#############################################################################
|
48
79
|
# ENVIRONMENTS
|
49
80
|
#############################################################################
|
@@ -64,7 +95,7 @@
|
|
64
95
|
|
65
96
|
# The CMAKE_CXX_FLAGS option is added to the already existing configuration
|
66
97
|
# from the global recipe. As we can't add to it just set the complete value
|
67
|
-
# module "
|
98
|
+
# module "kde-core"
|
68
99
|
# build-system cmake
|
69
100
|
# option CMAKE_CXXFLAGS "-Wall -pipe -O0 -pedantic -Wno-long-long"
|
70
101
|
# end
|
@@ -88,3 +119,28 @@
|
|
88
119
|
# end
|
89
120
|
# end
|
90
121
|
|
122
|
+
#############################################################################
|
123
|
+
# GITORIOUS KDEDEVELOPERS
|
124
|
+
#############################################################################
|
125
|
+
# There is a kdedevelopers group on gitorious. If you belong to it uncomment the
|
126
|
+
# following code which changes the server url of all kdedevelopers owned
|
127
|
+
# projects so you can push to them.
|
128
|
+
# server "kdedevelopers.gitorious.org"
|
129
|
+
# host "git@gitorious.org:"
|
130
|
+
# end
|
131
|
+
|
132
|
+
#############################################################################
|
133
|
+
# KDE I18N
|
134
|
+
#############################################################################
|
135
|
+
|
136
|
+
# To enable just adapt the following snippet to your needs. You can copy it and add more languages
|
137
|
+
# if you like
|
138
|
+
|
139
|
+
# module "l10n/de" < l10n
|
140
|
+
# remote-path "l10n-kde4/de"
|
141
|
+
# end
|
142
|
+
|
143
|
+
# module "l10n/en_GB" < l10n
|
144
|
+
# remote-path "l10n-kde4/en_GB"
|
145
|
+
# end
|
146
|
+
|
data/recipes/kde/settings.yaml
CHANGED
@@ -8,6 +8,14 @@ SETTINGS:
|
|
8
8
|
# BUILD_DIR/log -> log files
|
9
9
|
BUILD_DIR: "~/kde4/trunk"
|
10
10
|
|
11
|
+
# Install prefix for qt.
|
12
|
+
QT_PREFIX: "/kde4/qt/4.6"
|
13
|
+
|
14
|
+
# The same as QT_PREFIX if you enable the qt/qt module (feature kdeqt). If you want to use a
|
15
|
+
# distro provided Qt ypu have to adjust this path if you want to compile qt/qtscriptgenerator.
|
16
|
+
# All other modules will find the correct qt without it.
|
17
|
+
QTDIR: "/kde4/qt/4.6"
|
18
|
+
|
11
19
|
# Install prefix for kdesupport
|
12
20
|
KDESUPPORT_PREFIX: "/kde4/trunk/support"
|
13
21
|
|
@@ -50,3 +58,12 @@ SETTINGS:
|
|
50
58
|
# if not or others along that line.
|
51
59
|
XDG_DATA_DIRS: "/usr/share:/share"
|
52
60
|
|
61
|
+
#
|
62
|
+
### SCRIPTING/PYTHON FEATURE
|
63
|
+
#
|
64
|
+
# See 'man python'.
|
65
|
+
PYTHONPATH: ""
|
66
|
+
# See 'python -V'. Skip the third number
|
67
|
+
PYTHON_VERSION: "2.6"
|
68
|
+
# Additional directories for sip to look for definition files
|
69
|
+
SIP_INCLUDES: ""
|
data/recipes/kde43/recipe-local
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# See http://techbase.kde.org/Contribute/Get_a_SVN_Account
|
2
|
+
# vim: textwidth=80
|
2
3
|
#############################################################################
|
3
4
|
# SSH-KEYS
|
4
5
|
#############################################################################
|
@@ -16,7 +17,7 @@
|
|
16
17
|
# server "svn.kde.org"
|
17
18
|
# protocol "svn+ssh"
|
18
19
|
# host "svn.kde.org"
|
19
|
-
# path "home/kde
|
20
|
+
# path "home/kde"
|
20
21
|
# end
|
21
22
|
|
22
23
|
#############################################################################
|
@@ -44,6 +45,36 @@
|
|
44
45
|
# use ssh-key "user(at)example.com"
|
45
46
|
# end
|
46
47
|
|
48
|
+
#############################################################################
|
49
|
+
# FEATURES
|
50
|
+
#############################################################################
|
51
|
+
# Enable or disable features the recipe provides. Have a look at
|
52
|
+
# > lsfeatures
|
53
|
+
# > lsfeature [feature]
|
54
|
+
# to get more information what each feature provides.
|
55
|
+
|
56
|
+
# Only disable the support feature if you know what you do. For trunk it's
|
57
|
+
# normally recommended to use kdesupport trunk.
|
58
|
+
# disable feature "support" # It's recommended to use kdesupport for trunk development
|
59
|
+
|
60
|
+
disable feature "bindings"
|
61
|
+
disable feature "devel"
|
62
|
+
disable feature "devel/icecream"
|
63
|
+
disable feature "finance"
|
64
|
+
disable feature "graphics"
|
65
|
+
disable feature "kdeqt"
|
66
|
+
disable feature "kdevelop"
|
67
|
+
disable feature "kdevelop/plugins"
|
68
|
+
disable feature "l10n"
|
69
|
+
disable feature "multimedia"
|
70
|
+
disable feature "network"
|
71
|
+
disable feature "office"
|
72
|
+
disable feature "plasma"
|
73
|
+
disable feature "scripting/python"
|
74
|
+
disable feature "utils"
|
75
|
+
disable feature "webdev"
|
76
|
+
disable feature "webkit"
|
77
|
+
|
47
78
|
#############################################################################
|
48
79
|
# ENVIRONMENTS
|
49
80
|
#############################################################################
|
@@ -64,7 +95,7 @@
|
|
64
95
|
|
65
96
|
# The CMAKE_CXX_FLAGS option is added to the already existing configuration
|
66
97
|
# from the global recipe. As we can't add to it just set the complete value
|
67
|
-
# module "
|
98
|
+
# module "kde-core"
|
68
99
|
# build-system cmake
|
69
100
|
# option CMAKE_CXXFLAGS "-Wall -pipe -O0 -pedantic -Wno-long-long"
|
70
101
|
# end
|
@@ -88,3 +119,28 @@
|
|
88
119
|
# end
|
89
120
|
# end
|
90
121
|
|
122
|
+
#############################################################################
|
123
|
+
# GITORIOUS KDEDEVELOPERS
|
124
|
+
#############################################################################
|
125
|
+
# There is a kdedevelopers group on gitorious. If you belong to it uncomment the
|
126
|
+
# following code which changes the server url of all kdedevelopers owned
|
127
|
+
# projects so you can push to them.
|
128
|
+
# server "kdedevelopers.gitorious.org"
|
129
|
+
# host "git@gitorious.org:"
|
130
|
+
# end
|
131
|
+
|
132
|
+
#############################################################################
|
133
|
+
# KDE I18N
|
134
|
+
#############################################################################
|
135
|
+
|
136
|
+
# To enable just adapt the following snippet to your needs. You can copy it and add more languages
|
137
|
+
# if you like
|
138
|
+
|
139
|
+
# module "l10n/de" < l10n
|
140
|
+
# remote-path "l10n-kde4/de"
|
141
|
+
# end
|
142
|
+
|
143
|
+
# module "l10n/en_GB" < l10n
|
144
|
+
# remote-path "l10n-kde4/en_GB"
|
145
|
+
# end
|
146
|
+
|
@@ -90,8 +90,8 @@ class TestConfigurationParser < Test::Unit::TestCase
|
|
90
90
|
end
|
91
91
|
|
92
92
|
repository kde
|
93
|
-
server
|
94
|
-
path
|
93
|
+
use server kde
|
94
|
+
path "KDE"
|
95
95
|
end
|
96
96
|
|
97
97
|
repository kde
|
@@ -117,6 +117,61 @@ class TestConfigurationParser < Test::Unit::TestCase
|
|
117
117
|
assert_equal "svn+ssh://mjansen@svn.kde.org/home/kde/KDE", default.url
|
118
118
|
end
|
119
119
|
|
120
|
+
def test_features
|
121
|
+
text = <<-EOS
|
122
|
+
feature devel
|
123
|
+
short description "KDE Development Tools"
|
124
|
+
feature playground
|
125
|
+
short description "Playground modules"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
feature graphics
|
130
|
+
short description "KDE Development Tools"
|
131
|
+
feature playground
|
132
|
+
short description "Playground modules"
|
133
|
+
module kdesupport end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
disable feature graphics
|
138
|
+
EOS
|
139
|
+
parser = BuildTool::Cfg::Parser.new
|
140
|
+
configuration = parser.parse_string(text)
|
141
|
+
|
142
|
+
# Check devel top level feature ( active )
|
143
|
+
devel = configuration.feature("devel")
|
144
|
+
assert devel.active?
|
145
|
+
assert "KDE Development Tools", devel.description
|
146
|
+
assert "devel", devel.path
|
147
|
+
assert "devel", devel.name
|
148
|
+
assert_nil devel.parent
|
149
|
+
|
150
|
+
# Check devel/playground feature ( active )
|
151
|
+
playground = configuration.feature("devel/playground")
|
152
|
+
assert playground.active?
|
153
|
+
assert "Playground modules", playground.description
|
154
|
+
assert "playground", playground.path
|
155
|
+
assert "devel/playground", playground.name
|
156
|
+
assert_equal devel, playground.parent
|
157
|
+
|
158
|
+
# Check graphics top level feature ( not active )
|
159
|
+
graphics = configuration.feature("graphics")
|
160
|
+
assert !graphics.active?
|
161
|
+
assert "KDE Development Tools", graphics.description
|
162
|
+
assert "graphics", graphics.path
|
163
|
+
assert "graphics", graphics.name
|
164
|
+
assert_nil graphics.parent
|
165
|
+
|
166
|
+
# Check graphics/playground feature ( not active )
|
167
|
+
playground = configuration.feature("graphics/playground")
|
168
|
+
assert !playground.active?
|
169
|
+
assert "Playground modules", playground.description
|
170
|
+
assert "playground", playground.path
|
171
|
+
assert "graphics/playground", playground.name
|
172
|
+
assert_equal graphics, playground.parent
|
173
|
+
end
|
174
|
+
|
120
175
|
def test_module
|
121
176
|
text = <<-EOS
|
122
177
|
environment kdelibs end
|
@@ -127,13 +182,13 @@ class TestConfigurationParser < Test::Unit::TestCase
|
|
127
182
|
end
|
128
183
|
|
129
184
|
repository kde
|
130
|
-
server
|
131
|
-
path
|
185
|
+
use server kde
|
186
|
+
path "/home/kde"
|
132
187
|
end
|
133
188
|
|
134
189
|
repository kde-core
|
135
|
-
server
|
136
|
-
path
|
190
|
+
use server kde
|
191
|
+
path "/home/kde"
|
137
192
|
end
|
138
193
|
|
139
194
|
module kdelibs
|
@@ -175,9 +230,9 @@ class TestConfigurationParser < Test::Unit::TestCase
|
|
175
230
|
end
|
176
231
|
|
177
232
|
repository kde
|
178
|
-
server
|
179
|
-
path
|
180
|
-
user
|
233
|
+
use server kde
|
234
|
+
path "/home"
|
235
|
+
user mjansen
|
181
236
|
end
|
182
237
|
|
183
238
|
module kdelibs
|
@@ -268,9 +323,9 @@ class TestConfigurationParser < Test::Unit::TestCase
|
|
268
323
|
end
|
269
324
|
|
270
325
|
repository kde
|
271
|
-
server
|
272
|
-
path
|
273
|
-
user
|
326
|
+
use server kde
|
327
|
+
path "/home"
|
328
|
+
user mjansen
|
274
329
|
end
|
275
330
|
|
276
331
|
module kdelibs
|
@@ -311,9 +366,9 @@ class TestConfigurationParser < Test::Unit::TestCase
|
|
311
366
|
|
312
367
|
# Change the kde repository
|
313
368
|
repository kde
|
314
|
-
server
|
315
|
-
path
|
316
|
-
user
|
369
|
+
use server kde
|
370
|
+
path "/home"
|
371
|
+
user meier
|
317
372
|
end
|
318
373
|
|
319
374
|
# test inheritance
|
@@ -396,9 +451,9 @@ class TestConfigurationParser < Test::Unit::TestCase
|
|
396
451
|
end
|
397
452
|
|
398
453
|
repository kde
|
399
|
-
server
|
400
|
-
path
|
401
|
-
user
|
454
|
+
use server kde
|
455
|
+
path "/home"
|
456
|
+
user mjansen
|
402
457
|
end
|
403
458
|
|
404
459
|
module kdelibstemplate TEMPLATE
|
@@ -449,9 +504,9 @@ class TestConfigurationParser < Test::Unit::TestCase
|
|
449
504
|
end
|
450
505
|
|
451
506
|
repository kde
|
452
|
-
server
|
453
|
-
path
|
454
|
-
user
|
507
|
+
use server kde
|
508
|
+
path "/home"
|
509
|
+
user mjansen
|
455
510
|
end
|
456
511
|
|
457
512
|
environment default
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require Pathname.new( File.dirname(__FILE__)).join( 'test_helper' ).cleanpath
|
3
|
+
|
4
|
+
require 'build-tool/feature'
|
5
|
+
|
6
|
+
class TestFeature < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_simple_creation
|
9
|
+
testfeat = BuildTool::Feature.new( "test" )
|
10
|
+
assert_equal "test", testfeat.name
|
11
|
+
assert testfeat.active?
|
12
|
+
assert_nil testfeat.parent
|
13
|
+
assert_equal "test", testfeat.path
|
14
|
+
|
15
|
+
test2feat = BuildTool::Feature.new( "test2", testfeat, false )
|
16
|
+
assert_equal "test2", test2feat.name
|
17
|
+
assert !test2feat.active?
|
18
|
+
assert_equal testfeat, test2feat.parent
|
19
|
+
assert_equal "test/test2", test2feat.path
|
20
|
+
|
21
|
+
test3feat = BuildTool::Feature.new( "test3", testfeat )
|
22
|
+
assert_equal "test3", test3feat.name
|
23
|
+
assert test3feat.active?
|
24
|
+
assert_equal testfeat, test3feat.parent
|
25
|
+
assert_equal "test/test3", test3feat.path
|
26
|
+
|
27
|
+
# Check that disabling the parent feature disables the child feature
|
28
|
+
testfeat.active = false
|
29
|
+
assert !testfeat.active?
|
30
|
+
assert !test3feat.active?
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require Pathname.new( File.dirname(__FILE__)).join( 'test_helper' ).cleanpath
|
3
|
+
|
4
|
+
require 'sequel'
|
5
|
+
require 'sequel/extensions/migration'
|
6
|
+
|
7
|
+
# Create a memory database
|
8
|
+
database = Sequel.sqlite
|
9
|
+
Sequel::Migrator.apply( database, 'db/migrations' )
|
10
|
+
|
11
|
+
require 'build-tool/history'
|
12
|
+
|
13
|
+
class TestHistory < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def test_command_log
|
16
|
+
cmd = BuildTool::History::CommandLog.new(
|
17
|
+
:command => "test" )
|
18
|
+
assert_equal cmd.command, "test"
|
19
|
+
assert_nil cmd.started_at
|
20
|
+
assert_nil cmd.finished_at
|
21
|
+
assert_nil cmd.id
|
22
|
+
assert_nil cmd.state
|
23
|
+
|
24
|
+
# #started sets the started_at attribute and saves the object. Nothing else.
|
25
|
+
cmd.started
|
26
|
+
assert_not_nil cmd.id
|
27
|
+
assert_equal cmd.command, "test"
|
28
|
+
assert_not_nil cmd.started_at
|
29
|
+
assert_nil cmd.finished_at
|
30
|
+
assert_equal BuildTool::History::CommandLog::STARTED, cmd.state
|
31
|
+
|
32
|
+
# Check that the started state will lead to an exception on finished
|
33
|
+
assert_raises StandardError do
|
34
|
+
cmd.finished( BuildTool::History::CommandLog::STARTED )
|
35
|
+
end
|
36
|
+
|
37
|
+
# #finished sets the finished_at attribute and saves the object. Nothing else.
|
38
|
+
cmd.finished( BuildTool::History::CommandLog::FINISHED_SUCCESSFUL )
|
39
|
+
assert_not_nil cmd.id
|
40
|
+
assert_equal cmd.command, "test"
|
41
|
+
assert_not_nil cmd.started_at
|
42
|
+
assert_not_nil cmd.finished_at
|
43
|
+
assert cmd.finished_at > cmd.started_at
|
44
|
+
assert_equal BuildTool::History::CommandLog::FINISHED_SUCCESSFUL, cmd.state
|
45
|
+
|
46
|
+
# Reload the object from db
|
47
|
+
id = cmd.id
|
48
|
+
cmd = nil
|
49
|
+
cmd = BuildTool::History::CommandLog[id]
|
50
|
+
assert_equal id, cmd.id
|
51
|
+
assert_equal cmd.command, "test"
|
52
|
+
assert_not_nil cmd.started_at
|
53
|
+
assert_not_nil cmd.finished_at
|
54
|
+
assert cmd.finished_at > cmd.started_at
|
55
|
+
|
56
|
+
# Create more entried
|
57
|
+
for i in 1..50 do
|
58
|
+
cmd = BuildTool::History::CommandLog.new(
|
59
|
+
:command => "test #{i}" )
|
60
|
+
cmd.started
|
61
|
+
cmd.finished( BuildTool::History::CommandLog::FINISHED_SUCCESSFUL )
|
62
|
+
# Remember the last id
|
63
|
+
maxid = cmd.id
|
64
|
+
end
|
65
|
+
|
66
|
+
# Get the latest history entry
|
67
|
+
cmd = BuildTool::History::CommandLog::most_recent
|
68
|
+
assert_equal maxid, cmd.id
|
69
|
+
|
70
|
+
# Get the latest ten history entries
|
71
|
+
arr = BuildTool::History::CommandLog.last( 10 )
|
72
|
+
assert_equal 10, arr.size
|
73
|
+
assert_equal maxid, arr[0].id
|
74
|
+
|
75
|
+
lastid = maxid+1
|
76
|
+
while nxt = arr.shift
|
77
|
+
assert lastid > nxt.id
|
78
|
+
lastid = nxt.id
|
79
|
+
end
|
80
|
+
|
81
|
+
end # test_command_log
|
82
|
+
|
83
|
+
|
84
|
+
def test_module_log
|
85
|
+
# Get a command to work with
|
86
|
+
cmd = BuildTool::History::CommandLog::most_recent
|
87
|
+
|
88
|
+
# Create a empty one
|
89
|
+
mod = BuildTool::History::ModuleLog.new
|
90
|
+
assert_nil mod.id
|
91
|
+
assert_nil mod.module
|
92
|
+
assert_nil mod.command_log_id
|
93
|
+
assert_nil mod.event
|
94
|
+
assert_nil mod.logfile
|
95
|
+
assert_nil mod.started_at
|
96
|
+
assert_nil mod.finished_at
|
97
|
+
assert_nil mod.state
|
98
|
+
|
99
|
+
assert_raises Sequel::DatabaseError do
|
100
|
+
mod.save
|
101
|
+
end
|
102
|
+
|
103
|
+
mod.module = "test"
|
104
|
+
assert_raises Sequel::DatabaseError do
|
105
|
+
mod.save
|
106
|
+
end
|
107
|
+
|
108
|
+
mod.event = "update"
|
109
|
+
assert_raises Sequel::DatabaseError do
|
110
|
+
mod.save
|
111
|
+
end
|
112
|
+
|
113
|
+
# SQLite3 does not check foreign keys (just to remember
|
114
|
+
mod.command_log_id = 45000
|
115
|
+
mod.save
|
116
|
+
|
117
|
+
mod = BuildTool::History::ModuleLog.new(
|
118
|
+
:command_log_id => cmd.id,
|
119
|
+
:module => "test_module",
|
120
|
+
:event => "update",
|
121
|
+
:logfile => "/path/to/my/logfile")
|
122
|
+
assert_equal mod.command_log_id, cmd.id
|
123
|
+
assert_equal "test_module", mod.module
|
124
|
+
assert_equal "update", mod.event
|
125
|
+
assert_equal "/path/to/my/logfile", mod.logfile
|
126
|
+
assert_nil mod.id
|
127
|
+
|
128
|
+
# Start the event
|
129
|
+
mod.started
|
130
|
+
assert_not_nil mod.id
|
131
|
+
assert_not_nil mod.started_at
|
132
|
+
assert_equal mod.state, BuildTool::History::ModuleLog::STARTED
|
133
|
+
|
134
|
+
# Finish the event
|
135
|
+
assert_raises StandardError do
|
136
|
+
mod.finished( BuildTool::History::ModuleLog::STARTED )
|
137
|
+
end
|
138
|
+
|
139
|
+
mod.finished( BuildTool::History::ModuleLog::FINISHED_SUCCESSFUL )
|
140
|
+
assert_not_nil mod.finished_at
|
141
|
+
assert_equal mod.state, BuildTool::History::ModuleLog::FINISHED_SUCCESSFUL
|
142
|
+
|
143
|
+
cmds = BuildTool::History::CommandLog.last_by_module( "test_module" )
|
144
|
+
puts cmds.inspect
|
145
|
+
assert_equal 1, cmds.count
|
146
|
+
end
|
147
|
+
|
148
|
+
end # class TestHistory
|
149
|
+
|