rscm 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,10 @@
1
1
  = RSCM Changelog
2
2
 
3
+ == 0.5.1
4
+ Bugfix release.
5
+
6
+ * Fixed a bug causing bad commands in conjunction with a block not to fail. They now fail correctly.
7
+
3
8
  == 0.5.0
4
9
  This release improves command line and logging, as well as improved support for slurping all historic revisions incrementally (to save memory). The latter will be improved in upcoming versions.
5
10
 
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = RSCM - Ruby Source Control Management (0.4.5)
1
+ = RSCM - Ruby Source Control Management (0.5.1)
2
2
 
3
3
  RSCM is to SCM what DBI/JDBC/ODBC are to databases - an SCM-independent API for accessing different SCMs. The high level features are roughly:
4
4
 
@@ -66,12 +66,11 @@ module RSCM
66
66
  options[:stdout] = File.expand_path(options[:stdout]) if options[:stdout]
67
67
  options[:stderr] = File.expand_path(options[:stderr]) if options[:stderr]
68
68
 
69
- commands = cmd.split("&&").collect{|c| c.strip}
70
69
  if options[:dir].nil?
71
- e(cmd, commands, options, &proc)
70
+ e(cmd, options, &proc)
72
71
  else
73
72
  Dir.chdir(options[:dir]) do
74
- e(cmd, commands, options, &proc)
73
+ e(cmd, options, &proc)
75
74
  end
76
75
  end
77
76
  end
@@ -79,7 +78,8 @@ module RSCM
79
78
 
80
79
  private
81
80
 
82
- def e(cmd, commands, options, &proc)
81
+ def full_cmd(cmd, options, &proc)
82
+ commands = cmd.split("&&").collect{|c| c.strip}
83
83
  stdout_opt = options[:stdout] ? ">> #{options[:stdout]}" : ""
84
84
  stderr_opt = options[:stderr] ? "2>> #{options[:stderr]}" : ""
85
85
  capture_info_command = (block_given? && options[:stdout])? "echo [output captured and therefore not logged] >> #{options[:stdout]} && " : ""
@@ -92,34 +92,42 @@ module RSCM
92
92
 
93
93
  stdout_prompt_command + capture_info_command + stderr_prompt_command + redirected_command
94
94
  end.join(" && ")
95
+ end
96
+ module_function :full_cmd
97
+
98
+ def verify_exit_code(cmd, full_cmd, options)
99
+ if($?.exitstatus != options[:exitstatus])
100
+ error_message = "#{options[:stderr]} doesn't exist"
101
+ if options[:stderr] && File.exist?(options[:stderr])
102
+ File.open(options[:stderr]) do |errio|
103
+ begin
104
+ errio.seek(-1200, IO::SEEK_END)
105
+ rescue Errno::EINVAL
106
+ # ignore - it just means we didn't have 400 bytes.
107
+ end
108
+ error_message = errio.read
109
+ end
110
+ end
111
+ raise ExecutionError.new(cmd, full_cmd, options[:dir] || Dir.pwd, $?.exitstatus, error_message)
112
+ end
113
+ end
114
+ module_function :verify_exit_code
115
+
116
+ def e(cmd, options, &proc)
117
+ full_cmd = full_cmd(cmd, options, &proc)
95
118
 
96
119
  options[:env].each{|k,v| ENV[k]=v}
97
120
  begin
98
121
  STDOUT.puts "#{RSCM::Platform.prompt} #{cmd}" if options[:stdout].nil?
99
122
  IO.popen(full_cmd, options[:mode]) do |io|
100
123
  if(block_given?)
101
- return(proc.call(io))
124
+ proc.call(io)
102
125
  else
103
126
  io.each_line do |line|
104
127
  STDOUT.puts line if options[:stdout].nil?
105
128
  end
106
129
  end
107
130
  end
