made the example file names unique, closes #419

This commit is contained in:
hneemann 2020-02-09 17:43:03 +01:00
parent 22aacf0ba3
commit 165b8b7526
17 changed files with 45 additions and 14 deletions

View File

@ -122,23 +122,13 @@ die Interrupts wieder freigegeben.}}</string>
<pos x="220" y="140"/>
</visualElement>
<visualElement>
<elementName>RS.dig</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>intLock</string>
</entry>
</elementAttributes>
<elementName>RSpSet.dig</elementName>
<elementAttributes/>
<pos x="300" y="-20"/>
</visualElement>
<visualElement>
<elementName>RS.dig</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>intr</string>
</entry>
</elementAttributes>
<elementName>RSpSet.dig</elementName>
<elementAttributes/>
<pos x="300" y="140"/>
</visualElement>
</visualElements>

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 2020 Helmut Neemann.
* Use of this source code is governed by the GPL v3 license
* that can be found in the LICENSE file.
*/
package de.neemann.digital.integration;
import junit.framework.TestCase;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
public class TestExampleNamesUnique extends TestCase {
public void testExamples() throws Exception {
File basedir = new File(Resources.getRoot(), "../../../");
File sourceFilename = new File(basedir, "distribution/Assembly.xml");
HashMap<String, File> names = new HashMap<>();
Element assembly = new SAXBuilder().build(sourceFilename).getRootElement();
for (Element fs : assembly.getChild("fileSets", null).getChildren("fileSet", null)) {
String outDir = fs.getChild("outputDirectory", null).getText();
if (outDir.startsWith("/examples/")) {
String srcDir = fs.getChild("directory", null).getText();
srcDir = srcDir.replace("${basedir}", basedir.getPath());
new FileScanner(f -> {
String name = f.getName();
File present = names.get(name);
if (present != null) {
throw new IOException("name not unique\n" + present.getPath() + "\n" + f.getPath());
}
names.put(name, f);
}).noOutput().scan(new File(srcDir));
}
}
}
}