falsework 2.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/README.rdoc +19 -59
  2. data/Rakefile +28 -20
  3. data/bin/falsework +266 -73
  4. data/doc/NEWS.rdoc +24 -0
  5. data/doc/README.rdoc +19 -59
  6. data/doc/TODO.org +16 -6
  7. data/doc/template-tutorial.rdoc +49 -12
  8. data/dynamic.yaml +4 -0
  9. data/falsework.gemspec +10 -1
  10. data/lib/falsework/cliconfig.rb +14 -9
  11. data/lib/falsework/cliutils.rb +0 -2
  12. data/lib/falsework/meta.rb +2 -1
  13. data/lib/falsework/mould.rb +121 -192
  14. data/lib/falsework/upgrader.rb +120 -0
  15. data/lib/falsework/utils.rb +23 -0
  16. data/templates/c-glib/#config.yaml +18 -0
  17. data/{lib/falsework/templates → templates}/c-glib/README +0 -0
  18. data/{lib/falsework/templates → templates}/c-glib/doc/#doc.ascii +0 -0
  19. data/{lib/falsework/templates → templates}/c-glib/doc/%%@project%%.1.asciidoc +0 -0
  20. data/{lib/falsework/templates → templates}/c-glib/doc/LICENSE +0 -0
  21. data/{lib/falsework/templates → templates}/c-glib/doc/Makefile +0 -0
  22. data/{lib/falsework/templates → templates}/c-glib/src/#exe.c +0 -0
  23. data/{lib/falsework/templates → templates}/c-glib/src/#exe.h +0 -0
  24. data/{lib/falsework/templates → templates}/c-glib/src/%%@project%%.c +0 -0
  25. data/{lib/falsework/templates → templates}/c-glib/src/%%@project%%.h +0 -0
  26. data/{lib/falsework/templates → templates}/c-glib/src/Makefile +0 -0
  27. data/{lib/falsework/templates → templates}/c-glib/src/untest.c +0 -0
  28. data/{lib/falsework/templates → templates}/c-glib/src/untest.h +0 -0
  29. data/{lib/falsework/templates → templates}/c-glib/src/utils.c +0 -0
  30. data/{lib/falsework/templates → templates}/c-glib/src/utils.h +0 -0
  31. data/{lib/falsework/templates → templates}/c-glib/test/#test.c +0 -0
  32. data/{lib/falsework/templates → templates}/c-glib/test/Makefile +0 -0
  33. data/{lib/falsework/templates → templates}/c-glib/test/Makefile.test.mk +0 -0
  34. data/{lib/falsework/templates → templates}/c-glib/test/mycat.c +0 -0
  35. data/{lib/falsework/templates → templates}/c-glib/test/semis/text/empty.txt +0 -0
  36. data/{lib/falsework/templates → templates}/c-glib/test/test_utils.c +0 -0
  37. data/templates/ruby-cli/#config.yaml +26 -0
  38. data/{lib/falsework/templates → templates}/ruby-cli/%%@project%%.gemspec +0 -0
  39. data/{lib/falsework/templates → templates}/ruby-cli/.gitignore +0 -0
  40. data/{lib/falsework/templates → templates}/ruby-cli/.gitignore.#erb +0 -0
  41. data/{lib/falsework/templates → templates}/ruby-cli/Gemfile +0 -0
  42. data/{lib/falsework/templates → templates}/ruby-cli/README.rdoc +17 -19
  43. data/{lib/falsework/templates → templates}/ruby-cli/Rakefile +0 -0
  44. data/{lib/falsework/templates → templates}/ruby-cli/bin/%%@project%% +3 -3
  45. data/{lib/falsework/templates → templates}/ruby-cli/doc/#doc.rdoc +16 -18
  46. data/{lib/falsework/templates → templates}/ruby-cli/doc/LICENSE +0 -0
  47. data/{lib/falsework/templates → templates}/ruby-cli/doc/NEWS.rdoc +0 -0
  48. data/{lib/falsework/templates → templates}/ruby-cli/doc/README.rdoc +17 -19
  49. data/templates/ruby-cli/etc/%%@project%%.yaml +2 -0
  50. data/{lib/falsework/templates → templates}/ruby-cli/lib/%%@project%%/cliconfig.rb +14 -11
  51. data/{lib/falsework/templates → templates}/ruby-cli/lib/%%@project%%/cliutils.rb +0 -4
  52. data/{lib/falsework/templates → templates}/ruby-cli/lib/%%@project%%/meta.rb +1 -0
  53. data/{lib/falsework/templates → templates}/ruby-cli/test/helper.rb +0 -0
  54. data/{lib/falsework/templates → templates}/ruby-cli/test/helper_cliutils.rb +0 -3
  55. data/{lib/falsework/templates → templates}/ruby-cli/test/test_%%@project%%.rb +0 -0
  56. data/test/example/note/full +10 -0
  57. data/test/example/note/project-too-old +8 -0
  58. data/test/example/note/template-unknown +8 -0
  59. data/test/helper.rb +11 -0
  60. data/test/helper_cliutils.rb +0 -1
  61. data/test/templates/config-01.yaml +1 -1
  62. data/test/{test_exe.rb → test_cli.rb} +52 -29
  63. data/test/test_mould.rb +41 -16
  64. data/test/test_upgrader.rb +96 -0
  65. metadata +76 -50
  66. data/dynamic.ruby-cli +0 -3
  67. data/lib/falsework/templates/c-glib/#config.yaml +0 -18
  68. data/lib/falsework/templates/ruby-cli/#config.yaml +0 -15
  69. data/lib/falsework/templates/ruby-cli/etc/%%@project%%.yaml +0 -2
  70. data/test/rake_erb_templates.rb +0 -60
  71. data/test/templates/config-02.yaml +0 -2
  72. data/test/test_cl.rb +0 -33
