pvn 0.0.7 → 0.0.8

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 (111) hide show
  1. data/bin/change.rb +50 -0
  2. data/bin/pvn +8 -4
  3. data/bin/quote.rb +18 -6
  4. data/bin/quotes.orig.txt +145 -0
  5. data/bin/quotes.txt +64 -0
  6. data/lib/pvn/app/runner.rb +103 -0
  7. data/lib/pvn/app.rb +1 -142
  8. data/lib/pvn/{subcommands/base → command}/color_option.rb +1 -1
  9. data/lib/pvn/{subcommands/base → command}/command.rb +10 -6
  10. data/lib/pvn/{subcommands/base → command}/doc.rb +2 -2
  11. data/lib/pvn/{subcommands/base → command}/options.rb +2 -2
  12. data/lib/pvn/config.rb +14 -1
  13. data/lib/pvn/{subcommands/diff → diff}/command.rb +6 -6
  14. data/lib/pvn/diff/differ.rb +60 -44
  15. data/lib/pvn/diff/local_differ.rb +99 -0
  16. data/lib/pvn/diff/log_paths.rb +46 -0
  17. data/lib/pvn/{subcommands/diff → diff}/options.rb +8 -6
  18. data/lib/pvn/diff/path.rb +52 -0
  19. data/lib/pvn/diff/path_revision.rb +31 -0
  20. data/lib/pvn/diff/paths.rb +42 -0
  21. data/lib/pvn/diff/repository_differ.rb +154 -0
  22. data/lib/pvn/diff/revision.rb +36 -0
  23. data/lib/pvn/diff/status_paths.rb +87 -0
  24. data/lib/pvn/io/element.rb +29 -8
  25. data/lib/pvn/{subcommands/log → log}/command.rb +4 -4
  26. data/lib/pvn/log/formatter/log_formatter.rb +1 -1
  27. data/lib/pvn/{subcommands/log → log}/options.rb +7 -7
  28. data/lib/pvn/{subcommands/pct → pct}/command.rb +6 -6
  29. data/lib/pvn/{subcommands/pct → pct}/diffcount.rb +1 -1
  30. data/lib/pvn/{subcommands/pct → pct}/differ.rb +2 -2
  31. data/lib/pvn/{subcommands/pct → pct}/local_differ.rb +3 -3
  32. data/lib/pvn/pct/options.rb +12 -0
  33. data/lib/pvn/{subcommands/pct → pct}/repository_differ.rb +5 -13
  34. data/lib/pvn/revision/{entry.rb → argument.rb} +45 -30
  35. data/lib/pvn/{subcommands/revision → revision}/base_option.rb +2 -2
  36. data/lib/pvn/revision/error.rb +11 -0
  37. data/lib/pvn/{subcommands/revision → revision}/multiple_revisions_option.rb +1 -1
  38. data/lib/pvn/revision/range.rb +49 -0
  39. data/lib/pvn/{subcommands/revision → revision}/revision_option.rb +1 -8
  40. data/lib/pvn/{subcommands/revision → revision}/revision_regexp_option.rb +2 -2
  41. data/lib/pvn/{subcommands/status → status}/command.rb +6 -6
  42. data/lib/pvn/status/formatter/status_formatter.rb +1 -1
  43. data/lib/pvn/status/options.rb +12 -0
  44. data/lib/pvn/{base/util.rb → util/array.rb} +2 -1
  45. data/lib/pvn.rb +1 -6
  46. data/lib/svnx/action.rb +52 -0
  47. data/lib/svnx/entries.rb +9 -1
  48. data/lib/svnx/log/command.rb +4 -3
  49. data/lib/svnx/status/entry.rb +30 -13
  50. data/lib/synoption/base_option.rb +10 -27
  51. data/lib/synoption/matchers.rb +22 -0
  52. data/lib/system/command/cachefile.rb +28 -14
  53. data/lib/system/command.rb +1 -1
  54. data/test/integration/pvn/diff/command_test.rb +20 -0
  55. data/test/integration/pvn/diff/local_differ_test.rb +72 -0
  56. data/test/integration/pvn/diff/log_paths_test.rb +28 -0
  57. data/test/integration/pvn/diff/repository_differ_test.rb +127 -0
  58. data/test/integration/pvn/diff/status_paths_test.rb +31 -0
  59. data/test/integration/pvn/log/command_test.rb +29 -0
  60. data/test/integration/pvn/pct/command_test.rb +30 -0
  61. data/test/integration/pvn/status/command_test.rb +26 -0
  62. data/test/unit/pvn/app_test.rb +7 -5
  63. data/test/unit/pvn/diff/path_revision_test.rb +45 -0
  64. data/test/unit/pvn/diff/path_test.rb +38 -0
  65. data/test/unit/pvn/diff/revision_test.rb +35 -0
  66. data/test/unit/pvn/io/element/log/log_test.rb +2 -2
  67. data/test/unit/pvn/log/formatter/entry_formatter_test.rb +40 -29
  68. data/test/unit/pvn/{subcommands/log → log}/options_test.rb +4 -4
  69. data/test/unit/pvn/revision/argument_test.rb +157 -0
  70. data/test/unit/pvn/{subcommands/revision → revision}/multiple_revisions_option_test.rb +10 -11
  71. data/test/unit/pvn/revision/range_test.rb +26 -0
  72. data/test/unit/pvn/{subcommands/revision → revision}/revision_option_test.rb +13 -18
  73. data/test/unit/pvn/{subcommands/revision → revision}/revision_regexp_option_test.rb +8 -10
  74. data/test/unit/svnx/action_test.rb +67 -0
  75. data/test/unit/svnx/info/entries_test.rb +10 -10
  76. data/test/unit/svnx/info/entry_test.rb +7 -10
  77. data/test/unit/svnx/log/entries_test.rb +31 -29
  78. data/test/unit/svnx/log/entry_test.rb +3 -7
  79. data/test/unit/svnx/status/entries_test.rb +7 -6
  80. data/test/unit/svnx/status/entry_test.rb +2 -23
  81. data/test/unit/system/command/cachefile_test.rb +53 -0
  82. data/test/unit/system/command/caching_test.rb +14 -23
  83. metadata +83 -64
  84. data/lib/pvn/describe.rb +0 -40
  85. data/lib/pvn/diff/diffcmd.rb +0 -49
  86. data/lib/pvn/diff/diffopts.rb +0 -58
  87. data/lib/pvn/log/logcmd.rb +0 -135
  88. data/lib/pvn/log/logentry.rb +0 -116
  89. data/lib/pvn/log/logfactory.rb +0 -101
  90. data/lib/pvn/log/logoptions.rb +0 -43
  91. data/lib/pvn/revision.rb +0 -119
  92. data/lib/pvn/subcommands/diff/differ.rb +0 -65
  93. data/lib/pvn/subcommands/diff/local_differ.rb +0 -103
  94. data/lib/pvn/subcommands/diff/repository_differ.rb +0 -145
  95. data/lib/pvn/subcommands/pct/clargs.rb +0 -33
  96. data/lib/pvn/subcommands/pct/options.rb +0 -12
  97. data/lib/pvn/subcommands/status/options.rb +0 -12
  98. data/lib/pvn/svn/command/svncmd.rb +0 -39
  99. data/lib/pvn/svn/environment.rb +0 -23
  100. data/lib/pvn/svn/svnelement.rb +0 -89
  101. data/lib/pvn/svn/svninfo.rb +0 -42
  102. data/lib/pvn/svn/svnroot.rb +0 -29
  103. data/lib/pvn/upp/uppcmd.rb +0 -112
  104. data/lib/pvn/wherecmd.rb +0 -55
  105. data/test/integration/pvn/subcommands/diff/command_test.rb +0 -153
  106. data/test/integration/pvn/subcommands/log/command_test.rb +0 -22
  107. data/test/integration/svnx/log/test.rb +0 -43
  108. data/test/unit/pvn/revision/entry_test.rb +0 -110
  109. /data/lib/pvn/{subcommands/base → command}/clargs.rb +0 -0
  110. /data/lib/pvn/{base → util}/color_formatter.rb +0 -0
  111. /data/lib/pvn/{base → util}/textlines.rb +0 -0
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'tc'
5
- require 'pvn/subcommands/revision/revision_regexp_option'
6
- require 'pvn/subcommands/revision/tc'
7
- require 'resources'
4
+ require 'pvn/revision/tc'
5
+ require 'pvn/revision/revision_regexp_option'
8
6
 
