Skip to content

Commit

Permalink
Refectored test output folder name (#998)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrizzi committed Jun 22, 2023
1 parent 2b0749b commit c8a9309
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
15 changes: 15 additions & 0 deletions rules/src/test/java/org/jboss/windup/rules/tests/RuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,27 @@
*/
public class RuleTest
{
private String id;
private String testDataPath;
private List<String> rulePaths = new ArrayList<>();
private List<String> ruleIds = new ArrayList<>();
private String source;
private String target;

/**
* Gets the ruletest ID
*/
public String getId() {
return id;
}

/**
* Sets the ruletest ID
*/
public void setId(String id) {
this.id = id;
}

/**
* Gets the source technology to operate on (eg, Glassfish).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
public class RuleTestHandler implements ElementHandler<RuleTest>
{
public static final String RULETEST = "ruletest";
public static final String RULETEST_ID = "id";
public static final String TEST_DATA_PATH = "testDataPath";
public static final String RULE_PATH = "rulePath";
public static final String SOURCE_MODE = "sourceMode";
Expand All @@ -62,6 +63,7 @@ public class RuleTestHandler implements ElementHandler<RuleTest>
public RuleTest processElement(ParserContext context, Element element) throws ConfigurationException
{
RuleTest ruleTest = new RuleTest();
ruleTest.setId($(element).attr(RULETEST_ID));

List<Element> children = $(element).children().get();
for (Element child : children)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ public void visit(File ruleTestFile)
try
{
Map<String, Exception> exceptions;
Path outputPath = getDefaultPath();
// load the ruletest file
final RuleTest ruleTest = parser.processDocument(ruleTestFile.toURI());
Path outputPath = getDefaultPath(ruleTest.getId());
try (GraphContext context = factory.create(outputPath, true))
{
// load the ruletest file
RuleTest ruleTest = parser.processDocument(ruleTestFile.toURI());
List<Path> rulePaths = new ArrayList<>();
if (ruleTest.getRulePaths().isEmpty())
{
Expand Down Expand Up @@ -316,9 +316,9 @@ private DefaultEvaluationContext createEvalContext(GraphRewrite event)
return evaluationContext;
}

private Path getDefaultPath()
private Path getDefaultPath(String rulesetId)
{
return FileUtils.getTempDirectory().toPath().resolve("WindupRulesTests").resolve("windupgraph_" + RandomStringUtils.randomAlphanumeric(6));
return FileUtils.getTempDirectory().toPath().resolve("WindupRulesTests").resolve("windupgraph_" + rulesetId + "_" + RandomStringUtils.randomAlphanumeric(6));
}

private void runWindup(GraphContext context, File baseRuleDirectory, final List<Path> rulePaths, File input, File output, boolean sourceMode, String source, String target) throws IOException
Expand Down

0 comments on commit c8a9309

Please sign in to comment.