From 2ea0d4fc5ccf691d0656d72d1b3456dec82ede27 Mon Sep 17 00:00:00 2001 From: arun Date: Fri, 10 Jun 2016 15:29:16 +0530 Subject: [PATCH] OTWO-4267 Added dependencies configuration and resolved failing test cases --- .travis.yml | 4 ++++ lib/ohloh_scm/adapters/bzr/misc.rb | 4 +++- lib/ohloh_scm/adapters/hg/cat_file.rb | 4 +++- test/unit/cvs_commits_test.rb | 22 +++++++++++----------- test/unit/hg_cat_file_test.rb | 2 +- test/unit/hglib_cat_file_test.rb | 2 +- test/unit/shellout_test.rb | 1 + 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index eeac2080..f2f095b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,8 @@ language: ruby +before_install: + - sudo apt-get install -y cvs + - sudo ln -s /usr/bin/cvs /usr/bin/cvsnt + - sudo apt-get install -y subversion install: - gem install posix-spawn - sh .install_dependencies.sh diff --git a/lib/ohloh_scm/adapters/bzr/misc.rb b/lib/ohloh_scm/adapters/bzr/misc.rb index 12f5b9a5..3b24c5fc 100644 --- a/lib/ohloh_scm/adapters/bzr/misc.rb +++ b/lib/ohloh_scm/adapters/bzr/misc.rb @@ -10,7 +10,9 @@ def exist? end def ls_tree(token) - run("cd #{path} && bzr ls -V -r #{to_rev_param(token)}").split("\n") + run("cd #{path} && bzr ls -V -r #{to_rev_param(token)}").split("\n").map!{ |file_name| + file_name.force_encoding(Encoding::UTF_8) + } end def to_rev_param(r=nil) diff --git a/lib/ohloh_scm/adapters/hg/cat_file.rb b/lib/ohloh_scm/adapters/hg/cat_file.rb index e8caf7d6..1620d8eb 100644 --- a/lib/ohloh_scm/adapters/hg/cat_file.rb +++ b/lib/ohloh_scm/adapters/hg/cat_file.rb @@ -1,3 +1,5 @@ +require 'shellwords' + module OhlohScm::Adapters class HgAdapter < AbstractAdapter def cat_file(commit, diff) @@ -20,7 +22,7 @@ def cat(revision, path) # Example: # "Foo Bar & Baz" => "Foo\ Bar\ \&\ Baz" def escape(path) - path.gsub(/[ `'"&()<>|#\$]/) { |c| '\\' + c } + path.shellescape end end end diff --git a/test/unit/cvs_commits_test.rb b/test/unit/cvs_commits_test.rb index b2013804..575bdca4 100644 --- a/test/unit/cvs_commits_test.rb +++ b/test/unit/cvs_commits_test.rb @@ -6,19 +6,19 @@ class CvsCommitsTest < OhlohScm::Test def test_commits with_cvs_repository('cvs', 'simple') do |cvs| - assert_equal ['2006/06/29 16:21:07', - '2006/06/29 18:14:47', - '2006/06/29 18:45:29', - '2006/06/29 18:48:54', - '2006/06/29 18:52:23'], cvs.commits.collect { |c| c.token } - - assert_equal ['2006/06/29 18:48:54', - '2006/06/29 18:52:23'], - cvs.commits(:after => '2006/06/29 18:45:29').collect { |c| c.token } + assert_equal ['2006-06-29 16:21:07', + '2006-06-29 18:14:47', + '2006-06-29 18:45:29', + '2006-06-29 18:48:54', + '2006-06-29 18:52:23'], cvs.commits.collect { |c| c.token } # Make sure we are date format agnostic (2008/01/01 is the same as 2008-01-01) - assert_equal ['2006/06/29 18:48:54', - '2006/06/29 18:52:23'], + assert_equal ['2006-06-29 18:48:54', + '2006-06-29 18:52:23'], + cvs.commits(:after => '2006/06/29 18:45:29').collect { |c| c.token } + + assert_equal ['2006-06-29 18:48:54', + '2006-06-29 18:52:23'], cvs.commits(:after => '2006-06-29 18:45:29').collect { |c| c.token } assert_equal [], cvs.commits(:after => '2006/06/29 18:52:23').collect { |c| c.token } diff --git a/test/unit/hg_cat_file_test.rb b/test/unit/hg_cat_file_test.rb index efc374d6..0b36820e 100644 --- a/test/unit/hg_cat_file_test.rb +++ b/test/unit/hg_cat_file_test.rb @@ -35,7 +35,7 @@ def test_funny_file_name_chars File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } # Add it to an hg repository - `cd #{dir} && hg init && hg add * && hg commit -m test` + `cd #{dir} && hg init && hg add * && hg commit -u tester -m test` # Confirm that we can read the file back hg = HgAdapter.new(:url => dir).normalize diff --git a/test/unit/hglib_cat_file_test.rb b/test/unit/hglib_cat_file_test.rb index 19fa4f08..3b0be631 100644 --- a/test/unit/hglib_cat_file_test.rb +++ b/test/unit/hglib_cat_file_test.rb @@ -35,7 +35,7 @@ def test_funny_file_name_chars File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } # Add it to an hg repository - `cd #{dir} && hg init && hg add * && hg commit -m test` + `cd #{dir} && hg init && hg add * && hg commit -u tester -m test` # Confirm that we can read the file back hg = HglibAdapter.new(:url => dir).normalize diff --git a/test/unit/shellout_test.rb b/test/unit/shellout_test.rb index c007d9a5..108ebaf2 100644 --- a/test/unit/shellout_test.rb +++ b/test/unit/shellout_test.rb @@ -1,4 +1,5 @@ require_relative '../test_helper' +require 'timeout' class ShelloutTest < OhlohScm::Test def test_execute_must_pipe_the_results_accurately