3 # Helper for running hphp/test in fbconfig builds. Examples:
5 # ./convert_make_target_to_command.py SlowVM
6 # ./convert_make_target_to_command.py QuickRepoJit
7 # ./convert_make_target_to_command.py ZendJitIR
11 # SuiteName [VM|Jit|JitIR] [<blank>|Repo] [-SubSuiteName]
22 'Facebook': '../facebook/test/',
30 home
= os
.path
.dirname(os
.path
.realpath(__file__
)) + '/../..'
31 root
= home
+ '/' + os
.getenv('FBMAKE_BIN_ROOT', '_bin')
35 print "%s [Quick|Slow|Zend][<blank>|Repo][VM|Jit|JitIR][-SubSuiteName]" % sys
.argv
[0]
39 for suite
, dir in suites
.items():
40 if arg
.startswith(suite
):
41 arg
= arg
.replace(suite
, '')
44 if arg
.startswith('Repo'):
45 arg
= arg
.replace('Repo', '')
48 for mode
, vq
in modes
.items():
49 if arg
.startswith(mode
):
50 arg
= arg
.replace(mode
, '')
55 subpath
= '/' + camel_to_slash(arg
[1:])
57 raise Exception('Extra? "%s"' % arg
)
59 path
= relative_path('../test/' + dir + subpath
)
60 return [relative_path('../test/run'), path
, '-m', vq
, repo
]
62 raise Exception('Unknown mode "%s"' % arg
)
64 raise Exception('Unknown Suite "%s"' % arg
)
66 def camel_to_slash(name
):
67 s1
= re
.sub('(.)([A-Z][a-z]+)', r
'\1/\2', name
)
68 return re
.sub('([a-z0-9])([A-Z])', r
'\1/\2', s1
).lower()
70 def relative_path(path
):
71 """Given a path relative to this file, returns a path relative to cwd"""
72 to_file
= os
.path
.join(os
.path
.realpath(os
.path
.dirname(__file__
)), path
)
73 return os
.path
.relpath(to_file
)
75 print ' '.join(main())