|
@@ -1,17 +1,17 @@
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
-import collections, json, textwrap
|
|
|
+import collections, json, os, textwrap
|
|
|
|
|
|
# This script generates the benchmark_config and setup_*.py files.
|
|
|
# To add new tests, modify the `configurations` and `test_urls` tables.
|
|
|
|
|
|
# Each line corresponds to a test application.
|
|
|
-# Format is: (language, orm, (os, ...), (test, ...))
|
|
|
+# Format is: (language, orm, (opsys, ...), (test, ...))
|
|
|
# See the dir_name logic below to see the directory name for each test application.
|
|
|
configurations = [
|
|
|
('Java', None, ['Linux'], ['json']),
|
|
|
- ('Scala', None, ['Linux'], ['json']),
|
|
|
('Java', 'Ebean', ['Linux'], ['db', 'query']),
|
|
|
+ ('Scala', None, ['Linux'], ['json']),
|
|
|
('Scala', 'Anorm', ['Linux', 'Windows'], ['db', 'query', 'fortune', 'update']),
|
|
|
]
|
|
|
|
|
@@ -24,24 +24,47 @@ test_urls = {
|
|
|
'update': '/update?queries=',
|
|
|
}
|
|
|
|
|
|
-tests_config_json = collections.OrderedDict()
|
|
|
+langs = {
|
|
|
+ 'Java': ['Java', 'play2-java'],
|
|
|
+ 'Scala': ['Scala', 'play2-scala']
|
|
|
+}
|
|
|
+def pathForLang(lang):
|
|
|
+ return os.path.join(frameworksPath(), *langs[lang])
|
|
|
+def frameworksPath():
|
|
|
+ 'Get the absolute path of ROOT/frameworks'
|
|
|
+ return os.path.abspath(os.path.join(__file__, '..', '..', '..'))
|
|
|
+
|
|
|
+lang_test_configs = {}
|
|
|
+for lang, _ in langs.iteritems():
|
|
|
+ lang_test_configs[lang] = collections.OrderedDict()
|
|
|
|
|
|
-for lang, orm, oses, tests in configurations:
|
|
|
+for lang, orm, opsyses, tests in configurations:
|
|
|
dir_name = 'play2-' + lang.lower() + (('-'+orm.lower()) if orm else '')
|
|
|
- print 'Generating tests for test application '+dir_name
|
|
|
setup_name = 'setup_' + lang.lower() + (('_'+orm.lower()) if orm else '')
|
|
|
- for os in oses:
|
|
|
- if len(oses) == 1:
|
|
|
+
|
|
|
+ setup_path = os.path.join(pathForLang(lang), setup_name+'.py')
|
|
|
+ print 'Generating', setup_path
|
|
|
+ with open(setup_path, 'w') as f:
|
|
|
+ f.write(textwrap.dedent("""
|
|
|
+ # This file was generated by frameworks/Java/play2-java/generate_config.py.
|
|
|
+ # Do not edit this file directly, use the script to regenerate.
|
|
|
+ from .setup_common import make_setup_for_dir
|
|
|
+
|
|
|
+ make_setup_for_dir(globals(), '"""+dir_name+"""')
|
|
|
+ """))
|
|
|
+
|
|
|
+ for opsys in opsyses:
|
|
|
+ if len(opsyses) == 1:
|
|
|
test_name = lang.lower() + (('-'+orm.lower()) if orm else '')
|
|
|
else:
|
|
|
- test_name = lang.lower() + (('-'+orm.lower()) if orm else '') + '-'+os.lower()
|
|
|
+ test_name = lang.lower() + (('-'+orm.lower()) if orm else '') + '-'+opsys.lower()
|
|
|
test_config_json = collections.OrderedDict([
|
|
|
('display_name', 'play2-'+test_name),
|
|
|
('setup_file', setup_name),
|
|
|
('framework', 'play2'),
|
|
|
('language', lang),
|
|
|
('orm', orm if orm else 'Raw'),
|
|
|
- ('os', os),
|
|
|
+ ('os', opsys),
|
|
|
('database', 'MySQL' if orm else 'None'),
|
|
|
('approach', 'Realistic'),
|
|
|
('classification', 'Fullstack'),
|
|
@@ -54,19 +77,14 @@ for lang, orm, oses, tests in configurations:
|
|
|
])
|
|
|
for test in tests:
|
|
|
test_config_json[test+'_url'] = test_urls[test]
|
|
|
- tests_config_json[test_name] = test_config_json
|
|
|
- with open(setup_name+'.py', 'w') as f:
|
|
|
- f.write(textwrap.dedent("""
|
|
|
- # This file was generated by generate_config.py.
|
|
|
- # Do not edit this file directly.
|
|
|
- from .setup_common import make_setup_for_dir
|
|
|
-
|
|
|
- make_setup_for_dir(globals(), '"""+dir_name+"""')
|
|
|
- """))
|
|
|
+ lang_test_configs[lang][test_name] = test_config_json
|
|
|
|
|
|
-with open('benchmark_config', 'w') as f:
|
|
|
- json_str = json.dumps({
|
|
|
- 'framework': 'play2',
|
|
|
- 'tests': [tests_config_json]
|
|
|
- }, indent=2)
|
|
|
- f.write(json_str)
|
|
|
+for lang, _ in langs.iteritems():
|
|
|
+ benchmark_config_path = os.path.join(pathForLang(lang), 'benchmark_config')
|
|
|
+ print 'Generating', benchmark_config_path
|
|
|
+ with open(benchmark_config_path, 'w') as f:
|
|
|
+ json_str = json.dumps({
|
|
|
+ 'framework': 'play2',
|
|
|
+ 'tests': [lang_test_configs[lang]]
|
|
|
+ }, indent=2)
|
|
|
+ f.write(json_str)
|