Commit 58549349 authored by Martti Käärik's avatar Martti Käärik
Browse files

Option to store converted files locally (eg in tmp\)

parent dd44abe1
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
    <stringAttribute key="bad_container_name" value="\org.etsi.mts.tdl.asn1.converter.tests\output"/>
    <booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
    <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
        <listEntry value="/org.etsi.mts.tdl.asn1.converter.tests/src/org/etsi/mts/tdl/asn1/converter/tests/ASN1ConverterParsingTest.java"/>
    </listAttribute>
    <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
        <listEntry value="1"/>
    </listAttribute>
    <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
    <booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
    <stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
    <stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit6"/>
    <booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
    <booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
    <booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
    <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
    <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.etsi.mts.tdl.asn1.converter.tests.ASN1ConverterParsingTest"/>
    <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.etsi.mts.tdl.asn1.converter.tests"/>
    <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
    <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Dasn1.test.output.dir=tmp\"/>
</launchConfiguration>
+16 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.google.inject.Inject;
 *   <li>{@code python.executable} — Python interpreter command (default: venv in converter dir, else {@code python})</li>
 *   <li>{@code asn1.test.files} — path to folder with ASN.1 input files (default: {@code src/asn1})</li>
 *   <li>{@code converter.timeout} — max seconds to wait for the converter process (default: 120)</li>
 *   <li>{@code asn1.test.output.dir} — if set, converter output is saved to this directory (default: not saved)</li>
 * </ul>
 */
@ExtendWith(InjectionExtension.class)
@@ -113,6 +114,9 @@ public class ASN1ConverterParsingTest {
		Assertions.assertFalse(tdlContent.isBlank(),
				"Converter produced empty output for " + label);

		// Step 1b: Optionally save the output
		saveOutput(label, tdlContent);

		// Step 2: Parse the TDL output
		Package result = parseHelper.parse(tdlContent);
		Assertions.assertNotNull(result,
@@ -201,6 +205,18 @@ public class ASN1ConverterParsingTest {
		}
	}

	private void saveOutput(String label, String tdlContent) throws Exception {
		String outputDir = System.getProperty("asn1.test.output.dir");
		if (outputDir == null) return;

		File dir = new File(outputDir);
		dir.mkdirs();
		String safeName = label.replaceAll("[^a-zA-Z0-9._-]", "_");
		File outputFile = new File(dir, safeName + ".tdl");
		Files.writeString(outputFile.toPath(), tdlContent);
		System.out.println("Saved converter output to " + outputFile.getAbsolutePath());
	}

	private File findConverterDir() {
		String dir = System.getProperty("asn1.converter.dir");
		if (dir != null) {