108
-
109
- if($?.exitstatus != options[:exitstatus])
110
- error_message = "#{options[:stderr]} doesn't exist"
111
- if options[:stderr] && File.exist?(options[:stderr])
112
- File.open(options[:stderr]) do |errio|
113
- begin
114
- errio.seek(-1200, IO::SEEK_END)
115
- rescue Errno::EINVAL
116
- # ignore - it just means we didn't have 400 bytes.
117
- end
118
- error_message = errio.read
119
- end
120
- end
121
- raise ExecutionError.new(cmd, full_cmd, options[:dir] || Dir.pwd, $?.exitstatus, error_message)
122
- end
123
131
  rescue Errno::ENOENT => e
124
132
  unless options[:stderr].nil?
125
133
  File.open(options[:stderr], "a") {|io| io.write(e.message)}
@@ -128,6 +136,8 @@ module RSCM
128
136
  STDERR.puts e.backtrace.join("\n")
129
137
  end
130
138
  raise ExecutionError.new(cmd, full_cmd, options[:dir] || Dir.pwd, nil, e.message)
139
+ ensure
140
+ verify_exit_code(cmd, full_cmd, options)
131
141
  end
132
142
  end
133
143
  module_function :e
@@ -2,7 +2,7 @@ module RSCM
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
 
@@ -3,7 +3,7 @@ require 'rscm/command_line'
3
3
 
4
4
  module RSCM
5
5
 
6
- class DifftoolTest < Test::Unit::TestCase
6
+ class CommandLineTest < Test::Unit::TestCase
7
7
  def setup_dir(prefix)
8
8
  @dir = RSCM.new_temp_dir(prefix)
9
9
  @stdout = "#{@dir}/stdout"
@@ -39,5 +39,30 @@ module RSCM
39
39
  assert_equal("#{@prompt} echo hello", File.open(@stderr).read.strip)
40
40
  end
41
41
 
42
+ def test_should_raise_on_bad_command
43
+ setup_dir(method_name)
44
+ assert_raise(CommandLine::ExecutionError) do
45
+ CommandLine.execute("xaswedf", {:dir => @dir, :stdout => @stdout, :stderr => @stderr})
46
+ end
47
+ end
48
+
49
+ def test_should_raise_on_bad_command_with_block
50
+ setup_dir(method_name)
51
+ assert_raise(CommandLine::ExecutionError) do
52
+ CommandLine.execute("xaswedf", {:dir => @dir, :stdout => @stdout, :stderr => @stderr}) do |io|
53
+ io.each_line do |line|
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ def test_should_return_block_result
60
+ setup_dir(method_name)
61
+ result = CommandLine.execute("echo hello", {:dir => @dir, :stdout => @stdout, :stderr => @stderr}) do |io|
62
+ io.read
63
+ end
64
+ assert_equal "hello", result.strip
65
+ end
66
+
42
67
  end
43
68
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rscm
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.0
7
- date: 2006-05-18 00:00:00 -05:00
6
+ version: 0.5.1
7
+ date: 2006-05-19 00:00:00 -05:00
8
8
  summary: RSCM - Ruby Source Control Management
9
9
  require_paths:
10
10
  - lib
@@ -43,9 +43,9 @@ files:
43
43
  - lib/rscm/path_converter.rb
44
44
  - lib/rscm/platform.rb
45
45
  - lib/rscm/revision.rb
46
- - lib/rscm/revisions.rb
47
46
  - lib/rscm/revision_file.rb
48
47
  - lib/rscm/revision_poller.rb
48
+ - lib/rscm/revisions.rb
49
49
  - lib/rscm/scm
50
50
  - lib/rscm/tempdir.rb
51
51
  - lib/rscm/time_ext.rb
@@ -77,10 +77,10 @@ files:
77
77
  - test/rscm/mockit_test.rb
78
78
  - test/rscm/parser_test.rb
79
79
  - test/rscm/path_converter_test.rb
80
- - test/rscm/revisions_test.rb
81
80
  - test/rscm/revision_file_test.rb
82
81
  - test/rscm/revision_poller_test.rb
83
82
  - test/rscm/revision_test.rb
83
+ - test/rscm/revisions_test.rb
84
84
  - test/rscm/scm
85
85
  - test/rscm/test_helper.rb
86
86
  - test/rscm/compatibility/config.yml