build-tool 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +28 -1
  3. data/Manifest.txt +91 -52
  4. data/README.txt +63 -0
  5. data/Rakefile +20 -23
  6. data/bin/build-tool +53 -0
  7. data/lib/build-tool.rb +7 -0
  8. data/lib/build-tool/GUI.rb +360 -0
  9. data/lib/build-tool/application.rb +84 -0
  10. data/lib/build-tool/build-system/autoconf.rb +60 -0
  11. data/lib/build-tool/build-system/base.rb +142 -0
  12. data/lib/build-tool/build-system/cmake.rb +119 -0
  13. data/lib/build-tool/build-system/custom.rb +115 -0
  14. data/lib/build-tool/build-system/qt.rb +113 -0
  15. data/lib/build-tool/cfg/lexer.rb +558 -0
  16. data/lib/build-tool/cfg/lexer.rex +248 -0
  17. data/lib/build-tool/cfg/lexer_base.rb +82 -0
  18. data/lib/build-tool/cfg/node.rb +94 -0
  19. data/lib/build-tool/cfg/parser.rb +871 -0
  20. data/lib/build-tool/cfg/parser.y +279 -0
  21. data/lib/build-tool/cfg/visitor.rb +471 -0
  22. data/lib/build-tool/commands.rb +639 -0
  23. data/lib/build-tool/commands/build.rb +120 -0
  24. data/lib/build-tool/commands/configure.rb +73 -0
  25. data/lib/build-tool/commands/ctags.rb +46 -0
  26. data/lib/build-tool/commands/environments.rb +29 -0
  27. data/lib/build-tool/commands/environments/list.rb +37 -0
  28. data/lib/build-tool/commands/environments/set.rb +33 -0
  29. data/lib/build-tool/commands/fetch.rb +50 -0
  30. data/lib/build-tool/commands/files.rb +73 -0
  31. data/lib/build-tool/commands/help.rb +22 -0
  32. data/lib/build-tool/commands/info.rb +48 -0
  33. data/lib/build-tool/commands/install.rb +56 -0
  34. data/lib/build-tool/commands/modules.rb +29 -0
  35. data/lib/build-tool/commands/modules/info.rb +75 -0
  36. data/lib/build-tool/commands/modules/list.rb +49 -0
  37. data/lib/build-tool/commands/modules/shell.rb +40 -0
  38. data/lib/build-tool/commands/rebase.rb +46 -0
  39. data/lib/build-tool/commands/recipes.rb +32 -0
  40. data/lib/build-tool/commands/recipes/info.rb +46 -0
  41. data/lib/build-tool/commands/recipes/install.rb +184 -0
  42. data/lib/build-tool/commands/recipes/list.rb +33 -0
  43. data/lib/build-tool/configuration.rb +115 -0
  44. data/lib/build-tool/environment.rb +119 -0
  45. data/lib/build-tool/errors.rb +9 -0
  46. data/lib/build-tool/module.rb +366 -0
  47. data/lib/build-tool/pluginbase.rb +43 -0
  48. data/lib/build-tool/recipe.rb +180 -0
  49. data/lib/build-tool/repository.rb +59 -0
  50. data/lib/build-tool/server.rb +43 -0
  51. data/lib/build-tool/singleton.rb +50 -0
  52. data/lib/build-tool/sshkey.rb +22 -0
  53. data/lib/build-tool/vcs/base.rb +105 -0
  54. data/lib/build-tool/vcs/git-svn.rb +154 -0
  55. data/lib/build-tool/vcs/git.rb +187 -0
  56. data/lib/build-tool/vcs/svn.rb +136 -0
  57. data/lib/mj/logging.rb +31 -0
  58. data/lib/mj/tools/ssh.rb +64 -0
  59. data/lib/{kde-build → mj/tools}/subprocess.rb +21 -16
  60. data/lib/mj/visitor.rb +21 -0
  61. data/recipes/kde/files/finish_installation.sh +16 -0
  62. data/recipes/kde/files/kde4.desktop +22 -0
  63. data/recipes/kde/files/xsession +89 -0
  64. data/recipes/kde/info.yaml +10 -0
  65. data/recipes/kde/recipe +585 -0
  66. data/recipes/kde/recipe-local +90 -0
  67. data/recipes/kde/settings.yaml +52 -0
  68. data/recipes/kde43/info.yaml +10 -0
  69. data/recipes/kde43/recipe +256 -0
  70. data/recipes/kde43/recipe-local +90 -0
  71. data/recipes/kde43/settings.yaml +32 -0
  72. data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/compile.sh +77 -0
  73. data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/configure.sh +70 -0
  74. data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/install.sh +39 -0
  75. data/recipes/kdeqt4.6/info.yaml +7 -0
  76. data/recipes/kdeqt4.6/recipe +155 -0
  77. data/recipes/kdeqt4.6/recipe-local +30 -0
  78. data/recipes/kdeqt4.6/settings.yaml +27 -0
  79. data/tags +745 -0
  80. data/tasks/genfiles.rake +28 -0
  81. data/tasks/rdoc.rake +34 -0
  82. data/tasks/rspec.rake +21 -0
  83. data/test.rb +28 -0
  84. data/test/commands/test_build.rb +29 -0
  85. data/test/test_build_system.rb +98 -0
  86. data/test/test_cli.rb +61 -0
  87. data/test/test_command.rb +175 -0
  88. data/test/test_configuration_parser.rb +542 -0
  89. data/test/test_environment.rb +82 -0
  90. data/test/test_helper.rb +39 -7
  91. data/test/test_module.rb +158 -0
  92. data/test/test_repository.rb +75 -0
  93. data/test/test_singleton.rb +51 -0
  94. data/test/test_ssh_key.rb +14 -0
  95. data/test/test_svn_parser.rb +28 -0
  96. data/test/test_vcs.rb +33 -0
  97. metadata +139 -90
  98. metadata.gz.sig +0 -0
  99. data/PostInstall.txt +0 -3
  100. data/TODO +0 -2
  101. data/bin/kde-build.rb +0 -21
  102. data/config/website.yml +0 -2
  103. data/config/website.yml.sample +0 -2
  104. data/lib/kde-build.rb +0 -18
  105. data/lib/kde-build/application.rb +0 -270
  106. data/lib/kde-build/build_system.rb +0 -28
  107. data/lib/kde-build/build_system/autoconf.rb +0 -108
  108. data/lib/kde-build/build_system/base.rb +0 -139
  109. data/lib/kde-build/build_system/cmake.rb +0 -94
  110. data/lib/kde-build/build_system/qtcopy.rb +0 -127
  111. data/lib/kde-build/command.rb +0 -42
  112. data/lib/kde-build/command/build.rb +0 -106
  113. data/lib/kde-build/command/compile.rb +0 -39
  114. data/lib/kde-build/command/configure.rb +0 -48
  115. data/lib/kde-build/command/ctags.rb +0 -41
  116. data/lib/kde-build/command/fetch.rb +0 -33
  117. data/lib/kde-build/command/help.rb +0 -71
  118. data/lib/kde-build/command/info.rb +0 -45
  119. data/lib/kde-build/command/install.rb +0 -39
  120. data/lib/kde-build/command/module_based.rb +0 -44
  121. data/lib/kde-build/command/rebase.rb +0 -50
  122. data/lib/kde-build/command/version.rb +0 -43
  123. data/lib/kde-build/configuration.rb +0 -209
  124. data/lib/kde-build/exception.rb +0 -6
  125. data/lib/kde-build/metaaid.rb +0 -18
  126. data/lib/kde-build/module.rb +0 -227
  127. data/lib/kde-build/module_configuration.rb +0 -107
  128. data/lib/kde-build/moduleregistry.rb +0 -85
  129. data/lib/kde-build/tools/ctags.rb +0 -59
  130. data/lib/kde-build/tools/logging.rb +0 -49
  131. data/lib/kde-build/tools/make.rb +0 -58
  132. data/lib/kde-build/tools/ssh.rb +0 -47
  133. data/lib/kde-build/vcs.rb +0 -28
  134. data/lib/kde-build/vcs/base.rb +0 -85
  135. data/lib/kde-build/vcs/git-svn.rb +0 -139
  136. data/lib/kde-build/vcs/git.rb +0 -121
  137. data/lib/kde-build/vcs/svn.rb +0 -102
  138. data/script/console +0 -10
  139. data/script/destroy +0 -14
  140. data/script/generate +0 -14
  141. data/script/txt2html +0 -71
  142. data/test.yaml.tmpl +0 -632
  143. data/test/test_kde-build.rb +0 -11
  144. data/test/test_vcs_svn.rb +0 -44
  145. data/website/index.html +0 -84
  146. data/website/index.txt +0 -59
  147. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  148. data/website/stylesheets/screen.css +0 -159
  149. data/website/template.html.erb +0 -50