@@ -0,0 +1,26 @@
1
+ ---
2
+ exe:
3
+ - src: 'bin/%%@project%%'
4
+ dest: 'bin/%s'
5
+ mode_int: 0744
6
+
7
+ doc:
8
+ - src: 'doc/#doc.rdoc'
9
+ dest: 'doc/%s.rdoc'
10
+ mode_int: null
11
+
12
+ test:
13
+ - src: 'test/test_%%@project%%.rb'
14
+ dest: 'test/test_%s.rb'
15
+ mode_int: null
16
+
17
+ version: 3.0.0
18
+
19
+ upgrade:
20
+ obsolete:
21
+ - test/rake_git.rb
22
+ files:
23
+ - lib/%%@project%%/cliconfig.rb
24
+ - lib/%%@project%%/cliutils.rb
25
+ - test/helper_cliutils.rb
26
+ from: 2.0.0
@@ -1,21 +1,21 @@
1
- =Name
1
+ = Name
2
2
 
3
3
  <%= @classy %>--[TODO: write a summary here.]
4
4
 
5
5
 
6
- ==Synopsis
6
+ == Synopsis
7
7
 
8
8
  <%= @project %> [options]
9
9
 
10
10
 
11
- ==Description
11
+ == Description
12
12
 
13
13
  The <%= @project %> utility [TODO: write a description here.]
14
14
 
15
15
  The options are as follows:
16
16
 
17
17
  --config-dirs:: List all possible locations for the
18
- configuration file. The first found wins.
18
+ configuration file.
19
19
 
20
20
  --config NAME:: The name of the configuration file. If
21
21
  it contains <tt>/</tt> in it, the list from
@@ -29,28 +29,26 @@ The options are as follows:
29
29
 
30
30
  --foobar NAME:: Huh?
31
31
 
32
- ==Configuration
33
32
 
34
- <%= @project %> looks for its configuration at 3 places at start up.
33
+ == Configuration
35
34
 
36
- 1. At <tt><%= @project.upcase %>_CONF</tt> env variable.
37
- (Its format is exactly similar to CL options.)
35
+ From the least significant to the most:
38
36
 
