@@ -376,6 +376,43 @@ def check_output_file(fname, str_exp):
376
376
else :
377
377
self .removeTmpDir ()
378
378
379
+ def test_config_stdin (self ):
380
+ outstring = []
381
+ instring = "CALL alien_invasion( x)"
382
+ outstring_with_config = "call alien_invasion(x)"
383
+ self .createTmpDir ()
384
+
385
+ alien_file = joinpath (TEMP_DIR , "alien_invasion.f90" )
386
+ config_file = joinpath (os .getcwd (), ".fprettify.rc" )
387
+ conf_string = "case=[1,1,1,2]\n exclude=[excluded*]"
388
+
389
+ if os .path .exists (config_file ):
390
+ raise FileException (
391
+ "remove file %s" % conf_file_cwd ) # pragma: no cover
392
+
393
+ def create_file (fname , string ):
394
+ with io .open (fname , 'w' , encoding = 'utf-8' ) as infile :
395
+ infile .write (string )
396
+
397
+ try :
398
+ create_file (alien_file , instring )
399
+ create_file (config_file , conf_string )
400
+
401
+ # testing stdin --> stdout, with configuration file read from CWD
402
+ p1 = subprocess .Popen (RUNSCRIPT ,
403
+ stdout = subprocess .PIPE , stdin = subprocess .PIPE )
404
+ outstr = p1 .communicate (instring .encode ('UTF-8' ))[0 ].decode ('UTF-8' )
405
+ self .assertEqual (outstring_with_config , outstr .strip ())
406
+
407
+ except : # pragma: no cover
408
+ self .removeTmpDir ()
409
+ if os .path .isfile (config_file ):
410
+ os .remove (config_file )
411
+ raise
412
+ else :
413
+ self .removeTmpDir ()
414
+ os .remove (config_file )
415
+
379
416
def test_config_file (self ):
380
417
"""simple test for configuration file reading"""
381
418
0 commit comments