@@ -0,0 +1,28 @@
1
+ PARSER = Dir["lib/build-tool/*.y", "lib/build-tool/cfg/*.y"].map { |f| f.chomp(".y") }
2
+
3
+ rule '.rb' => [ '.y' ] do |t|
4
+ puts "generating #{t.source}"
5
+ sh "racc -o#{t.name} #{t.source}"
6
+ end
7
+
8
+ PARSER.each do |parser| # need closure
9
+ # file "#{parser}.rb" => [ "#{parser}.y" ]
10
+ task :genfiles => [ "#{parser}.rb" ]
11
+ end
12
+
13
+
14
+ LEXER = Dir["lib/build-tool/*.rex", "lib/build-tool/cfg/*.rex"].map { |f| f.chomp(".rex") }
15
+ rule '.rb' => [ '.rex' ] do |t|
16
+ puts "generating #{t.source}"
17
+ sh "rex -o#{t.name} #{t.source}"
18
+ end
19
+
20
+ LEXER.each do |lexer| # need closure
21
+ # file "#{lexer}.rb" => [ "#{lexer}.rex" ]
22
+ task :genfiles => [ "#{lexer}.rb" ]
23
+ end
24
+
25
+ task :test => :genfiles
26
+
27
+ desc 'Regenerate all rex and racc files if necessary.'
28
+ task :genfiles
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'yard'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ require 'yard'
6
+ end
7
+ begin
8
+ require 'yard/rake/yardoc_task'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use yard you must install the gem:
12
+ gem install yard
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ namespace :yard do
18
+
19
+ desc "Create yardoc documentation"
20
+ YARD::Rake::YardocTask.new :generate do |t|
21
+ t.files = ['lib/**/*.rb']
22
+ t.options = ['--output-dir', "meta/documentation" ]
23
+ end
24
+
25
+ YARD::Rake::YardocTask.new :dot_yardoc do |t|
26
+ t.files = ['lib/**/*.rb']
27
+ t.options = ['--no-output', '--readme', 'README.mkdn']
28
+ end
29
+
30
+ task :open do
31
+ system 'open ' + 'meta' / 'documentation' / 'index.html' if PLATFORM['darwin']
32
+ end
33
+
34
+ end
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
data/test.rb ADDED
@@ -0,0 +1,28 @@
1
+ module Wrrr
2
+ def self.included( base )
3
+ base.module_eval do
4
+ alias_method :old_doit, :doit
5
+ remove_method :doit
6
+ end
7
+
8
+ def doit
9
+ "Yes"
10
+ end
11
+ def doit2
12
+ "Yes"
13
+ end
14
+ end
15
+ end
16
+
17
+ class Test
18
+ def doit
19
+ "Hallo"
20
+ end
21
+ include Wrrr
22
+ end
23
+
24
+ t = Test.new
25
+ puts t.old_doit
26
+ puts t.doit
27
+ puts t.doit2
28
+
@@ -0,0 +1,29 @@
1
+ require 'pathname'
2
+ require Pathname.new( File.dirname(__FILE__)).join( '../test_helper' ).cleanpath
3
+
4
+ require 'build-tool/configuration'
5
+ require 'build-tool/commands'
6
+ require 'build-tool/commands/build'
7
+
8
+ class TestBuildCommand < ::Test::Unit::TestCase
9
+
10
+ def test_default_values
11
+ cmd = BuildTool::Commands::Build.new( BuildTool::Configuration.new(nil) )
12
+ assert_equal cmd.name, "build"
13
+ assert_equal cmd.description, "Build a module."
14
+ # clean is off by default
15
+ assert_equal false, cmd.instance_variable_get( "@clean" )
16
+ # configure is off by default
17
+ assert_equal false, cmd.instance_variable_get( "@configure" )
18
+ # from-scratch is off by default
19
+ assert_equal false, cmd.instance_variable_get( "@from_scratch" )
20
+ # install is off by default
21
+ assert_equal true, cmd.instance_variable_get( "@install" )
22
+ # reconfigure is off by default
23
+ assert_equal false, cmd.instance_variable_get( "@reconfigure" )
24
+ # update is off by default
25
+ assert_equal false, cmd.instance_variable_get( "@update" )
26
+ end
27
+
28
+ end
29
+
@@ -0,0 +1,98 @@
1
+ require 'pathname'
2
+ require Pathname.new( File.dirname(__FILE__)).join( 'test_helper' ).cleanpath
3
+
4
+ require 'build-tool/build-system/base'
5
+ require 'build-tool/module'
6
+ require 'build-tool/cfg/parser'
7
+
8
+ class TestBuildSystem < Test::Unit::TestCase
9
+
10
+ def test_creation
11
+ base = BuildTool::BuildSystem::Base.new
12
+
13
+ # Out of source build is default
14
+ assert base.out_of_source
15
+
16
+ # No module is set
17
+ assert_nil base.module
18
+
19
+ # No options set
20
+ assert_equal 0, base.options.size
21
+ end
22
+
23
+ def test_virtual_methods
24
+ base = BuildTool::BuildSystem::Base.new
25
+
26
+ assert_raise NotImplementedError do
27
+ base.configure
28
+ end
29
+
30
+ assert_raise NotImplementedError do
31
+ base.configured?
32
+ end
33
+
34
+ assert_raise NotImplementedError do
35
+ base.make
36
+ end
37
+
38
+ assert_raise NotImplementedError do
39
+ base.name
40
+ end
41
+
42
+ assert_raise NotImplementedError do
43
+ base.reconfigure
44
+ end
45
+ end
46
+
47
+ def test_module_required
48
+ base = BuildTool::BuildSystem::Base.new
49
+
50
+ assert_raise BuildTool::ConfigurationError do
51
+ base.source_directory
52
+ end
53
+
54
+ assert_raise BuildTool::ConfigurationError do
55
+ base.install_prefix
56
+ end
57
+
58
+ mod = BuildTool::Module::new( "kdelibs" )
59
+ base.module = mod
60
+
61
+ assert_raise BuildTool::ConfigurationError do
62
+ base.source_directory
63
+ end
64
+
65
+ assert_raise BuildTool::ConfigurationError do
66
+ base.install_prefix
67
+ end
68
+
69
+ mod.install_prefix= "/opt/kde"
70
+ assert_equal "/opt/kde", base.install_prefix.to_s
71
+
72
+ mod.build_prefix= "/home/user/kde"
73
+ assert_equal "/home/user/kde/src/kdelibs", base.source_directory
74
+ end
75
+
76
+ def test_dup
77
+ base = BuildTool::BuildSystem::CMake.new
78
+ base['CMAKE_BUILD_TYPE'] = 'Debug'
79
+ assert_equal 'Debug', base['CMAKE_BUILD_TYPE']
80
+ copy = base.dup
81
+ base['CMAKE_BUILD_TYPE'] = 'Release'
82
+ assert_equal 'Debug', copy['CMAKE_BUILD_TYPE']
83
+ assert_equal 'Release', base['CMAKE_BUILD_TYPE']
84
+ end
85
+
86
+ def test_parsing
87
+ text = <<EOS
88
+ build-system "cmake"
89
+ inplace
90
+ end
91
+ EOS
92
+ parser = BuildTool::Cfg::Parser.new
93
+ configuration = parser.parse_string(text)
94
+ test = configuration.build_system( "cmake" )
95
+ assert !test.out_of_source
96
+ end
97
+
98
+ end
@@ -0,0 +1,61 @@
1
+ require 'pathname'
2
+ require Pathname.new( File.dirname(__FILE__)).join( 'test_helper' ).cleanpath
3
+
4
+ require 'build-tool/configuration'
5
+ require 'build-tool/commands'
6
+ require 'build-tool/commands/build'
7
+ require 'build-tool/commands/help'
8
+ require 'build-tool/commands/recipes'
9
+ require 'build-tool/commands/recipes/list'
10
+ require 'build-tool/commands/recipes/install'
11
+
12
+ class TestCli < Test::Unit::TestCase
13
+
14
+ def setup
15
+ cfg = BuildTool::Configuration.new(nil)
16
+ @cmd = BuildTool::Commands::Shell.new( cfg )
17
+ @cmd.add_command( BuildTool::Commands::Build.new( cfg ) )
18
+ @cmd.add_command( BuildTool::Commands::Help.new( cfg ) )
19
+ @cmd.add_command( BuildTool::Commands::Recipes::CLI.new( cfg ) )
20
+ @cmd.get_command( "recipes" ).add_command( BuildTool::Commands::Recipes::List.new( cfg ) )
21
+ @cmd.get_command( "recipes" ).add_command( BuildTool::Commands::Recipes::Install.new( cfg ) )
22
+ end
23
+
24
+ def teardown
25
+ @cmd = nil
26
+ end
27
+
28
+ def test_command_completion
29
+ assert_equal ["build"], @cmd.complete_command("bui")
30
+ assert_equal ["build", "help", "recipes"], @cmd.complete_command("")
31
+
32
+ assert_equal ["build"], @cmd.complete("bui")
33
+ assert_equal ["build", "help", "recipes"], @cmd.complete("")
34
+
35
+
36
+ end
37
+
38
+ def test_subcommand_completion
39
+ if !Readline.respond_to? 'line_buffer'
40
+ assert_equal ["recipes list", "recipes install"], @cmd.complete( "recipes")
41
+ assert_equal ["recipes list", "recipes install"], @cmd.complete( "recipes ")
42
+ else
43
+ assert_equal ["list", "install"], @cmd.complete( "recipes")
44
+ assert_equal ["list", "install"], @cmd.complete( "recipes ")
45
+ end
46
+ end
47
+
48
+ def test_argument_completion
49
+ require 'readline'
50
+ cmd = @cmd.get_command( "build" )
51
+ if !Readline.respond_to? 'line_buffer'
52
+ assert_equal ["build --clean", "build --configure"], cmd.complete( "build --c" )
53
+ assert_equal ["build --from-scratch --clean", "build --from-scratch --configure"], cmd.complete( "build --from-scratch --c")
54
+ assert_equal ["build --from-scratch --install"], cmd.complete( "build --from-scratch --inst")
55
+ else
56
+ assert_equal ["--clean", "--configure"], cmd.complete( "build --c" )
57
+ assert_equal ["--clean", "--configure"], cmd.complete( "build --from-scratch --c" )
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,175 @@
1
+ require 'pathname'
2
+ require Pathname.new( File.dirname(__FILE__)).join( 'test_helper' ).cleanpath
3
+
4
+ require 'build-tool/configuration'
5
+ require 'build-tool/commands'
6
+
7
+ class TestCommand < BuildTool::Commands::Standard
8
+
9
+ name "simple_test"
10
+ description "For Testing purposes"
11
+
12
+ attr_reader :do_clean, :do_configure, :do_from_scratch, :do_install, :do_reconfigure, :do_update
13
+
14
+ def initialize_options
15
+ @do_clean = false
16
+ @do_configure = false
17
+ @do_from_scratch = false
18
+ @do_install = true
19
+ @do_reconfigure = false
20
+ @do_update = false
21
+
22
+ reset_done_markers
23
+
24
+ options.on( "--[no-]clean", "Make clean before building." ) { |t|
25
+ @do_clean = t
26
+ }
27
+
28
+ options.on( "--[no-]install", "Do not install" ) { |t|
29
+ @do_install = t
30
+ }
31
+
32
+ options.on( "--[no-]update", "Do not update from the repository" ) { |t|
33
+ @do_update = t
34
+ }
35
+
36
+ options.on( "-c", "--configure", "Run the configuration step again" ) { |t|
37
+ @do_configure = true
38
+ }
39
+
40
+ options.on( "--reconfigure", "Remove old configuration then run configuration again" ) { |t|
41
+ @do_reconfigure = true
42
+ }
43
+
44
+ options.on( nil, "--from-scratch", "Rebuild from scratch" ) { |t|
45
+ @do_from_scratch = true
46
+ }
47
+
48
+ super
49
+
50
+ end
51
+
52
+ # Reset the done markers
53
+ def reset_done_markers
54
+ @done_help = false
55
+ @done_command = false
56
+ end
57
+
58
+ # Overload the show_help method to check if it was executed
59
+ def show_help( args = [] )
60
+ @done_help = true
61
+ super
62
+ end
63
+ attr_reader :done_help
64
+
65
+ # # Overload the do_execute method to check if it was executed
66
+ def do_execute( args )
67
+ @done_command = true
68
+ end
69
+ attr_reader :done_command
70
+
71
+ end # class Build
72
+
73
+
74
+ class TestBuildtoolCommands < ::Test::Unit::TestCase
75
+
76
+ def test_default_values
77
+ cmd = TestCommand.new( BuildTool::Configuration.new(nil) )
78
+
79
+ assert_equal cmd.name, "simple_test"
80
+ assert_equal cmd.description, "For Testing purposes"
81
+
82
+ # clean is off by default
83
+ assert !cmd.do_clean, "do not clean"
84
+ # configure is off by default
85
+ assert !cmd.do_configure, "do not configure"
86
+ # from-scratch is off by default
87
+ assert !cmd.do_from_scratch, "do not build from scratch"
88
+ # install is off by default
89
+ assert cmd.do_install, "do install"
90
+ # reconfigure is off by default
91
+ assert !cmd.do_reconfigure, "do not reconfigure"
92
+ # update is off by default
93
+ assert !cmd.do_update, "do not update"
94
+
95
+ end
96
+
97
+ def test_help
98
+ # With --help call show_help and then return without executing the
99
+ # command
100
+ cmd = TestCommand.new( BuildTool::Configuration.new(nil) )
101
+ assert !cmd.done_help.nil? and !cmd.done_help
102
+ assert !cmd.done_command.nil? and !cmd.done_command
103
+
104
+ expected_output = <<EOS
105
+ Usage: simple_test [options]
106
+ --[no-]clean Make clean before building.
107
+ --[no-]install Do not install
108
+ --[no-]update Do not update from the repository
109
+ -c, --configure Run the configuration step again
110
+ --reconfigure Remove old configuration then run configuration again
111
+ --from-scratch Rebuild from scratch
112
+ Common options
113
+ -v, --verbose Enable verbose output
114
+ --dry-run Enable dry run.
115
+ -h, --help Show this help text
116
+ EOS
117
+ # *TODO* make that work again
118
+ # assert_output( expected_output ) { cmd.execute(["--help"]) }
119
+ cmd.execute(["--help"])
120
+ assert cmd.done_help, "help was shown"
121
+ assert !cmd.done_command, "command was not executed"
122
+ end
123
+
124
+ def test_verbose
125
+
126
+ Logging.logger.root.appenders = Logging.appenders.stdout(
127
+ :layout => Logging::Layouts::Pattern.new( :pattern => '%m\n' ),
128
+ :level => :info)
129
+
130
+ # --verbose should increase the verbosity by one
131
+ cmd = TestCommand.new( BuildTool::Configuration.new(nil) )
132
+
133
+ Logging.appenders['stdout'].level = :info
134
+ current = Logging.appenders['stdout'].level
135
+ cmd.execute(["--verbose"])
136
+ assert_equal current - 1, Logging.appenders['stdout'].level
137
+
138
+ Logging.appenders['stdout'].level = current
139
+ cmd.execute(["--verbose", "--verbose"])
140
+ assert_equal current - 2, Logging.appenders['stdout'].level
141
+
142
+ # There are no more levels.
143
+ Logging.appenders['stdout'].level = current
144
+ cmd.execute(["--verbose", "--verbose", "--verbose", "--verbose", "--verbose", "--verbose", "--verbose"])
145
+ assert_equal 0, Logging.appenders['stdout'].level
146
+
147
+ Logging.logger.root.clear_appenders()
148
+ end
149
+
150
+ def test_execute_twice
151
+ # When executing the command more than once make sure the options are
152
+ # reset
153
+ cmd = TestCommand.new( BuildTool::Configuration.new(nil) )
154
+ assert !cmd.done_help.nil? and !cmd.done_help
155
+ assert !cmd.done_command.nil? and !cmd.done_command
156
+ cmd.execute(["--install", "--clean"])
157
+ assert cmd.do_install, "do make install"
158
+ assert cmd.do_clean, "do make clean"
159
+
160
+ cmd.execute(["--update", "--configure"])
161
+ assert cmd.do_install, "do not make install"
162
+ assert !cmd.do_clean, "do not make clean"
163
+ assert cmd.do_update, "do update"
164
+ assert cmd.do_configure, "do configure"
165
+ end
166
+
167
+ def test_completion
168
+ cmd = TestCommand.new( BuildTool::Configuration.new(nil) )
169
+ assert_equal [ "--from-scratch" ], cmd.complete_arguments( ["--from"] )
170
+ assert_equal ["--no-clean", "--no-install", "--no-update"], cmd.complete_arguments( ["--no"] )
171
+ assert_equal ["--clean", "--configure"], cmd.complete_arguments( ["--c"] )
172
+ end
173
+
174
+ end
175
+