svnx 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/info/tc'
5
+ require 'svnx/info/entry'
6
+
7
+ module SVNx::Info
8
+ class EntryTestCase < SVNx::Info::TestCase
9
+ def assert_info_entry_equals entry, path, kind, revision
10
+ assert_entry_equals entry, :path => path, :kind => 'file', :url => EXPROOT + '/' + path, :root => EXPROOT, :revision => revision
11
+ end
12
+
13
+ def test_entry_from_xml
14
+ xmllines = Resources::PTP_INFO_SIXTH_TXT.readlines
15
+
16
+ entry = Entry.new :xmllines => xmllines
17
+ assert_info_entry_equals entry, 'dirzero/SixthFile.txt', 'file', '22'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/log/tc'
5
+ require 'svnx/log/entries'
6
+
7
+ module SVNx::Log
8
+ class EntriesTestCase < SVNx::Log::TestCase
9
+ def assert_entry_fields_not_nil entry
10
+ # these are occasionally missing or blank, which REXML considers nil:
11
+ assert entry.message
12
+ assert entry.author
13
+ end
14
+
15
+ def assert_log_entry_16 entry
16
+ expdata = '16', 'Buddy Bizarre', '2012-09-16T14:07:30.329525Z', 'CUT! What in the hell do you think you\'re doing here? This is a closed set.'
17
+ expdata << { :kind => 'dir',
18
+ :action => 'A',
19
+ :name => '/src/java'
20
+ }
21
+ expdata << { :kind => 'file',
22
+ :action => 'A',
23
+ :name => '/src/java/Alpha.java'
24
+ }
25
+ expdata << { :kind => 'file',
26
+ :action => 'A',
27
+ :name => '/src/java/Bravo.java'
28
+ }
29
+
30
+ assert_log_entry_equals entry, expdata
31
+ end
32
+
33
+ def test_create_from_xml
34
+ # entries = Entries.new :xmllines => Resources::PT_LOG_L_15.readlines this
35
+ # is the equivalent of being at revision 19 (when this was written) and
36
+ # doing "svn log -r19:5"
37
+ entries = Entries.new :xmllines => Resources::PT_LOG_R19_5.readlines
38
+ assert_log_entry_16 entries[3]
39
+ end
40
+
41
+ def test_empty_message_element
42
+ entries = Entries.new :xmllines => Resources::PT_LOG_R19.readlines
43
+ nentries = entries.size
44
+
45
+ # empty message here:
46
+ assert_entry_fields_not_nil entries[0]
47
+ end
48
+
49
+ def test_create_on_demand
50
+ # although entries now supports xmllines as an Array, we need the size for the assertion:
51
+ xmllines = Resources::PT_LOG_R19_5.readlines
52
+
53
+ assert_equal 101, xmllines.size
54
+
55
+ entries = Entries.new :xmllines => xmllines
56
+
57
+ nentries = entries.size
58
+ assert_equal 15, nentries
59
+
60
+ # the power of Ruby, effortlessly getting instance variables ...
61
+
62
+ real_entries = entries.instance_eval '@entries'
63
+
64
+ # nothing processed yet ...
65
+ assert_nil real_entries[12]
66
+ assert_nil real_entries[13]
67
+ assert_nil real_entries[14]
68
+
69
+ assert_entry_fields_not_nil entries[13]
70
+
71
+ # and these still aren't processed:
72
+ assert_nil real_entries[12]
73
+ assert_nil real_entries[14]
74
+ end
75
+
76
+ def test_each
77
+ idx = 0
78
+
79
+ entries = Entries.new :xmllines => Resources::PT_LOG_R19_5.readlines
80
+ entries.each do |entry|
81
+ if idx == 3
82
+ assert_log_entry_16 entry
83
+ end
84
+ idx += 1
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/log/tc'
5
+ require 'svnx/log/entry'
6
+
7
+ module SVNx::Log
8
+ class EntryTestCase < SVNx::Log::TestCase
9
+ def test_entry_from_xml
10
+ doc = REXML::Document.new Resources::PT_LOG_R19_5.readlines.join('')
11
+ entry = Entry.new :xmlelement => doc.elements[1].elements[4]
12
+ assert_log_entry_16 entry
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/status/tc'
5
+ require 'svnx/status/entries'
6
+
7
+ module SVNx::Status
8
+ class EntriesTestCase < SVNx::Status::TestCase
9
+ def test_create_from_xml
10
+ entries = Entries.new :xmllines => Resources::PTP_STATUS.readlines
11
+
12
+ assert_equal 5, entries.size
13
+ assert_status_entry_equals 'modified', 'FirstFile.txt', entries[0]
14
+ assert_status_entry_equals 'unversioned', 'src/java/Charlie.java', entries[1]
15
+ assert_status_entry_equals 'added', 'src/ruby/dog.rb', entries[2]
16
+ assert_status_entry_equals 'added', 'SeventhFile.txt', entries[3]
17
+ assert_status_entry_equals 'deleted', 'dirzero/SixthFile.txt', entries[4]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/status/tc'
5
+ require 'svnx/status/entry'
6
+
7
+ module SVNx::Status
8
+ class EntryTestCase < SVNx::Status::TestCase
9
+ def test_entry_from_xml
10
+ entry = Entry.new :xmllines => Resources::PTP_STATUS_DOG_RB.readlines
11
+ assert_status_entry_equals 'added', 'src/ruby/dog.rb', entry
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'tc'
5
+ require 'system/command/tc'
6
+ require 'system/command/caching'
7
+ require 'zlib'
8
+
9
+ module System
10
+ class CacheFileTestCase < CommandTestCase
11
+ CACHE_DIR = Pathname.new '/tmp/pvn/testing'
12
+
13
+ def test_creates_gzfile
14
+ cf = CacheFile.new CACHE_DIR, [ "ls", "/var/tmp" ]
15
+ cfpn = cf.instance_eval '@pn'
16
+ cfpn.unlink if cfpn.exist?
17
+
18
+ lines = cf.readlines
19
+
20
+ cfpn = cf.instance_eval '@pn'
21
+ assert cfpn.exist?
22
+
23
+ Zlib::GzipReader.open(cfpn.to_s) do |gz|
24
+ fromgz = gz.readlines
25
+ assert_equal lines, fromgz
26
+ end
27
+ end
28
+
29
+ def test_reads_gzfile
30
+ cf = CacheFile.new CACHE_DIR, [ "ls", "-l", "/var/tmp" ]
31
+ cfpn = cf.instance_eval '@pn'
32
+ cfpn.unlink if cfpn.exist?
33
+
34
+ lines = cf.readlines
35
+
36
+ cfpn = cf.instance_eval '@pn'
37
+ assert cfpn.exist?
38
+
39
+ # same as above
40
+ cf2 = CacheFile.new CACHE_DIR, [ "ls", "-l", "/var/tmp" ]
41
+
42
+ def cf2.save_file
43
+ fail "should not have called save file for read"
44
+ end
45
+
46
+ lines2 = cf2.readlines
47
+
48
+ assert_equal lines2, lines
49
+
50
+ fromgz = read_gzfile cfpn
51
+ assert_equal lines, fromgz
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'system/command/caching'
5
+ require 'system/command/tc'
6
+
7
+ # Ruby 2 changes this to "file: Class#method", so we've got to cache it (ironic,
8
+ # no?)
9
+ $curfile = $0
10
+
11
+ module System
12
+ class CachingCommandLineTestCase < CommandTestCase
13
+ def create_ls_tmp
14
+ CachingCommandLine.new [ "ls", "/bin" ]
15
+ end
16
+
17
+ def test_ctor_no_args
18
+ cl = CachingCommandLine.new [ "ls" ]
19
+ assert_equal "ls", cl.to_command
20
+ end
21
+
22
+ def test_ctor_with_args
23
+ cl = CachingCommandLine.new [ "ls", "/bin" ]
24
+ assert_equal "ls /bin", cl.to_command
25
+ end
26
+
27
+ def test_lshift
28
+ cl = CachingCommandLine.new [ "ls" ]
29
+ cl << "/bin"
30
+ assert_equal "ls /bin", cl.to_command
31
+ end
32
+
33
+ def test_cache_dir_defaults_to_executable
34
+ cl = create_ls_tmp
35
+ assert_equal '/tmp' + (Pathname.new($curfile).expand_path).to_s, cl.cache_dir
36
+ end
37
+
38
+ def test_cache_file_defaults_to_executable
39
+ cl = create_ls_tmp
40
+ assert_equal '/tmp' + (Pathname.new($curfile).expand_path).to_s + '/ls-_slash_bin.gz', cl.cache_file.to_s
41
+ end
42
+
43
+ def test_cache_dir_set_cachefile
44
+ cl = create_ls_tmp
45
+ def cl.cache_dir; CACHE_DIR.to_s; end
46
+ assert_not_nil cl.cache_dir
47
+ assert !CACHE_DIR.exist?
48
+
49
+ cachefile = cl.cache_file
50
+ assert_equal CACHE_DIR.to_s + '/ls-_slash_bin.gz', cachefile.to_s
51
+ end
52
+
53
+ def test_cache_dir_created_on_execute
54
+ cl = create_ls_tmp
55
+ def cl.cache_dir; CACHE_DIR.to_s; end
56
+
57
+ cachefile = cl.cache_file
58
+
59
+ cl.execute
60
+ assert CACHE_DIR.exist?
61
+ cachelines = read_gzfile cachefile
62
+
63
+ syslines = nil
64
+ # we can't use /tmp, since this test will add to it:
65
+ IO.popen("ls /bin") do |io|
66
+ syslines = io.readlines
67
+ end
68
+
69
+ assert_equal syslines, cachelines
70
+ end
71
+
72
+ def test_cache_file_matches_results
73
+ dir = "/usr/local/bin"
74
+ cl = CachingCommandLine.new [ "ls", dir ]
75
+ def cl.cache_dir; CACHE_DIR.to_s; end
76
+
77
+ cachefile = cl.cache_file
78
+
79
+ cl.execute
80
+ assert CACHE_DIR.exist?
81
+
82
+ cachelines = read_gzfile cachefile
83
+
84
+ syslines = nil
85
+ IO.popen("ls #{dir}") do |io|
86
+ syslines = io.readlines
87
+ end
88
+
89
+ assert_equal syslines, cachelines
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'tc'
5
+ require 'system/command/line'
6
+
7
+ module System
8
+ class CommandLineTestCase < PVN::TestCase
9
+ def test_ctor
10
+ cl = System::CommandLine.new [ "ls" ]
11
+ assert_equal "ls", cl.to_command
12
+ end
13
+
14
+ def test_lshift
15
+ cl = System::CommandLine.new [ "ls" ]
16
+ cl << "/tmp"
17
+ assert_equal "ls /tmp", cl.to_command
18
+ end
19
+
20
+ def test_execute
21
+ cl = System::CommandLine.new [ "ls" ]
22
+ cl << "/tmp"
23
+ assert_equal "ls /tmp", cl.to_command
24
+ output = cl.execute
25
+
26
+ syslines = nil
27
+ IO.popen("ls /tmp") do |io|
28
+ syslines = io.readlines
29
+ end
30
+
31
+ assert_equal syslines, output
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: svnx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Pace
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logue
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rainbow
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.4
41
+ description: A bridge between Subversion functionality, via the command line, and
42
+ Ruby.
43
+ email: jeugenepace@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/svnx.rb
49
+ - lib/svnx/action.rb
50
+ - lib/svnx/cat/command.rb
51
+ - lib/svnx/command.rb
52
+ - lib/svnx/entries.rb
53
+ - lib/svnx/entry.rb
54
+ - lib/svnx/exec.rb
55
+ - lib/svnx/info/command.rb
56
+ - lib/svnx/info/entries.rb
57
+ - lib/svnx/info/entry.rb
58
+ - lib/svnx/log/command.rb
59
+ - lib/svnx/log/entries.rb
60
+ - lib/svnx/log/entry.rb
61
+ - lib/svnx/status/command.rb
62
+ - lib/svnx/status/entries.rb
63
+ - lib/svnx/status/entry.rb
64
+ - lib/system/command/arg.rb
65
+ - lib/system/command/cachefile.rb
66
+ - lib/system/command/caching.rb
67
+ - lib/system/command/line.rb
68
+ - test/unit/svnx/action_test.rb
69
+ - test/unit/svnx/info/entries_test.rb
70
+ - test/unit/svnx/info/entry_test.rb
71
+ - test/unit/svnx/log/entries_test.rb
72
+ - test/unit/svnx/log/entry_test.rb
73
+ - test/unit/svnx/status/entries_test.rb
74
+ - test/unit/svnx/status/entry_test.rb
75
+ - test/unit/system/command/cachefile_test.rb
76
+ - test/unit/system/command/caching_test.rb
77
+ - test/unit/system/command/line_test.rb
78
+ homepage: http://www.incava.org/projects/svnx
79
+ licenses: []
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.0.6
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Wrapper around Subversion command line.
101
+ test_files:
102
+ - test/unit/svnx/action_test.rb
103
+ - test/unit/svnx/info/entries_test.rb
104
+ - test/unit/svnx/info/entry_test.rb
105
+ - test/unit/svnx/log/entries_test.rb
106
+ - test/unit/svnx/log/entry_test.rb
107
+ - test/unit/svnx/status/entries_test.rb
108
+ - test/unit/svnx/status/entry_test.rb
109
+ - test/unit/system/command/cachefile_test.rb
110
+ - test/unit/system/command/caching_test.rb
111
+ - test/unit/system/command/line_test.rb