Skip to content

Commit 2c2ac14

Browse files
author
Peter Degen-Portnoy
committed
Fix test errors by updating SVN regex
These changes update the Ohloh SCM so that it works with Ubuntu 14 and the current versions of the SCM libraries.
1 parent 46c909d commit 2c2ac14

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

lib/scm/adapters/abstract/system.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def logger
1717
# Raises an exception if the shell returns non-zero exit code.
1818
def self.run(cmd)
1919
logger.debug { cmd }
20-
status, out, err = Shellout.new.run(cmd)
20+
status, out, err = Shellout.execute(cmd)
2121
raise RuntimeError.new("#{cmd} failed: #{out}\n#{err}") if status.exitstatus != 0
2222
out
2323
end

lib/scm/adapters/svn/cat_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def cat(path, revision)
1212
begin
1313
run "svn cat --trust-server-cert --non-interactive -r #{revision} '#{SvnAdapter.uri_encode(File.join(self.root, self.branch_name.to_s, path.to_s))}@#{revision}'"
1414
rescue
15-
raise unless $!.message =~ /svn: (File not found|.* is not a directory in filesystem)/
15+
raise unless $!.message =~ /svn:.*Could not cat all targets because some targets don't exist/
1616
end
1717
end
1818
end

lib/scm/adapters/svn/misc.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ def ls(path=nil, revision=final_token || 'HEAD')
9898
end
9999

100100
def node_kind(path=nil, revision=final_token || 'HEAD')
101-
$1 if self.info(path, revision) =~ /^Node Kind: (.+)$/
101+
$1 if self.info(path, revision) =~ /Node Kind: (\w+)\W/
102102
end
103103

104104
def is_directory?(path=nil, revision=final_token || 'HEAD')
105105
begin
106106
return node_kind(path, revision) == 'directory'
107-
rescue
108-
if $!.message =~ /svn: .* is not a directory in filesystem/ || $!.message =~ /.*Not a valid URL.*/
107+
rescue Exception
108+
if $!.message =~ /svn: E200009: Could not display info for all targets because some targets don't exist/
109109
return false
110110
else
111111
raise

lib/scm/shellout.rb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'rubygems'
22
require 'stringio'
3-
require 'open4'
3+
require 'open3'
44

55
class Shellout
66

@@ -9,17 +9,19 @@ def self.relay src, dst
99
end
1010

1111
def self.execute(cmd)
12-
outbuf = StringIO.new
13-
errbuf = StringIO.new
14-
status = Open4::popen4("sh") do | pid, stdin, stdout, stderr |
15-
stdin.puts cmd
16-
stdin.close
17-
to = Thread.new { relay stdout, outbuf }
18-
te = Thread.new { relay stderr, errbuf }
19-
to.join
20-
te.join
21-
end
22-
return status, outbuf.string, errbuf.string
12+
out = ''
13+
err = ''
14+
exit_status = nil
15+
Open3.popen3(cmd) { |stdin, stdout, stderr, wait_thread|
16+
while line = stdout.gets
17+
out << line
18+
end
19+
while line = stderr.gets
20+
err << line
21+
end
22+
exit_status = wait_thread.value
23+
}
24+
return exit_status, out, err
2325
end
2426

2527
def run(cmd)

test/unit/svn_pull_test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ def test_svnadmin_create
1414
assert svn.exist?
1515

1616
# Ensure that revision properties are settable
17-
svn.propset('foo','bar')
18-
assert_equal 'bar', svn.propget('foo')
17+
# Note that only valid properties can be set
18+
svn.propset('log','bar')
19+
assert_equal 'bar', svn.propget('log')
1920
end
2021
end
2122

0 commit comments

Comments
 (0)