39
- 2. At the configuration file. Its default name is
40
- <tt><%= @project %>.yaml</tt> and it can be stored in several
41
- system directories which are observable by <tt>--config--dirs</tt> CL
42
- option.
37
+ 1. <tt><%= @project.upcase %>_CONF</tt> env variable.
38
+ (Its format is exactly similar to CL options.)
43
39
 
44
- 3. At command line.
40
+ 2. Configuration file. Its default name is <tt><%= @project %>.yaml</tt>
41
+ and it can be stored in several directories which are observable by
42
+ <tt>--config--dirs</tt> CL option.
45
43
 
46
- Higher number levels overrides the values from lower number levels.
44
+ 3. Command line.
47
45
 
48
46
  The configuration file must be in YAML format. Look into <tt>`gem env
49
- gemdir`/gems/<%= @project %>-x.y.z/etc/</tt> directory for samples.
47
+ gemdir`/gems/<%= @project %>-x.y.z/etc/</tt> directory for examples.
50
48
 
51
49
 
52
- ==Examples
50
+ == Examples
53
51
 
54
- % ri <%= @camelcase %>
55
- % <%= @project %> --config-dirs
56
- % <%= @project %> -V
52
+ $ ri <%= @camelcase %> # after gem installation
53
+ $ <%= @project %> --config-dirs
54
+ $ <%= @project %> -V
@@ -6,13 +6,13 @@ include <%= @camelcase %>
6
6
 
7
7
  $conf = CliConfig.new
8
8
  $conf[:banner] = "Usage: #{File.basename($0)} [options] hren'"
9
- $conf[:foobar] = ''
9
+
10
10
 
11
11
  ### main
12
12
 
13
13
  $conf.load(['foobar']) {|o|
14
- o.on('--foobar STR', 'An example of the option --foobar') {|i|
15
- $conf[:foobar] = i
14
+ o.on('--foobar STR', 'An example of the --foobar option') {|i|
15
+ $conf['foobar'] = i
16
16
  }
17
17
  }
18
18
 
@@ -1,21 +1,21 @@
1
- =Name
1
+ = Name
2
2
 
3
3
  <%= target %>--[TODO: write a summary here.]
4
4
 
5
5
 
6
- ==Synopsis
6
+ == Synopsis
7
7
 
8
8
  <%= target %> [options]
9
9
 
10
10
 
11
- ==Description
11
+ == Description
12
12
 
13
13
  The <%= target %> utility [TODO: write a description here.]
14
14
 
15
15
  The options are as follows:
16
16
 
17
17
  --config-dirs:: List all possible locations for the
18
- configuration file. The first found wins.
18
+ configuration file.
19
19
 
20
20
  --config NAME:: The name of the configuration file. If
21
21
  it contains <tt>/</tt> in it, the list from
@@ -29,27 +29,25 @@ The options are as follows:
29
29
 
30
30
  --foobar NAME:: Huh?
31
31
 
32
- ==Configuration
33
32
 
34
- <%= target %> looks for its configuration at 3 places at start up.
33
+ == Configuration
35
34
 
36
- 1. At <tt><%= @project.upcase %>_CONF</tt> env variable.
37
- (Its format is exactly similar to CL options.)
35
+ From the least significant to the most:
38
36
 
39
- 2. At the configuration file. Its default name is
40
- <tt><%= @project %>.yaml</tt> and it can be stored in several
41
- system directories which are observable by <tt>--config--dirs</tt> CL
42
- option.
37
+ 1. <tt><%= @project.upcase %>_CONF</tt> env variable.
38
+ (Its format is exactly similar to CL options.)
43
39
 
44
- 3. At command line.
40
+ 2. Configuration file. Its default name is <tt><%= @project %>.yaml</tt>
41
+ and it can be stored in several directories which are observable by
42
+ <tt>--config--dirs</tt> CL option.
45
43
 
46
- Higher number levels overrides the values from lower number levels.
44
+ 3. Command line.
47
45
 
48
46
  The configuration file must be in YAML format. Look into <tt>`gem env
