##// END OF EJS Templates
scm: cvs: add methods of getting cvs version and add unit lib test (#4273)....
Toshi MARUYAMA -
r4712:2afc8e8c9522
parent child
Show More
@@ -33,6 +33,25 module Redmine
33 33 def sq_bin
34 34 @@sq_bin ||= shell_quote(CVS_BIN)
35 35 end
36
37 def client_version
38 @@client_version ||= (scm_command_version || [])
39 end
40
41 def client_available
42 !client_version.empty?
43 end
44
45 def scm_command_version
46 scm_version = scm_version_from_command_line
47 if m = scm_version.match(%r{\A(.*?)((\d+\.)+\d+)}m)
48 m[2].scan(%r{\d+}).collect(&:to_i)
49 end
50 end
51
52 def scm_version_from_command_line
53 shellout("#{sq_bin} --version") { |io| io.read }.to_s
54 end
36 55 end
37 56
38 57 # Guidelines for the input:
@@ -13,6 +13,15 begin
13 13 @adapter = Redmine::Scm::Adapters::CvsAdapter.new(MODULE_NAME, REPOSITORY_PATH)
14 14 end
15 15
16 def test_scm_version
17 to_test = { "\nConcurrent Versions System (CVS) 1.12.13 (client/server)\n" => [1,12,13],
18 "\r\n1.12.12\r\n1.12.11" => [1,12,12],
19 "1.12.11\r\n1.12.10\r\n" => [1,12,11]}
20 to_test.each do |s, v|
21 test_scm_version_for(s, v)
22 end
23 end
24
16 25 def test_revisions_all
17 26 cnt = 0
18 27 @adapter.revisions('', nil, nil, :with_paths => true) do |revision|
@@ -29,6 +38,13 begin
29 38 end
30 39 assert_equal 2, cnt
31 40 end
41
42 private
43
44 def test_scm_version_for(scm_command_version, version)
45 @adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version)
46 assert_equal version, @adapter.class.scm_command_version
47 end
32 48 else
33 49 puts "Cvs test repository NOT FOUND. Skipping unit tests !!!"
34 50 def test_fake; assert true end
General Comments 0
You need to be logged in to leave comments. Login now