require 'test/unit' require 'stringio' require 'fileutils' require 'rscm' module RSCM class CvsLogParserTest < Test::Unit::TestCase include FileUtils def setup @parser = CvsLogParser.new(nil) @parser.cvspath = "/scm/damagecontrol" @parser.cvsmodule = "damagecontrol" end def teardown assert(!@parser.had_error?, "parser had errors") unless @parser.nil? end def test_read_log_entry assert_equal(nil, CvsLogParser.new(StringIO.new("")).next_log_entry) end def test_parses_entire_log_into_revisions File.open(File.dirname(__FILE__) + "/cvs-test.log") do |io| @parser = CvsLogParser.new(io) revisions = @parser.parse_revisions assert_equal(24, revisions.length) assert_match(/o YAML config \(BuildBootstrapper\)/, revisions[1].message) assert_match(/failure/, revisions[8].message) end end # http://jira.codehaus.org/browse/DC-312 def test_jira_dc_312 File.open(File.dirname(__FILE__) + "/cvs-dataforge.log") do |io| @parser = CvsLogParser.new(io) revisions = @parser.parse_revisions assert_equal(271, revisions.length) end end def test_parse_files revisions = Revisions.new @parser.parse_files(LOG_ENTRY, revisions) revisions.sort! assert_equal(4, revisions.length) assert_equal("src/ruby/damagecontrol/BuildExecutorTest.rb", revisions[0][0].path) assert_match(/linux-windows galore/, revisions[1][0].message) end def test_sets_previous_native_revision_identifier_to_one_before_the_current change = @parser.parse_file(CHANGE_ENTRY) assert_equal("1.20", change.native_revision_identifier) assert_equal("1.19", change.previous_native_revision_identifier) end def test_can_determine_previous_native_revision_identifiers_from_tricky_input assert_equal("2.2.1.1", @parser.determine_previous_native_revision_identifier("2.2.1.2")) assert_equal(nil, @parser.determine_previous_native_revision_identifier("2.2.1.1")) end def test_parse_file change = @parser.parse_file(CHANGE_ENTRY) assert_equal("1.20", change.native_revision_identifier) assert_equal(Time.utc(2003,11,9,17,53,37), change.time) assert_equal("tirsen", change.developer) assert_match(/Quiet period is configurable for each project/, change.message) end def test_can_split_entries_separated_by_line_of_dashes entries = @parser.split_entries(LOG_ENTRY) assert_equal(5, entries.length) assert_equal(CHANGE_ENTRY, entries[1]) end CHANGE_ENTRY = <<-EOF revision 1.20 date: 2003/11/09 17:53:37; author: tirsen; state: Exp; lines: +3 -4 Quiet period is configurable for each project EOF LOG_ENTRY_WITH_DELETED_FILE = <