9
7
  module PVN
10
8
  class MockRevisionRegexpOption < RevisionRegexpOption
@@ -41,19 +39,19 @@ module PVN
41
39
  end
42
40
 
43
41
  def test_out_of_range
44
- assert_revision_option_raises '-164'
42
+ assert_revision_option_raises '-20'
45
43
  end
46
44
 
47
45
  def test_post_process_middling
48
- assert_post_process '1887', '-7'
46
+ assert_post_process '13', '-7'
49
47
  end
50
48
 
51
49
  def test_post_process_latest
52
- assert_post_process '1950', '-1'
50
+ assert_post_process '19', '-1'
53
51
  end
54
52
 
55
53
  def test_post_process_oldest
56
- assert_post_process '412', '-163'
54
+ assert_post_process '1', '-19'
57
55
  end
58
56
 
59
57
  def test_post_process_tagval
@@ -61,11 +59,11 @@ module PVN
61
59
  end
62
60
 
63
61
  def test_post_process_tagrange
64
- assert_post_process '7:177', '-r7:177'
62
+ assert_post_process '7:17', '-r7:17'
65
63
  end
66
64
 
67
65
  def test_post_process_absolute_middling
68
- assert_post_process '1887', '1887'
66
+ assert_post_process '11', '11'
69
67
  end