49
- gemdir`/gems/<%= @project %>-x.y.z/etc/</tt> directory for samples.
47
+ gemdir`/gems/<%= @project %>-x.y.z/etc/</tt> directory for examples.
50
48
 
51
49
 
52
- ==Examples
50
+ == Examples
53
51
 
54
- % <%= target %> --config-dirs
55
- % <%= target %> -V
52
+ $ <%= target %> --config-dirs
53
+ $ <%= target %> -V
@@ -1,21 +1,21 @@
1
- =Name
1
+ = Name
2
2
 
3
3
  <%= @classy %>--[TODO: write a summary here.]
4
4
 
5
5
 
6
- ==Synopsis
6
+ == Synopsis
7
7
 
8
8
  <%= @project %> [options]
9
9
 
10
10
 
11
- ==Description
11
+ == Description
12
12
 
13
13
  The <%= @project %> utility [TODO: write a description here.]
14
14
 
15
15
  The options are as follows:
16
16
 
17
17
  --config-dirs:: List all possible locations for the
18
- configuration file. The first found wins.
18
+ configuration file.
19
19
 
20
20
  --config NAME:: The name of the configuration file. If
21
21
  it contains <tt>/</tt> in it, the list from
@@ -29,28 +29,26 @@ The options are as follows:
29
29
 
30
30
  --foobar NAME:: Huh?
31
31
 
32
- ==Configuration
33
32
 
34
- <%= @project %> looks for its configuration at 3 places at start up.
33
+ == Configuration
35
34
 
36
- 1. At <tt><%= @project.upcase %>_CONF</tt> env variable.
37
- (Its format is exactly similar to CL options.)
35
+ From the least significant to the most:
38
36
 
39
- 2. At the configuration file. Its default name is
40
- <tt><%= @project %>.yaml</tt> and it can be stored in several
41
- system directories which are observable by <tt>--config--dirs</tt> CL
42
- option.
37
+ 1. <tt><%= @project.upcase %>_CONF</tt> env variable.
38
+ (Its format is exactly similar to CL options.)
43
39
 
44
- 3. At command line.
40
+ 2. Configuration file. Its default name is <tt><%= @project %>.yaml</tt>
41
+ and it can be stored in several directories which are observable by
42
+ <tt>--config--dirs</tt> CL option.
45
43
 
46
- Higher number levels overrides the values from lower number levels.
44
+ 3. Command line.
47
45
 
