java_gen: support glob based test_data files
enables us to have more than on unit test per class.
Additional tests follow the pattern:
${class_name}__${suffix}.data
diff --git a/java_gen/java_model.py b/java_gen/java_model.py
index 9f2bdc9..feb3c72 100644
--- a/java_gen/java_model.py
+++ b/java_gen/java_model.py
@@ -1005,16 +1005,23 @@
self.java_class = java_class
first_data_file_name = "of{version}/{name}.data".format(version=java_class.version.of_version,
name=java_class.c_name[3:])
- data_file_template = "of{version}/{name}.".format(version=java_class.version.of_version,
- name=java_class.c_name[3:]) + "{i}.data"
+ glob_file_name = "of{version}/{name}__*.data".format(version=java_class.version.of_version,
+ name=java_class.c_name[3:])
test_class_name = self.java_class.name + "Test"
self.test_units = []
if test_data.exists(first_data_file_name):
self.test_units.append(JavaUnitTest(java_class, first_data_file_name, test_class_name))
+
i = 1
- while test_data.exists(data_file_template.format(i=i)):
- self.test_units.append(JavaUnitTest(java_class, data_file_template.format(i=i), test_class_name + str(i)))
- i = i + 1
+ for f in test_data.glob(glob_file_name):
+ m = re.match(".*__(.*).data", f)
+ if m:
+ suffix = java_type.name_c_to_caps_camel(m.group(1))
+ else:
+ suffix = str(i)
+ i += 1
+ test_class_name = self.java_class.name + suffix + "Test"
+ self.test_units.append(JavaUnitTest(java_class, f, test_class_name))
@property
def package(self):