70
68
  end
71
69
  end
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'tc'
5
+ require 'svnx/action'
6
+
7
+ module SVNx
8
+ class ActionTestCase < PVN::TestCase
9
+ include Loggable
10
+
11
+ def assert_action_added exp, str
12
+ action = Action.new str
13
+ assert_equal exp, action.added?
14
+ end
15
+
16
+ def assert_action_deleted exp, str
17
+ action = Action.new str
18
+ assert_equal exp, action.deleted?
19
+ end
20
+
21
+ def assert_action_modified exp, str
22
+ action = Action.new str
23
+ assert_equal exp, action.modified?
24
+ end
25
+
26
+ def assert_action_unversioned exp, str
27
+ action = Action.new str
28
+ assert_equal exp, action.unversioned?
29
+ end
30
+
31
+ def test_added
32
+ [ 'added', 'A' ].each do |str|
33
+ assert_action_added true, str
34
+ assert_action_deleted false, str
35
+ assert_action_modified false, str
36
+ assert_action_unversioned false, str
37
+ end
38
+ end
39
+
40
+ def test_deleted
41
+ [ 'deleted', 'D' ].each do |str|
42
+ assert_action_added false, str
43
+ assert_action_deleted true, str
44
+ assert_action_modified false, str
45
+ assert_action_unversioned false, str
46
+ end
47
+ end
48
+
49
+ def test_modified
50
+ [ 'modified', 'M' ].each do |str|
51
+ assert_action_added false, str
52
+ assert_action_deleted false, str
53
+ assert_action_modified true, str
54
+ assert_action_unversioned false, str
55
+ end
56
+ end
57
+
58
+ def test_unversioned
59
+ [ 'unversioned', '?' ].each do |str|
60
+ assert_action_added false, str
61
+ assert_action_deleted false, str
62
+ assert_action_modified false, str
63
+ assert_action_unversioned true, str
64
+ end
65
+ end
66
+ end
67
+ end
@@ -5,18 +5,18 @@ require 'svnx/info/tc'
5
5
  require 'svnx/info/entries'
6
6
 
7
7
  module SVNx::Info
