@@ -1175,10 +1175,16 @@ Commands:
1175
1175
options .re_flags = re_flags
1176
1176
1177
1177
# Prepare: actionfiles
1178
+ if os .getenv ('ACTIONFILE_SEPARATOR' ) in (None , '' ):
1179
+ actionfile_separator = ':'
1180
+ else :
1181
+ actionfile_separator = os .getenv ('ACTIONFILE_SEPARATOR' )
1182
+
1178
1183
if options .actionfiles is not None :
1179
- options .actionfiles = options .actionfiles .split (':' )
1184
+ options .actionfiles = options .actionfiles .split (actionfile_separator )
1180
1185
elif os .getenv ('ACTIONFILES' ) not in (None , '' ):
1181
- options .actionfiles = os .getenv ('ACTIONFILES' ).split (':' )
1186
+ options .actionfiles = \
1187
+ os .getenv ('ACTIONFILES' ).split (actionfile_separator )
1182
1188
else :
1183
1189
# If there is no action file, don't proceed.
1184
1190
return options , args
@@ -1361,6 +1367,7 @@ class TestTimestat(unittest.TestCase):
1361
1367
# Empty environment variables
1362
1368
os .environ ['EDITOR' ] = ''
1363
1369
os .environ ['ACTIONFILES' ] = 'mock_actionfile_name'
1370
+ os .environ ['ACTIONFILE_SEPARATOR' ] = ''
1364
1371
1365
1372
# Mock stdout
1366
1373
self .output = ''
@@ -2908,6 +2915,45 @@ class TestTimestat(unittest.TestCase):
2908
2915
'environment variable or give --actionfiles '
2909
2916
'argument!' )
2910
2917
2918
+ def test_multiple_action_files (self ):
2919
+
2920
+ ## 1. Colon works fine on linux as a separator between action files.
2921
+
2922
+ # 1/a. Use -f to pass the action file list.
2923
+ os .environ ['ACTIONFILES' ] = ''
2924
+ options , args = parse_args (['-f' , 'first:second' ])
2925
+ self .assertEqual (options .actionfiles , ['first' , 'second' ])
2926
+
2927
+ # 1/b. Use environment variable to pass the action file list.
2928
+ os .environ ['ACTIONFILES' ] = 'first:second'
2929
+ options , args = parse_args ([])
2930
+ self .assertEqual (options .actionfiles , ['first' , 'second' ])
2931
+
2932
+ ## 2. Windows paths misbehave when the drive is specified.
2933
+
2934
+ # 2/a. Use -f to pass the action file list.
2935
+ os .environ ['ACTIONFILES' ] = ''
2936
+ options , args = parse_args (['-f' , 'C:\\ dir1;D:\\ dir2' ])
2937
+ self .assertEqual (options .actionfiles , ['C' , '\\ dir1;D' , '\\ dir2' ])
2938
+
2939
+ # 2/b. Use environment variable to pass the action file list.
2940
+ os .environ ['ACTIONFILES' ] = 'C:\\ dir1;D:\\ dir2'
2941
+ options , args = parse_args ([])
2942
+ self .assertEqual (options .actionfiles , ['C' , '\\ dir1;D' , '\\ dir2' ])
2943
+
2944
+ ## 3. So we need to use ACTIONFILE_SEPARATOR in this situation.
2945
+ os .environ ['ACTIONFILE_SEPARATOR' ] = ';'
2946
+
2947
+ # 3/a. Use -f to pass the action file list.
2948
+ os .environ ['ACTIONFILES' ] = ''
2949
+ options , args = parse_args (['-f' , 'C:\\ dir1;D:\\ dir2' ])
2950
+ self .assertEqual (options .actionfiles , ['C:\\ dir1' , 'D:\\ dir2' ])
2951
+
2952
+ # 3/b. Use environment variable to pass the action file list.
2953
+ os .environ ['ACTIONFILES' ] = 'C:\\ dir1;D:\\ dir2'
2954
+ options , args = parse_args ([])
2955
+ self .assertEqual (options .actionfiles , ['C:\\ dir1' , 'D:\\ dir2' ])
2956
+
2911
2957
def test_check_args (self ):
2912
2958
2913
2959
def ok (a , b , arg_count ):
0 commit comments