55class TestPmdReportDocument < Test ::Unit ::TestCase
66 include PmdTester
77
8- FIRST_FILE = '/ target/repositories/spring-framework/gradle/jdiff/Null.java'
8+ FIRST_FILE = 'target/repositories/spring-framework/gradle/jdiff/Null.java'
99
1010 def test_document
1111 doc = PmdReportDocument . new ( 'base' , 'SHOULD_BE_REPLACED' )
@@ -36,7 +36,7 @@ def test_filter_set_single_rule
3636 parser . parse ( File . open ( 'test/resources/pmd_report_document/test_document.xml' ) )
3737 assert_equal ( 4 , doc . violations . total_size , 'wrong number of violations' )
3838 assert_equal ( 3 , doc . violations . num_files , 'wrong number of files' )
39- first_file = '/ target/repositories/spring-framework/spring-aop/src/main/java/' \
39+ first_file = 'target/repositories/spring-framework/spring-aop/src/main/java/' \
4040 'org/springframework/aop/ClassFilter.java'
4141 assert_equal ( 44 , doc . violations [ first_file ] [ 0 ] . line )
4242 end
@@ -50,4 +50,16 @@ def test_error_filename_without_path
5050 assert_equal ( 1 , filenames . length )
5151 assert_equal ( 'InputXpathQueryGeneratorTabWidth.java' , filenames [ 0 ] )
5252 end
53+
54+ def test_relativized_filenames
55+ doc = PmdReportDocument . new ( 'base' , '/home/runner/work/pmd' )
56+ parser = Nokogiri ::XML ::SAX ::Parser . new ( doc )
57+ parser . parse ( File . open ( 'test/resources/pmd_report_document/sample_report_relativized_paths.xml' ) )
58+
59+ assert_equal ( 2 , doc . violations . total_size , 'wrong number of violations' )
60+ assert_equal ( 1 , doc . violations . num_files , 'wrong number of files' )
61+ first_file = 'target/repositories/spring-framework/gradle/jdiff/Null.java'
62+ assert_equal ( 7 , doc . violations [ first_file ] [ 0 ] . line )
63+ assert_equal ( 8 , doc . violations [ first_file ] [ 1 ] . line )
64+ end
5365end
0 commit comments