8
- class EntriesTestCase < SVNx::Info::TestCase
9
-
10
- def test_create_from_xml
11
- entries = Entries.new :xmllines => Resources::WIQTR_INFO_POM_XML_ADDED_FILE_TXT.readlines
12
- info "entries: #{entries}"
13
-
14
- assert_equal 2, entries.size
8
+ class EntriesTestCase < 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
15
12
 
16
- exproot = 'file:///home/jpace/Programs/Subversion/Repositories/wiquery'
13
+ def test_create_from_xml
14
+ entries = Entries.new :xmllines => Resources::PTP_INFO_SIXTH_TXT_DOG_RB_FIRST_TXT.readlines
15
+ assert_equal 3, entries.size
17
16
 
18
- assert_entry_equals entries[0], :path => 'pom.xml', :kind => 'file', :url => exproot + '/trunk/pom.xml', :root => exproot, :revision => '1950'
19
- assert_entry_equals entries[1], :path => 'AddedFile.txt', :kind => 'file', :url => exproot + '/trunk/AddedFile.txt', :root => exproot, :revision => '0'
17
+ assert_info_entry_equals entries[0], 'dirzero/SixthFile.txt', 'file', '22'
18
+ assert_info_entry_equals entries[1], 'src/ruby/dog.rb', 'file', '0'
19
+ assert_info_entry_equals entries[2], 'FirstFile.txt', 'file', '22'
20
20
  end
21
21
  end
22
22
  end
@@ -7,19 +7,16 @@ require 'svnx/info/entry'
7
7
  module SVNx::Info
8
8
  class EntryTestCase < SVNx::Info::TestCase
9
9
  include Loggable
10
+
11
+ def assert_info_entry_equals entry, path, kind, revision
12
+ assert_entry_equals entry, :path => path, :kind => 'file', :url => EXPROOT + '/' + path, :root => EXPROOT, :revision => revision
13
+ end
14
+
10
15
  def test_entry_from_xml
11
- xmllines = Resources::WIQTR_INFO_WIQUERY_CORE_POM_XML.readlines
12
-
13
- expdata = {
14
- :url => 'file:///home/jpace/Programs/Subversion/Repositories/wiquery/trunk/wiquery-core/pom.xml',
15
- :kind => 'file',
16
- :path => 'wiquery-core/pom.xml',
17
- :root => 'file:///home/jpace/Programs/Subversion/Repositories/wiquery',
18
- :revision => '1950'
19
- }
16
+ xmllines = Resources::PTP_INFO_SIXTH_TXT.readlines
20
17
 
21
18
  entry = Entry.new :xmllines => xmllines
22
- assert_entry_equals entry, expdata
19
+ assert_info_entry_equals entry, 'dirzero/SixthFile.txt', 'file', '22'
23
20
  end
24
21
  end
25
22
  end
@@ -14,72 +14,74 @@ module SVNx::Log
14
14
  assert entry.author
15
15
  end
16
16
 
17
- def assert_log_entry_1947 entry
18
- expdata = '1947', 'reiern70', '2011-11-14T12:24:45.757124Z', 'added a convenience method to set the range'
17
+ def assert_log_entry_16 entry
18
+ 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.'
19
+ expdata << { :kind => 'dir',
20
+ :action => 'A',
21
+ :name => '/src/java'
22
+ }
23
+ expdata << { :kind => 'file',
24
+ :action => 'A',
25
+ :name => '/src/java/Alpha.java'
26
+ }
19
27
  expdata << { :kind => 'file',
20
- :action => 'M',
21
- :name => '/trunk/wiquery-jquery-ui/src/test/java/org/odlabs/wiquery/ui/slider/SliderTestCase.java'
28
+ :action => 'A',
29
+ :name => '/src/java/Bravo.java'
22
30
  }
23
31
 
24
32
  assert_log_entry_equals entry, expdata
25
33
  end
26
34
 
27
35
  def test_create_from_xml
28
- entries = Entries.new :xmllines => get_test_lines_limit_15
29
- assert_log_entry_1947 entries[2]
36
+ # entries = Entries.new :xmllines => Resources::PT_LOG_L_15.readlines this
37
+ # is the equivalent of being at revision 19 (when this was written) and
38
+ # doing "svn log -r19:5"
39
+ entries = Entries.new :xmllines => Resources::PT_LOG_R19_5.readlines
40
+ assert_log_entry_16 entries[3]
30
41
  end