48
46
  The configuration file must be in YAML format. Look into <tt>`gem env
49
- gemdir`/gems/<%= @project %>-x.y.z/etc/</tt> directory for samples.
47
+ gemdir`/gems/<%= @project %>-x.y.z/etc/</tt> directory for examples.
50
48
 
51
49
 
52
- ==Examples
50
+ == Examples
53
51
 
54
- % ri <%= @camelcase %>
55
- % <%= @project %> --config-dirs
56
- % <%= @project %> -V
52
+ $ ri <%= @camelcase %> # after gem installation
53
+ $ <%= @project %> --config-dirs
54
+ $ <%= @project %> -V
@@ -0,0 +1,2 @@
1
+ ---
2
+ foobar: foo & bar
@@ -1,5 +1,3 @@
1
- # :erb: ruby-cli
2
-
3
1
  require 'pathname'
4
2
  require 'yaml'
5
3
  require 'optparse'
@@ -31,6 +29,7 @@ module <%= @camelcase %>
31
29
  @conf[:config_name] = Meta::NAME + '.yaml'
32
30
  @conf[:config_env] = Meta::NAME.upcase + '_CONF'
33
31
  @conf[:config_dirs] = DIR_CONFIG
32
+ @conf[:cl_parse_in_order] = false
34
33
  end
35
34
 
36
35
  # Setter for @conf
@@ -55,7 +54,7 @@ module <%= @camelcase %>
55
54
  }
56
55
  end
57
56
 
58
- CliUtils.warnx "no config file '#{@conf[:config_name]}' found" if @conf[:verbose] >= 2
57
+ CliUtils.warnx "config file '#{@conf[:config_name]}' not found" if @conf[:verbose] >= 2
59
58
  return nil
60
59
  end
61
60
 
@@ -75,15 +74,15 @@ module <%= @camelcase %>
75
74
  # Check if options in array opts are in @conf.
76
75
  def requiredOptions?(opts)
77
76
  opts.each {|idx|
78
- if !@conf.key?(idx.to_sym) || !@conf[idx.to_sym]
79
- CliUtils.errx EX_CONFIG, "option #{idx} is either nil or missing"
77
+ if !@conf.key?(idx) || !@conf[idx]
78
+ CliUtils.errx EX_CONFIG, "option '#{idx}' is either nil or missing"
80
79
  end
81
80
  }
82
81
  end
83
82
 
84
83
  # Parse CLO and env variable. If block is given it is passed with
85
84
  # OptionParser object as a parameter.
86
- def optParse
85
+ def optParse argv
87
86
  OptionParser.new do |o|
88
87
  o.on('-v', 'Be more verbose.') { |i|
89
88
  self[:verbose] += 1
@@ -118,7 +117,13 @@ module <%= @camelcase %>
118
117
  env = ENV[@conf[:config_env]].shellsplit if ENV.key?(@conf[:config_env])
119
118
 
120
119
  begin
121
- [env, ARGV].each { |i| o.parse!(i) if i }
120
+ [env, argv].each { |i|
121
+ if @conf[:cl_parse_in_order]
122
+ o.order!(i) if i
123
+ else
124
+ o.parse!(i) if i
125
+ end
126
+ }
122
127
  rescue
123
128
  CliUtils.errx EX_USAGE, $!.to_s
124
129
  end
@@ -129,13 +134,11 @@ module <%= @camelcase %>
129
134
  #
130
135
  # [reqOpts] an array of requied options
131
136
  # [&block] a optional block for OptionParser
132
- def load(reqOpts = [], &block)
133
- optParse(&block)
137
+ def load(reqOpts = [], argv = ARGV, &block)
138
+ optParse(argv, &block)
134
139
  loadFile
135
140
  requiredOptions?(reqOpts)
136
141
  end
137
142
 
138
143
  end
139
144
  end
140
-
141
- # Don't remove this: falsework/2.1.0/ruby-cli/2012-04-23T16:09:03+03:00
@@ -1,5 +1,3 @@
1
- # :erb: ruby-cli
2
-
3
1
  require 'pp'
4
2
  require 'open4'
5
3
  require 'pathname'
@@ -110,5 +108,3 @@ module <%= @camelcase %>
110
108
  end
111
109
 
112
110
  end
113
-
114
- # Don't remove this: falsework/2.1.0/ruby-cli/2012-04-23T16:09:03+03:00
@@ -1,3 +1,4 @@
1
+ # :include: ../../README.rdoc
1
2
  module <%= @camelcase %>
2
3
  module Meta # :nodoc:
3
4
  NAME = '<%= @project %>'
@@ -1,4 +1,3 @@
1
- # :erb: ruby-cli
2
1
  # Various staff for minitest. Include this file into your 'helper.rb'.
3
2
 
4
3
  require 'fileutils'
@@ -30,5 +29,3 @@ def cmd(c)
30
29
 
31
30
  File.absolute_path('../bin/' + c)
32
31
  end
33
-
34
- # Don't remove this: falsework/2.1.0/ruby-cli/2012-04-23T16:09:03+03:00
@@ -0,0 +1,10 @@
1
+ # DO NOT DELETE THIS FILE
2
+ # unless you don't want to upgrade scaffolds in the future.
3
+ ---
4
+ project:
5
+ classy: Foo Bar Pro
6
+ created: 2012-04-26T14:32:36+03:00
7
+
8
+ template:
9
+ version: 2.1.1
10
+ name: ruby-cli
@@ -0,0 +1,8 @@
1
+ ---
2
+ project:
3
+ classy: Foo Bar Pro
4
+ created: 2012-04-26T14:32:36+03:00
5
+
6
+ template:
7
+ version: 1.2.3
8
+ name: ruby-cli
@@ -0,0 +1,8 @@
1
+ ---
2
+ project:
3
+ classy: Foo Bar Pro
4
+ created: 2012-04-26T14:32:36+03:00
5
+
6
+ template:
7
+ version: 2.1.1
8
+ name: practical-english-usage
data/test/helper.rb CHANGED
@@ -1 +1,12 @@
1
1
  require_relative 'helper_cliutils'
2
+
3
+ def ClearFakeFS
4
+ return ::FakeFS unless block_given?
5
+ ::FakeFS.activate!
6
+
7
+ yield
8
+
9
+ ensure
10
+ ::FakeFS.deactivate!
11
+ ::FakeFS::FileSystem.clear
12
+ end
@@ -1,4 +1,3 @@
1
- # :erb: ruby-cli
2
1
  # Various staff for minitest. Include this file into your 'helper.rb'.
3
2
 
4
3
  require 'fileutils'
@@ -1,2 +1,2 @@
1
1
  ---
2
- :tdir: ['templates']
2
+ tdir: ['templates']
@@ -1,35 +1,25 @@
1
1
  require_relative 'helper'
2
2
 
3
- class TestExecution < MiniTest::Unit::TestCase
3
+ # Heavy & slow.
4
+ class TestCommandLine < MiniTest::Unit::TestCase
4
5
  def setup
5
6
  # this runs every time before test_*
6
7
  @cmd = cmd('falsework') # get path to the exe & cd to tests directory
7
8
  end
8
9
 
9
- def test_project_list
10
- r = CliUtils.exec "#{@cmd} list"
11
- assert_equal(0, r[0])
12
- assert_match(/ruby-cli/, r[2])
13
- end
14
-
15
- # very silly analogue of "sed -i'' -E 's/foo/bar/g' file"
16
- def sed(file, re, repl)
17
- o = File.read(file).gsub(re, repl)
18
- File.open(file, 'w+') {|fp| fp.printf(o) }
19
- end
20
-
21
10
  def test_project_ruby_cli
22
11
  rm_rf 'templates/foo'
23
- r = CliUtils.exec "#{@cmd} new templates/foo -v"
12
+ r = CliUtils.exec "#{@cmd} -v new templates/foo"
24
13
  # pp r
25
14
  assert_equal(0, r[0], r)
26
15
 
27
16
  out = r[2].split("\n")
28
17
  assert_match(/^Project path: \//, out[0])
29
- assert_equal("L: README.rdoc => doc/README.rdoc", out[-2])
18
+ assert_equal "N: .falsework", out[-2]
30
19
  assert_match(/Creating a git repository in .+... OK/, out[-1])
31
20
 
32
- tree = ["templates/foo/.git",
21
+ tree = ["templates/foo/.falsework",
22
+ "templates/foo/.git",
33
23
  "templates/foo/.gitignore",
34
24
  "templates/foo/Gemfile",
35
25
  "templates/foo/README.rdoc",
@@ -62,12 +52,15 @@ class TestExecution < MiniTest::Unit::TestCase
62
52
  # check rake
63
53
  r = CliUtils.exec "rake -T"
64
54
  assert_equal 0, r[0]
55
+
56
+ # bundler targets test
57
+ r = CliUtils.exec "rake build"
58
+ assert_equal 0, r[0]
65
59
 
66
60
  # add files
67
61
  r = CliUtils.exec "#{@cmd} exe qqq"
68
62
  assert_equal(0, r[0])
69
63
  assert_equal(true, File.executable?('bin/qqq'))
70
- assert_equal(true, File.exist?('doc/qqq.rdoc'))
71
64
  # smoke test of generated exe
72
65
  r = CliUtils.exec "bin/qqq --version"
73
66
  assert_equal 0, r[0]
@@ -79,30 +72,44 @@ class TestExecution < MiniTest::Unit::TestCase
79
72
 
80
73
  # upgrade
81
74
  r = CliUtils.exec "#{@cmd} upgrade -b"
82
- assert_equal(0, r[0])
75
+ # pp r
76
+ assert_equal 0, r[0]
83
77
  rm ['test/helper_cliutils.rb']
78
+
84
79
  r = CliUtils.exec "#{@cmd} upgrade -b"
85
- assert_equal(0, r[0])
86
- sed 'test/helper_cliutils.rb',
87
- /^(# Don't.+falsework\/)\d+\.\d+\.\d+(\/.+)$/, '\1999.999.999\2'
88
- r = CliUtils.exec "#{@cmd} upgrade -b"
89
- assert_equal(1, r[0])
90
- assert_match(/file .+ is from .+ falsework: 999.999.999/, r[1])
91
- mv('test', 'ttt')
80
+ assert_equal 0, r[0]
81
+
82
+ File.open('test/helper_cliutils.rb', 'w+') {|fp| fp.puts 'garbage' }
83
+ r = CliUtils.exec "#{@cmd} upgrade -b --save"
84
+ assert_equal 0, r[0]
85
+
86
+ mv 'test', 'ttt'
92
87
  r = CliUtils.exec "#{@cmd} upgrade -b"
93
- assert_equal(0, r[0])
88
+ assert_equal 0, r[0]
89
+
90
+ # upgrade info
91
+ r = CliUtils.exec "#{@cmd} upgrade check"
92
+ assert_equal 0, r[0]
93
+
94
+ r = CliUtils.exec "#{@cmd} upgrade list"
95
+ assert_equal 0, r[0]
96
+ assert_operator 1, :<=, r[2].split("\n").size
97
+
98
+ r = CliUtils.exec "#{@cmd} upgrade list obsolete"
99
+ assert_equal 0, r[0]
100
+ assert_operator 1, :<=, r[2].split("\n").size
94
101
  }
95
102
  end
96
103
 
97
104
  def test_project_invalid_name
98
105
  r = CliUtils.exec "#{@cmd} new 123"
99
- assert_equal(1, r[0])
106
+ assert_equal(EX_SOFTWARE, r[0])
100
107
  assert_match(/invalid project name/, r[1])
101
108
  end
102
109
 
103
110
  def test_project_c_glib
104
111
  rm_rf 'templates/c_glib'
105
- r = CliUtils.exec "#{@cmd} new templates/c-glib -t c-glib --no-git"
112
+ r = CliUtils.exec "#{@cmd} -t c-glib new templates/c-glib --no-git"
106
113
  assert_equal(0, r[0])
107
114
 
108
115
  Dir.chdir('templates/c_glib') {
@@ -110,7 +117,6 @@ class TestExecution < MiniTest::Unit::TestCase
110
117
  assert_equal(0, r[0])
111
118
  assert_equal(true, File.exist?('src/q_q_q.h'))
112
119
  assert_equal(true, File.exist?('src/q_q_q.c'))
113
- assert_equal(true, File.exist?('doc/q_q_q.1.asciidoc'))
114
120
 
115
121
  r = CliUtils.exec "#{@cmd} -t c-glib test q-q-q"
116
122
  assert_equal(0, r[0])
@@ -133,4 +139,21 @@ class TestExecution < MiniTest::Unit::TestCase
133
139
  }
134
140
  }
135
141
  end
142
+
143
+ def test_new_dir_from_config
144
+ r = CliUtils.exec "#{@cmd} --config /NO_SUCH_FILE.yaml list dirs"
145
+ assert_equal(0, r[0])
146
+ assert_equal(2, r[2].split("\n").size)
147
+
148
+ r = CliUtils.exec "#{@cmd} --config templates/config-01.yaml list dirs"
149
+ assert_equal(0, r[0])
150
+ assert_equal(3, r[2].split("\n").size)
151
+ end
152
+
153
+ def test_project_list
154
+ r = CliUtils.exec "#{@cmd} list"
155
+ assert_equal(0, r[0])
156
+ assert_match(/ruby-cli/, r[2])
157
+ end
158
+
136
159
  end