Sha256: 9965cfcf40808bb7b43313f4ed64c3550ebb62d9642d490a407e6363f3722cfc

Contents?: true

Size: 1.52 KB

Versions: 34

Compression:

Stored size: 1.52 KB

Contents

require_relative '../test_helper'

module OhlohScm::Adapters
	class HglibCatFileTest < OhlohScm::Test

		def test_cat_file
			with_hglib_repository('hg') do |hg|
expected = <<-EXPECTED
/* Hello, World! */

/*
 * This file is not covered by any license, especially not
 * the GNU General Public License (GPL). Have fun!
 */

#include <stdio.h>
main()
{
	printf("Hello, World!\\n");
}
EXPECTED

				# The file was deleted in revision 468336c6671c. Check that it does not exist now, but existed in parent.
				assert_equal nil, hg.cat_file(OhlohScm::Commit.new(:token => '75532c1e1f1d'), OhlohScm::Diff.new(:path => 'helloworld.c'))
				assert_equal expected, hg.cat_file_parent(OhlohScm::Commit.new(:token => '75532c1e1f1d'), OhlohScm::Diff.new(:path => 'helloworld.c'))
				assert_equal expected, hg.cat_file(OhlohScm::Commit.new(:token => '468336c6671c'), OhlohScm::Diff.new(:path => 'helloworld.c'))
			end
		end

		# Ensure that we escape bash-significant characters like ' and & when they appear in the filename
		def test_funny_file_name_chars
			OhlohScm::ScratchDir.new do |dir|
				# Make a file with a problematic filename
				funny_name = '#|file_name` $(&\'")#'
				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 -u tester -m test`

				# Confirm that we can read the file back
				hg = HglibAdapter.new(:url => dir).normalize
				assert_equal "contents", hg.cat_file(hg.head, OhlohScm::Diff.new(:path => funny_name))
			end
		end

	end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
ohloh_scm-2.2.13 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.12 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.11 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.10 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.9 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.8 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.7 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.6 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.5 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.4 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.3 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.2 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.1 test/unit/hglib_cat_file_test.rb
ohloh_scm-2.2.0 test/unit/hglib_cat_file_test.rb