31
42
 
32
- def test_no_author_field
33
- entries = Entries.new :xmllines => get_test_lines_no_author
34
- nentries = entries.size
35
-
36
- # revision 1 has no author ... wtf?
37
- assert_entry_fields_not_nil entries[0]
38
- end
39
-
40
43
  def test_empty_message_element
41
- entries = Entries.new :xmllines => get_test_lines_empty_message
44
+ entries = Entries.new :xmllines => Resources::PT_LOG_R19.readlines
42
45
  nentries = entries.size
43
-
46
+
44
47
  # empty message here:
45
48
  assert_entry_fields_not_nil entries[0]
46
49
  end
47
50
 
48
51
  def test_create_on_demand
49
52
  # although entries now supports xmllines as an Array, we need the size for the assertion:
50
- xmllines = get_test_lines_no_limit.join ''
53
+ xmllines = Resources::PT_LOG_R19_5.readlines
51
54
 
52
- # quite a big file ...
53
- assert_equal 324827, xmllines.size
55
+ assert_equal 101, xmllines.size
54
56
 
55
57
  entries = Entries.new :xmllines => xmllines
56
58
 
57
59
  nentries = entries.size
58
- assert_equal 1949, nentries
60
+ assert_equal 15, nentries
59
61
 
60
62
  # the power of Ruby, effortlessly getting instance variables ...
61
63
 
62
64
  real_entries = entries.instance_eval '@entries'
63
65
 
64
66
  # nothing processed yet ...
65
- assert_nil real_entries[16]
66
- assert_nil real_entries[17]
67
- assert_nil real_entries[18]
67
+ assert_nil real_entries[12]
68
+ assert_nil real_entries[13]
69
+ assert_nil real_entries[14]
68
70
 
69
- assert_entry_fields_not_nil entries[17]
71
+ assert_entry_fields_not_nil entries[13]
70
72
 
71
73
  # and these still aren't processed:
72
- assert_nil real_entries[16]
73
- assert_nil real_entries[18]
74
+ assert_nil real_entries[12]
75
+ assert_nil real_entries[14]
74
76
  end
75
77
 
76
78
  def test_each
77
79
  idx = 0
78
80
 
79
- entries = Entries.new :xmllines => get_test_lines_limit_15
81
+ entries = Entries.new :xmllines => Resources::PT_LOG_R19_5.readlines
80
82
  entries.each do |entry|
81
- if idx == 2
82
- assert_log_entry_1947 entry
83
+ if idx == 3
84
+ assert_log_entry_16 entry
83
85
  end
84
86
  idx += 1
85
87
  end
@@ -9,13 +9,9 @@ module SVNx::Log
9
9
  include Loggable
10
10
 
11
11
  def test_entry_from_xml
12
- expdata = '1947', 'reiern70', '2011-11-14T12:24:45.757124Z', 'added a convenience method to set the range'
13
- expdata << { :kind => 'file', :action => 'M', :name => '/trunk/wiquery-jquery-ui/src/test/java/org/odlabs/wiquery/ui/slider/SliderTestCase.java' }
14
-
15
- doc = REXML::Document.new get_test_lines_limit_15.join('')
16
-
17
- entry = Entry.new :xmlelement => doc.elements[1].elements[3]
18
- assert_log_entry_equals entry, expdata
12
+ doc = REXML::Document.new Resources::PT_LOG_R19_5.readlines.join('')
13
+ entry = Entry.new :xmlelement => doc.elements[1].elements[4]
14
+ assert_log_entry_16 entry
19
15
  end
20
16
  end
21
17
  end
@@ -8,13 +8,14 @@ module SVNx::Status
8
8
  class EntriesTestCase < SVNx::Status::TestCase
9
9
 
10
10
  def test_create_from_xml
11
- entries = Entries.new :xmllines => get_test_lines_all
11
+ entries = Entries.new :xmllines => Resources::PTP_STATUS.readlines
12
12
 
