falsework 0.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. data/{lib/falsework/templates/naive/Gemfile.erb → Gemfile} +1 -1
  2. data/Gemfile.lock +12 -0
  3. data/README.rdoc +45 -21
  4. data/Rakefile +5 -5
  5. data/bin/falsework +64 -28
  6. data/doc/NEWS.rdoc +37 -10
  7. data/doc/README.rdoc +45 -21
  8. data/doc/TODO.org +13 -0
  9. data/doc/template-tutorial.rdoc +113 -0
  10. data/etc/falsework.yaml +1 -1
  11. data/lib/falsework/meta.rb +3 -2
  12. data/lib/falsework/mould.rb +267 -146
  13. data/lib/falsework/templates/c-glib/#config.yaml +18 -0
  14. data/lib/falsework/templates/c-glib/README +24 -0
  15. data/lib/falsework/templates/c-glib/doc/#doc.ascii +46 -0
  16. data/lib/falsework/templates/c-glib/doc/%%@project%%.1.asciidoc +46 -0
  17. data/lib/falsework/templates/{naive/doc/LICENSE.erb → c-glib/doc/LICENSE} +1 -1
  18. data/lib/falsework/templates/c-glib/doc/Makefile +17 -0
  19. data/lib/falsework/templates/c-glib/src/#exe.c +23 -0
  20. data/lib/falsework/templates/c-glib/src/#exe.h +8 -0
  21. data/lib/falsework/templates/c-glib/src/%%@project%%.c +23 -0
  22. data/lib/falsework/templates/c-glib/src/%%@project%%.h +26 -0
  23. data/lib/falsework/templates/c-glib/src/Makefile +28 -0
  24. data/lib/falsework/templates/c-glib/src/untest.c +9 -0
  25. data/lib/falsework/templates/c-glib/src/untest.h +14 -0
  26. data/lib/falsework/templates/c-glib/src/utils.c +232 -0
  27. data/lib/falsework/templates/c-glib/src/utils.h +45 -0
  28. data/lib/falsework/templates/c-glib/test/#test.c +48 -0
  29. data/lib/falsework/templates/c-glib/test/Makefile +78 -0
  30. data/lib/falsework/templates/c-glib/test/Makefile.test.mk +72 -0
  31. data/lib/falsework/templates/c-glib/test/mycat.c +8 -0
  32. data/{test/templates/.keep_me → lib/falsework/templates/c-glib/test/semis/text/empty.txt} +0 -0
  33. data/lib/falsework/templates/c-glib/test/test_utils.c +134 -0
  34. data/lib/falsework/templates/ruby-naive/#config.yaml +15 -0
  35. data/lib/falsework/templates/{naive/.gitignore.erb → ruby-naive/.gitignore.#erb} +0 -0
  36. data/lib/falsework/templates/ruby-naive/Gemfile +4 -0
  37. data/lib/falsework/templates/{naive/doc/README.rdoc.erb → ruby-naive/README.rdoc} +2 -2
  38. data/lib/falsework/templates/{naive/Rakefile.erb → ruby-naive/Rakefile} +1 -1
  39. data/lib/falsework/templates/{naive/bin/%%@project%%.erb → ruby-naive/bin/%%@project%%} +5 -5
  40. data/lib/falsework/templates/{naive/doc/#util.rdoc.erb → ruby-naive/doc/#doc.rdoc} +6 -6
  41. data/lib/falsework/templates/ruby-naive/doc/LICENSE +22 -0
  42. data/lib/falsework/templates/{naive/doc/NEWS.rdoc.erb → ruby-naive/doc/NEWS.rdoc} +0 -0
  43. data/lib/falsework/templates/{naive/README.rdoc.erb → ruby-naive/doc/README.rdoc} +2 -2
  44. data/lib/falsework/templates/{naive/etc/%%@project%%.yaml.erb → ruby-naive/etc/%%@project%%.yaml} +0 -0
  45. data/lib/falsework/templates/{naive/lib/%%@project%%/meta.rb.erb → ruby-naive/lib/%%@project%%/meta.rb} +3 -2
  46. data/lib/falsework/templates/{naive/lib/%%@project%%/trestle.rb.erb → ruby-naive/lib/%%@project%%/trestle.rb} +22 -14
  47. data/lib/falsework/templates/{naive/test/helper.rb.erb → ruby-naive/test/helper.rb} +0 -0
  48. data/lib/falsework/templates/{naive/test/helper_trestle.rb.erb → ruby-naive/test/helper_trestle.rb} +2 -2
  49. data/lib/falsework/templates/{naive/test/rake_git.rb.erb → ruby-naive/test/rake_git.rb} +1 -1
  50. data/lib/falsework/templates/{naive/test/test_%%@project%%.rb.erb → ruby-naive/test/test_%%@project%%.rb} +1 -1
  51. data/lib/falsework/trestle.rb +17 -9
  52. data/test/rake_erb_templates.rb +4 -4
  53. data/test/templates/config-01.yaml +2 -0
  54. data/test/test_cl.rb +29 -0
  55. data/test/test_exe.rb +61 -30
  56. data/test/test_mould.rb +80 -0
  57. metadata +86 -60
  58. data/doc/TODO.rdoc +0 -7
@@ -3,10 +3,10 @@
3
3
 
4
4
  require_relative '../lib/<%= @project %>/trestle.rb'
5
5
 
6
- include <%= @project.capitalize %>
6
+ include <%= @camelcase %>
7
7
 
8
8
  $conf = Hash.new
9
- u = Trestle.new($conf)
9
+ $t = Trestle.new($conf)
10
10
 
11
11
  $conf[:banner] = "Usage: #{File.basename($0)} [options] hren'"
12
12
  $conf[:foobar] = ''
@@ -14,12 +14,12 @@ $conf[:foobar] = ''
14
14
 
15
15
  # --[ main ]------------------------------------------------------------
16
16
 
17
- u.config_parse(['foobar']) {|src|
18
- o = u.cl_parse(src) # create an OptionParser object
17
+ $t.config_parse(['foobar']) {|src|
18
+ o = $t.cl_parse(src) # create an OptionParser object
19
19
  o.on('--foobar STR', 'An example of the option --foobar') {|i|
20
20
  $conf[:foobar] = i
21
21
  }
22
- u.cl_parse(src, o) # run cl parser
22
+ $t.cl_parse(src, o) # run cl parser
23
23
  }
24
24
 
25
25
  # print our env
@@ -1,16 +1,16 @@
1
1
  =Name
2
2
 
3
- <%= what %>--[TODO: write a summary here.]
3
+ <%= target %>--[TODO: write a summary here.]
4
4
 
5
5
 
6
6
  ==Synopsis
7
7
 
8
- <%= what %> [options]
8
+ <%= target %> [options]
9
9
 
10
10
 
11
11
  ==Description
12
12
 
13
- The <%= what %> utility [TODO: write a description here.]
13
+ The <%= target %> utility [TODO: write a description here.]
14
14
 
15
15
  The options are as follows:
16
16
 
@@ -31,7 +31,7 @@ The options are as follows:
31
31
 
32
32
  ==Configuration
33
33
 
34
- <%= what %> looks for its configuration at 3 places at start up.
34
+ <%= target %> looks for its configuration at 3 places at start up.
35
35
 
36
36
  1. At <tt><%= @project.upcase %>_CONF</tt> env variable.
37
37
  (Its format is exactly similar to CL options.)
@@ -51,5 +51,5 @@ gemdir`/gems/<%= @project %>-x.y.z/etc/</tt> directory for samples.
51
51
 
52
52
  ==Examples
53
53
 
54
- % <%= what %> --config-dirs
55
- % <%= what %> -V
54
+ % <%= target %> --config-dirs
55
+ % <%= target %> -V
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) <%= DateTime.now.year %> <%= @gecos %>.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  =Name
2
2
 
3
- <%= @project %>-- [TODO: write a summary here.]
3
+ <%= @classy %>--[TODO: write a summary here.]
4
4
 
5
5
 
6
6
  ==Synopsis
@@ -51,6 +51,6 @@ gemdir`/gems/<%= @project %>-x.y.z/etc/</tt> directory for samples.
51
51
 
52
52
  ==Examples
53
53
 
54
- % ri <%= @project.capitalize %>
54
+ % ri <%= @camelcase %>
55
55
  % <%= @project %> --config-dirs
56
56
  % <%= @project %> -V
@@ -1,5 +1,6 @@
1
- module <%= @project.capitalize %>
2
- module Meta
1
+ # :include: ../../README.rdoc
2
+ module <%= @camelcase %>
3
+ module Meta # :nodoc:
3
4
  NAME = '<%= @project %>'
4
5
  VERSION = '0.0.1'
5
6
  AUTHOR = '<%= @gecos %>'
@@ -7,9 +7,8 @@ require 'open4'
7
7
 
8
8
  require_relative 'meta'
9
9
 
10
- # :include: ../../README.rdoc
11
- module <%= @project.capitalize %>
12
-
10
+ module <%= @camelcase %>
11
+ # A common routines from <%= @project %> with love.
13
12
  class Trestle
14
13
 
15
14
  # Execute _cmd_ and return a list [exit_status, stderr,
@@ -25,9 +24,9 @@ module <%= @project.capitalize %>
25
24
 
26
25
  # Return a directory with program libraries.
27
26
  def self.gem_libdir
28
- t = ["#{File.dirname(File.realpath($0))}/../lib/#{<%= @project.capitalize %>::Meta::NAME}",
29
- "#{Gem.dir}/gems/#{<%= @project.capitalize %>::Meta::NAME}-#{<%= @project.capitalize %>::Meta::VERSION}/lib/#{<%= @project.capitalize %>::Meta::NAME}",
30
- "lib/#{<%= @project.capitalize %>::Meta::NAME}"]
27
+ t = ["#{File.dirname(File.realpath($0))}/../lib/#{<%= @camelcase %>::Meta::NAME}",
28
+ "#{Gem.dir}/gems/#{<%= @camelcase %>::Meta::NAME}-#{<%= @camelcase %>::Meta::VERSION}/lib/#{<%= @camelcase %>::Meta::NAME}",
29
+ "lib/#{<%= @camelcase %>::Meta::NAME}"]
31
30
  t.each {|i| return i if File.readable?(i) }
32
31
  fail "all paths are invalid: #{t}"
33
32
  end
@@ -127,9 +126,9 @@ module <%= @project.capitalize %>
127
126
  # puts "\n2 run"
128
127
  r = config_flat_load(rvars)
129
128
  rescue
130
- Trestle.errx(1, "cannot load config: #{$!}")
129
+ Trestle.errx(1, "cannot load config: #{Trestle.get_backtrace}")
131
130
  end
132
- veputs(1, "Loaded config: #{r}")
131
+ veputs(1, "OK") if r
133
132
  cb.call(block_given?, ARGV)
134
133
  end
135
134
 
@@ -141,7 +140,8 @@ module <%= @project.capitalize %>
141
140
  # Return a loaded filename or nil on error.
142
141
  def config_flat_load(rvars)
143
142
  p = ->(f) {
144
- if File.readable?(f)
143
+ veputs(1, "Loading #{f}... " + NNL_MARK)
144
+ if File.file?(f)
145
145
  begin
146
146
  myconf = YAML.load_file(f)
147
147
  rescue
@@ -153,11 +153,13 @@ module <%= @project.capitalize %>
153
153
  @conf.merge!(myconf)
154
154
  return @conf[:config]
155
155
  end
156
+
157
+ veputs(1, "FAILED")
156
158
  return nil
157
159
  }
158
160
 
159
161
  if @conf[:config].index('/')
160
- return p.call(@config[:config])
162
+ return p.call(@conf[:config])
161
163
  else
162
164
  @conf[:config_dirs].each {|dir|
163
165
  return dir+'/'+@conf[:config] if p.call(dir + '/' + @conf[:config])
@@ -192,9 +194,15 @@ module <%= @project.capitalize %>
192
194
  @conf[:config] = i
193
195
  }
194
196
  o.on('--config-dirs', 'Show possible config locations.') {
195
- @conf[:config_dirs].each { |j|
196
- f = j + '/' + @conf[:config]
197
- puts((File.readable?(f) ? '* ' : ' ') + f)
197
+ mark = false
198
+ @conf[:config_dirs].each { |idx|
199
+ f = idx + '/' + @conf[:config]
200
+ if File.readable?(f) && !mark
201
+ puts "* " + f
202
+ mark = true
203
+ else
204
+ puts " " + f
205
+ end
198
206
  }
199
207
  exit 0
200
208
  }
@@ -219,4 +227,4 @@ module <%= @project.capitalize %>
219
227
  end # trestle
220
228
  end
221
229
 
222
- # Don't remove this: falsework/0.2.8/naive/2011-08-05T17:12:36+03:00
230
+ # Don't remove this: falsework/1.3.0/ruby-naive/2012-01-27T02:39:48+02:00
@@ -5,7 +5,7 @@ require 'fileutils'
5
5
  include FileUtils
6
6
 
7
7
  require_relative '../lib/<%= @project %>/trestle'
8
- include <%= @project.capitalize %>
8
+ include <%= @camelcase %>
9
9
 
10
10
  require 'minitest/autorun'
11
11
 
@@ -31,4 +31,4 @@ def cmd(c)
31
31
  File.absolute_path('../bin/' + c)
32
32
  end
33
33
 
34
- # Don't remove this: falsework/0.2.8/naive/2011-08-05T17:12:36+03:00
34
+ # Don't remove this: falsework/1.3.0/ruby-naive/2012-01-27T02:39:48+02:00
@@ -33,4 +33,4 @@ end
33
33
 
34
34
  pp git_ls('.') if __FILE__ == $0
35
35
 
36
- # Don't remove this: falsework/0.2.8/naive/2011-08-05T17:12:36+03:00
36
+ # Don't remove this: falsework/1.3.0/ruby-naive/2012-01-27T02:39:48+02:00
@@ -1,6 +1,6 @@
1
1
  require_relative 'helper'
2
2
 
3
- class Test<%= @project.capitalize %>_<%= rand 2**32 %> < MiniTest::Unit::TestCase
3
+ class Test<%= @camelcase %>_<%= rand 2**32 %> < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  # this runs every time before test_*
6
6
  @cmd = cmd('<%= @project %>') # get path to the exe & cd to tests directory
@@ -7,9 +7,8 @@ require 'open4'
7
7
 
8
8
  require_relative 'meta'
9
9
 
10
- # :include: ../../README.rdoc
11
10
  module Falsework
12
-
11
+ # A common routines from falsework with love.
13
12
  class Trestle
14
13
 
15
14
  # Execute _cmd_ and return a list [exit_status, stderr,
@@ -127,9 +126,9 @@ module Falsework
127
126
  # puts "\n2 run"
128
127
  r = config_flat_load(rvars)
129
128
  rescue
130
- Trestle.errx(1, "cannot load config: #{$!}")
129
+ Trestle.errx(1, "cannot load config: #{Trestle.get_backtrace}")
131
130
  end
132
- veputs(1, "Loaded config: #{r}")
131
+ veputs(1, "OK") if r
133
132
  cb.call(block_given?, ARGV)
134
133
  end
135
134
 
@@ -141,7 +140,8 @@ module Falsework
141
140
  # Return a loaded filename or nil on error.
142
141
  def config_flat_load(rvars)
143
142
  p = ->(f) {
144
- if File.readable?(f)
143
+ veputs(1, "Loading #{f}... " + NNL_MARK)
144
+ if File.file?(f)
145
145
  begin
146
146
  myconf = YAML.load_file(f)
147
147
  rescue
@@ -153,11 +153,13 @@ module Falsework
153
153
  @conf.merge!(myconf)
154
154
  return @conf[:config]
155
155
  end
156
+
157
+ veputs(1, "FAILED")
156
158
  return nil
157
159
  }
158
160
 
159
161
  if @conf[:config].index('/')
160
- return p.call(@config[:config])
162
+ return p.call(@conf[:config])
161
163
  else
162
164
  @conf[:config_dirs].each {|dir|
163
165
  return dir+'/'+@conf[:config] if p.call(dir + '/' + @conf[:config])
@@ -192,9 +194,15 @@ module Falsework
192
194
  @conf[:config] = i
193
195
  }
194
196
  o.on('--config-dirs', 'Show possible config locations.') {
195
- @conf[:config_dirs].each { |j|
196
- f = j + '/' + @conf[:config]
197
- puts((File.readable?(f) ? '* ' : ' ') + f)
197
+ mark = false
198
+ @conf[:config_dirs].each { |idx|
199
+ f = idx + '/' + @conf[:config]
200
+ if File.readable?(f) && !mark
201
+ puts "* " + f
202
+ mark = true
203
+ else
204
+ puts " " + f
205
+ end
198
206
  }
199
207
  exit 0
200
208
  }
@@ -31,7 +31,7 @@ def erb_skeletons(local_prj, template)
31
31
  # puts line
32
32
  if line =~ /^..? :erb:/
33
33
  t = i.sub(/^.+?\//, '')
34
- r[target + '/' + t.sub(/#{local_prj}/, '%%@project%%') + '.erb'] = t
34
+ r[target + '/' + t.sub(/#{local_prj}/, '%%@project%%')] = t
35
35
  break
36
36
  end
37
37
  n += 1
@@ -45,11 +45,11 @@ end
45
45
  def erb_make(local_prj, template, target, tmplt)
46
46
  raw = File.read(tmplt)
47
47
  raw.gsub!(/#{local_prj}/, '<%= @project %>')
48
- raw.gsub!(/#{local_prj.capitalize}/, '<%= @project.capitalize %>')
48
+ raw.gsub!(/#{Mould.name_camelcase(local_prj)}/, '<%= @camelcase %>')
49
49
 
50
50
  mark = <<-EOF
51
51
 
52
- # Don't remove this: <%= #{local_prj.capitalize}::Meta::NAME %>/<%= #{local_prj.capitalize}::Meta::VERSION %>/#{template}/<%= DateTime.now %>
52
+ # Don't remove this: <%= #{Mould.name_camelcase(local_prj)}::Meta::NAME %>/<%= #{local_prj.capitalize}::Meta::VERSION %>/#{template}/<%= DateTime.now %>
53
53
  EOF
54
54
  File.open(target, 'w+') {
55
55
  |fp| fp.puts raw + ERB.new(mark).result(binding)
@@ -57,4 +57,4 @@ def erb_make(local_prj, template, target, tmplt)
57
57
  end
58
58
 
59
59
 
60
- pp erb_skeletons(Falsework::Meta::NAME, 'naive') if __FILE__ == $0
60
+ pp erb_skeletons(Falsework::Meta::NAME, 'ruby-naive') if __FILE__ == $0
@@ -0,0 +1,2 @@
1
+ ---
2
+ :tdir: ['templates']
data/test/test_cl.rb ADDED
@@ -0,0 +1,29 @@
1
+ require_relative 'helper'
2
+ require_relative '../lib/falsework/mould'
3
+
4
+ class TestFalsework_3867654745 < MiniTest::Unit::TestCase
5
+ def setup
6
+ # this runs every time before test_*
7
+ @cmd = cmd('falsework') # get path to the exe & cd to tests directory
8
+ end
9
+
10
+ def test_listdirs
11
+ assert_equal 2, Mould.class_variable_get(:@@template_dirs).size
12
+ out, err = capture_io { Mould.template_dirs_add ["DOESN'T EXISI"] }
13
+ assert_equal 2, Mould.class_variable_get(:@@template_dirs).size
14
+ Mould.template_dirs_add [Dir.pwd]
15
+ assert_equal 3, Mould.class_variable_get(:@@template_dirs).size
16
+
17
+ assert_equal true, Mould.templates.key?("templates")
18
+ end
19
+
20
+ def test_new_dir_from_config
21
+ r = Trestle.cmd_run "#{@cmd} --config /NO_SUCH_FILE.yaml listdirs"
22
+ assert_equal(0, r[0])
23
+ assert_equal(2, r[2].split("\n").size)
24
+
25
+ r = Trestle.cmd_run "#{@cmd} --config templates/config-01.yaml listdirs"
26
+ assert_equal(0, r[0])
27
+ assert_equal(3, r[2].split("\n").size)
28
+ end
29
+ end
data/test/test_exe.rb CHANGED
@@ -9,7 +9,7 @@ class TestFalsework < MiniTest::Unit::TestCase
9
9
  def test_project_list
10
10
  r = Trestle.cmd_run "#{@cmd} list"
11
11
  assert_equal(0, r[0])
12
- assert_match(/naive\n/, r[2])
12
+ assert_match(/ruby-naive/, r[2])
13
13
  end
14
14
 
15
15
  # very silly analogue of "sed -i'' -E 's/foo/bar/g' file"
@@ -18,7 +18,7 @@ class TestFalsework < MiniTest::Unit::TestCase
18
18
  File.open(file, 'w+') {|fp| fp.printf(o) }
19
19
  end
20
20
 
21
- def test_project_new
21
+ def test_project_ruby_naive
22
22
  rm_rf 'templates/foo'
23
23
  r = Trestle.cmd_run "#{@cmd} new templates/foo -v"
24
24
  # pp r
@@ -57,40 +57,71 @@ class TestFalsework < MiniTest::Unit::TestCase
57
57
  i.match(/\.\.?$/) || i.match(/\.git[^i]/)
58
58
  })
59
59
 
60
- # add files
61
- origdir = pwd
62
- cd 'templates/foo'
60
+ Dir.chdir('templates/foo') {
61
+ # add files
62
+ r = Trestle.cmd_run "#{@cmd} exe qqq"
63
+ assert_equal(0, r[0])
64
+ assert_equal(true, File.executable?('bin/qqq'))
65
+ assert_equal(true, File.exist?('doc/qqq.rdoc'))
63
66
 
64
- r = Trestle.cmd_run "#{@cmd} exe qqq"
65
- assert_equal(0, r[0])
66
- assert_equal(true, File.executable?('bin/qqq'))
67
- assert_equal(true, File.exist?('doc/qqq.rdoc'))
68
-
69
- r = Trestle.cmd_run "#{@cmd} test qqq"
70
- assert_equal(0, r[0])
71
- assert_equal(true, File.exist?('test/test_qqq.rb'))
67
+ r = Trestle.cmd_run "#{@cmd} test qqq"
68
+ assert_equal(0, r[0])
69
+ assert_equal(true, File.exist?('test/test_qqq.rb'))
72
70
 
73
- # upgrade
74
- r = Trestle.cmd_run "#{@cmd} upgrade -b"
75
- assert_equal(0, r[0])
76
- rm ['test/helper_trestle.rb', 'test/rake_git.rb']
77
- r = Trestle.cmd_run "#{@cmd} upgrade -b"
78
- assert_equal(0, r[0])
79
- sed 'test/helper_trestle.rb',
80
- /^(# Don't.+falsework\/)\d+\.\d+\.\d+(\/.+)$/, '\1999.999.999\2'
81
- r = Trestle.cmd_run "#{@cmd} upgrade -b"
82
- assert_equal(1, r[0])
83
- assert_match(/file .+ is from .+ falsework: 999.999.999/, r[1])
84
- mv('test', 'ttt')
85
- r = Trestle.cmd_run "#{@cmd} upgrade -b"
86
- assert_equal(0, r[0])
87
-
88
- cd origdir
71
+ # upgrade
72
+ r = Trestle.cmd_run "#{@cmd} upgrade -b"
73
+ assert_equal(0, r[0])
74
+ rm ['test/helper_trestle.rb', 'test/rake_git.rb']
75
+ r = Trestle.cmd_run "#{@cmd} upgrade -b"
76
+ assert_equal(0, r[0])
77
+ sed 'test/helper_trestle.rb',
78
+ /^(# Don't.+falsework\/)\d+\.\d+\.\d+(\/.+)$/, '\1999.999.999\2'
79
+ r = Trestle.cmd_run "#{@cmd} upgrade -b"
80
+ assert_equal(1, r[0])
81
+ assert_match(/file .+ is from .+ falsework: 999.999.999/, r[1])
82
+ mv('test', 'ttt')
83
+ r = Trestle.cmd_run "#{@cmd} upgrade -b"
84
+ assert_equal(0, r[0])
85
+ }
89
86
  end
90
87
 
91
88
  def test_project_invalid_name
92
89
  r = Trestle.cmd_run "#{@cmd} new 123"
93
90
  assert_equal(1, r[0])
94
- assert_match(/project name cannot start with a digit/, r[1])
91
+ assert_match(/invalid project name/, r[1])
92
+ end
93
+
94
+ def test_project_c_glib
95
+ rm_rf 'templates/c_glib'
96
+ r = Trestle.cmd_run "#{@cmd} new templates/c-glib -t c-glib --no-git"
97
+ assert_equal(0, r[0])
98
+
99
+ Dir.chdir('templates/c_glib') {
100
+ r = Trestle.cmd_run "#{@cmd} -t c-glib exe q-q-q"
101
+ assert_equal(0, r[0])
102
+ assert_equal(true, File.exist?('src/q_q_q.h'))
103
+ assert_equal(true, File.exist?('src/q_q_q.c'))
104
+ assert_equal(true, File.exist?('doc/q_q_q.1.asciidoc'))
105
+
106
+ r = Trestle.cmd_run "#{@cmd} -t c-glib test q-q-q"
107
+ assert_equal(0, r[0])
108
+ assert_equal(true, File.exist?('test/test_q_q_q.c'))
109
+
110
+ Dir.chdir('src') {
111
+ r = Trestle.cmd_run "gmake"
112
+ assert_equal 0, r[0]
113
+ assert_equal true, File.executable?('c_glib')
114
+ assert_equal(true, File.exist?('q_q_q.o'))
115
+ }
116
+ Dir.chdir('test') {
117
+ r = Trestle.cmd_run "gmake"
118
+ assert_equal 0, r[0]
119
+ assert_equal true, File.executable?('test_utils')
120
+ assert_equal true, File.executable?('test_q_q_q')
121
+
122
+ r = Trestle.cmd_run "gmake test"
123
+ assert_equal 0, r[0]
124
+ }
125
+ }
95
126
  end
96
127
  end