@@ -2497,25 +2497,41 @@ def test_file_packager(self):
2497
2497
os .chdir ('subdir' )
2498
2498
create_file ('data2.txt' , 'data2' )
2499
2499
2500
+ def check (text ):
2501
+ self .assertGreater (len (text ), 0 )
2502
+ empty_lines = 0
2503
+ # check the generated is relatively tidy
2504
+ for line in text .splitlines ():
2505
+ if line and line [- 1 ].isspace ():
2506
+ self .fail ('output contains trailing whitespace: `%s`' % line )
2507
+
2508
+ if line .strip ():
2509
+ empty_lines = 0
2510
+ else :
2511
+ empty_lines += 1
2512
+ if empty_lines > 1 :
2513
+ self .fail ('output contains more then one empty line in row' )
2514
+
2500
2515
# relative path to below the current dir is invalid
2501
2516
stderr = self .expect_fail ([FILE_PACKAGER , 'test.data' , '--preload' , '../data1.txt' ])
2502
2517
self .assertContained ('below the current directory' , stderr )
2503
2518
2504
2519
# relative path that ends up under us is cool
2505
2520
proc = self .run_process ([FILE_PACKAGER , 'test.data' , '--preload' , '../subdir/data2.txt' ], stderr = PIPE , stdout = PIPE )
2506
- self .assertGreater (len (proc .stdout ), 0 )
2507
2521
self .assertNotContained ('below the current directory' , proc .stderr )
2522
+ check (proc .stdout )
2508
2523
2509
2524
# direct path leads to the same code being generated - relative path does not make us do anything different
2510
2525
proc2 = self .run_process ([FILE_PACKAGER , 'test.data' , '--preload' , 'data2.txt' ], stderr = PIPE , stdout = PIPE )
2511
- self . assertGreater ( len ( proc2 .stdout ), 0 )
2526
+ check ( proc2 .stdout )
2512
2527
self .assertNotContained ('below the current directory' , proc2 .stderr )
2513
2528
2514
2529
def clean (txt ):
2515
2530
lines = txt .splitlines ()
2516
2531
lines = [l for l in lines if 'PACKAGE_UUID' not in l and 'loadPackage({' not in l ]
2517
2532
return '' .join (lines )
2518
2533
2534
+
2519
2535
self .assertTextDataIdentical (clean (proc .stdout ), clean (proc2 .stdout ))
2520
2536
2521
2537
# verify '--separate-metadata' option produces separate metadata file
0 commit comments