13
- assert_equal 4, entries.size
14
- assert_status_entry_equals 'added', 'AddedFile.txt', entries[0]
15
- assert_status_entry_equals 'deleted', 'LICENSE', entries[1]
16
- assert_status_entry_equals 'modified', 'pom.xml', entries[2]
17
- assert_status_entry_equals 'modified', 'wiquery-core/src/main/java/org/odlabs/wiquery/core/effects/EffectBehavior.java', entries[3]
13
+ assert_equal 5, entries.size
14
+ assert_status_entry_equals 'modified', 'FirstFile.txt', entries[0]
15
+ assert_status_entry_equals 'unversioned', 'src/java/Charlie.java', entries[1]
16
+ assert_status_entry_equals 'added', 'src/ruby/dog.rb', entries[2]
17
+ assert_status_entry_equals 'added', 'SeventhFile.txt', entries[3]
18
+ assert_status_entry_equals 'deleted', 'dirzero/SixthFile.txt', entries[4]
18
19
  end
19
20
  end
20
21
  end
@@ -9,29 +9,8 @@ module SVNx::Status
9
9
  include Loggable
10
10
 
11
11
  def test_entry_from_xml
12
- xml = Array.new
13
- xml << "<?xml version=\"1.0\"?>\n"
14
- xml << "<status>\n"
15
- xml << "<target\n"
16
- xml << " path=\"LICENSE\">\n"
17
- xml << "<entry\n"
18
- xml << " path=\"LICENSE\">\n"
19
- xml << "<wc-status\n"
20
- xml << " props=\"none\"\n"
21
- xml << " item=\"deleted\"\n"
22
- xml << " revision=\"1950\">\n"
23
- xml << "<commit\n"
24
- xml << " revision=\"412\">\n"
25
- xml << "<author>lionel.armanet</author>\n"
26
- xml << "<date>2010-09-17T21:23:25.763385Z</date>\n"
27
- xml << "</commit>\n"
28
- xml << "</wc-status>\n"
29
- xml << "</entry>\n"
30
- xml << "</target>\n"
31
- xml << "</status>\n"
32
-
33
- entry = Entry.new :xmllines => xml.join('')
34
- assert_status_entry_equals 'deleted', 'LICENSE', entry
12
+ entry = Entry.new :xmllines => Resources::PTP_STATUS_DOG_RB.readlines
13
+ assert_status_entry_equals 'added', 'src/ruby/dog.rb', entry
35
14
  end
36
15
  end
37
16
  end
@@ -0,0 +1,53 @@
1
+ require 'tc'
2
+ require 'system/command/tc'
3
+ require 'system/command/caching'
4
+ require 'zlib'
5
+
6
+ module System
7
+ class CacheFileTestCase < CommandTestCase
8
+ include Loggable
9
+
10
+ CACHE_DIR = Pathname.new '/tmp/pvn/testing'
11
+
12
+ def test_creates_gzfile
13
+ cf = CacheFile.new CACHE_DIR, [ "ls", "/var/tmp" ]
14
+ cfpn = cf.instance_eval '@pn'
15
+ cfpn.unlink if cfpn.exist?
16
+
17
+ lines = cf.readlines
18
+
19
+ cfpn = cf.instance_eval '@pn'
20
+ assert cfpn.exist?
21
+
22
+ Zlib::GzipReader.open(cfpn.to_s) do |gz|
23
+ fromgz = gz.readlines
24
+ assert_equal lines, fromgz
25
+ end
26
+ end
27
+
28
+ def test_reads_gzfile
29
+ cf = CacheFile.new CACHE_DIR, [ "ls", "-l", "/var/tmp" ]
30
+ cfpn = cf.instance_eval '@pn'
31
+ cfpn.unlink if cfpn.exist?
32
+
33
+ lines = cf.readlines
34
+
35
+ cfpn = cf.instance_eval '@pn'
36
+ assert cfpn.exist?
37
+
38
+ # same as above
39
+ cf2 = CacheFile.new CACHE_DIR, [ "ls", "-l", "/var/tmp" ]
40
+
41
+ def cf2.save_file
42
+ fail "should not have called save file for read"
43
+ end
44
+
45
+ lines2 = cf2.readlines
46
+
47
+ assert_equal lines2, lines
48
+
49
+ fromgz = read_gzfile cfpn
50
+ assert_equal lines, fromgz
51
+ end
52
+ end
53
+ end
@@ -1,24 +1,13 @@
1
1
  require 'tc'
