#NEWLINE# def test_simple( self ) : #NEWLINE# #INDENT# with environment_as ( ZINCUTILS_SORTED_ANALYSIS = '1' ) : #NEWLINE# #INDENT# def get_test_analysis_path( name ) : #NEWLINE# #INDENT# return os . path . join ( os . path . dirname ( __file__ ) , 'testdata' , 'simple' , name ) #NEWLINE# #UNINDENT# def get_analysis_text( name ) : #NEWLINE# #INDENT# with open ( get_test_analysis_path ( name ) , 'r' ) as fp : #NEWLINE# #INDENT# return fp . read ( ) #NEWLINE# #UNINDENT# #UNINDENT# def parse_analyis( name ) : #NEWLINE# #INDENT# return ZincAnalysisParser ( ) . parse_from_path ( get_test_analysis_path ( name ) ) #NEWLINE# #UNINDENT# def analysis_to_string( analysis ) : #NEWLINE# #INDENT# buf = StringIO . StringIO ( ) #NEWLINE# analysis . write ( buf ) #NEWLINE# return buf . getvalue ( ) #NEWLINE# #UNINDENT# full_analysis = parse_analyis ( 'simple.analysis' ) #NEWLINE# analysis_splits = full_analysis . split ( [ [ b'/src/pants/examples/src/scala/org/pantsbuild/example/hello/welcome/Welcome.scala' ] , [ b'/src/pants/examples/src/scala/org/pantsbuild/example/hello/exe/Exe.scala' ] ] ) #NEWLINE# self . assertEquals ( len ( analysis_splits ) , 2 ) #NEWLINE# def compare_split( i ) : #NEWLINE# #INDENT# expected_filename = 'simple_split{0}.analysis' . format ( i ) #NEWLINE# expected_analyis = parse_analyis ( expected_filename ) #NEWLINE# self . assertTrue ( expected_analyis . is_equal_to ( analysis_splits [ i ] ) ) #NEWLINE# expected = get_analysis_text ( expected_filename ) #NEWLINE# actual = analysis_to_string ( analysis_splits [ i ] ) #NEWLINE# self . assertMultiLineEqual ( expected , actual ) #NEWLINE# #UNINDENT# compare_split ( 0 ) #NEWLINE# compare_split ( 1 ) #NEWLINE# merged_analysis = ZincAnalysis . merge ( analysis_splits ) #NEWLINE# self . assertTrue ( full_analysis . is_equal_to ( merged_analysis ) ) #NEWLINE# expected = get_analysis_text ( 'simple.analysis' ) #NEWLINE# actual = analysis_to_string ( merged_analysis ) #NEWLINE# self . assertMultiLineEqual ( expected , actual ) #NEWLINE# orig = iter ( get_analysis_text ( 'simple.analysis' ) . splitlines ( True ) ) #NEWLINE# expected_rebased = get_analysis_text ( 'simple.rebased.analysis' ) #NEWLINE# buf = StringIO . StringIO ( ) #NEWLINE# ZincAnalysisParser ( ) . rebase ( orig , buf , b'/src/pants' , b'$PANTS_HOME' ) #NEWLINE# rebased = buf . getvalue ( ) #NEWLINE# self . assertMultiLineEqual ( expected_rebased , rebased ) #NEWLINE# orig = iter ( get_analysis_text ( 'simple.analysis' ) . splitlines ( True ) ) #NEWLINE# expected_filtered_rebased = get_analysis_text ( 'simple.rebased.filtered.analysis' ) #NEWLINE# buf = StringIO . StringIO ( ) #NEWLINE# ZincAnalysisParser ( ) . rebase ( orig , buf , b'/src/pants' , b'$PANTS_HOME' , b'/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk' ) #NEWLINE# filtered_rebased = buf . getvalue ( ) #NEWLINE# self . assertMultiLineEqual ( expected_filtered_rebased , filtered_rebased ) #NEWLINE# infile = iter ( get_analysis_text ( 'simple.analysis' ) . splitlines ( True ) ) #NEWLINE# deps = ZincAnalysisParser ( ) . parse_deps ( infile , '' ) #NEWLINE# f = '/src/pants/examples/src/scala/org/pantsbuild/example/hello/exe/Exe.scala' #NEWLINE# self . assertItemsEqual ( deps [ f ] , [ '/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/rt.jar' , '/src/pants/examples/src/scala/org/pantsbuild/example/hello/welcome/Welcome.scala' ] )