2
2
  require 'system/command/caching'
3
+ require 'system/command/tc'
3
4
 
4
5
  module System
5
- class CachingCommandLineTestCase < PVN::TestCase
6
+ class CachingCommandLineTestCase < CommandTestCase
6
7
  include Loggable
7
8
 
8
- CACHE_DIR = Pathname.new '/tmp/pvn/testing'
9
-
10
- def setup
11
- super
12
- CACHE_DIR.rmtree if CACHE_DIR.exist?
13
- end
14
-
15
- def teardown
16
- CACHE_DIR.rmtree if CACHE_DIR.exist?
17
- super
18
- end
19
-
20
9
  def create_ls_tmp
21
- CachingCommandLine.new [ "ls", "/tmp" ]
10
+ CachingCommandLine.new [ "ls", "/bin" ]
22
11
  end
23
12
 
24
13
  def test_ctor_no_args
@@ -27,14 +16,14 @@ module System
27
16
  end
28
17
 
29
18
  def test_ctor_with_args
30
- cl = CachingCommandLine.new [ "ls", "/tmp" ]
31
- assert_equal "ls /tmp", cl.to_command
19
+ cl = CachingCommandLine.new [ "ls", "/bin" ]
20
+ assert_equal "ls /bin", cl.to_command
32
21
  end
33
22
 
34
23
  def test_lshift
35
24
  cl = CachingCommandLine.new [ "ls" ]
36
- cl << "/tmp"
37
- assert_equal "ls /tmp", cl.to_command
25
+ cl << "/bin"
26
+ assert_equal "ls /bin", cl.to_command
38
27
  end
39
28
 
40
29
  def test_cache_dir_defaults_to_executable
@@ -44,7 +33,7 @@ module System
44
33
 
45
34
  def test_cache_file_defaults_to_executable
46
35
  cl = create_ls_tmp
47
- assert_equal '/tmp' + (Pathname.new($0).expand_path).to_s + '/ls-\/tmp', cl.cache_file.to_s
36
+ assert_equal '/tmp' + (Pathname.new($0).expand_path).to_s + '/ls-_slash_bin.gz', cl.cache_file.to_s
48
37
  end
49
38
 
50
39
  def test_cache_dir_set_cachefile
@@ -54,7 +43,7 @@ module System
54
43
  assert !CACHE_DIR.exist?
55
44
 
56
45
  cachefile = cl.cache_file
57
- assert_equal CACHE_DIR.to_s + '/ls-\/tmp', cachefile.to_s
46
+ assert_equal CACHE_DIR.to_s + '/ls-_slash_bin.gz', cachefile.to_s
58
47
  end
59
48
 
60
49
  def test_cache_dir_created_on_execute
@@ -65,10 +54,11 @@ module System
65
54
 
66
55
  cl.execute
67
56
  assert CACHE_DIR.exist?
68
- cachelines = IO.readlines cachefile.to_s
57
+ cachelines = read_gzfile cachefile
69
58
 
70
59
  syslines = nil
71
- IO.popen("ls /tmp") do |io|
60
+ # we can't use /tmp, since this test will add to it:
61
+ IO.popen("ls /bin") do |io|
72
62
  syslines = io.readlines
73
63
  end
74
64
 
@@ -84,7 +74,8 @@ module System
84
74
 
85
75
  cl.execute
86
76
  assert CACHE_DIR.exist?
87
- cachelines = IO.readlines cachefile.to_s
77
+
78
+ cachelines = read_gzfile cachefile
88
79
 
89
80
  syslines = nil
90
81
  IO.popen("ls #{dir}") do |io|