Skip to content

Commit

Permalink
test: add a test to check that in NO_OUTPUT mode, nothing is created (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
surli authored and monperrus committed Mar 16, 2018
1 parent 2351731 commit 24f6b6c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/java/spoon/test/api/APITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.junit.Assert;
import org.junit.Test;
import spoon.Launcher;
import spoon.OutputType;
import spoon.SpoonAPI;
import spoon.compiler.InvalidClassPathException;
import spoon.reflect.code.CtIf;
Expand Down Expand Up @@ -45,6 +46,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -548,5 +550,21 @@ public File getDefaultOutputDirectory() {
assertTrue("Class file not contained ("+classFile.getCanonicalPath()+"). \nContent: "+ StringUtils.join(units, "\n"), units.contains(classFile.getCanonicalPath()));
}

@Test
public void testOutputWithNoOutputProduceNoFolder() {
// contract: when using "NO_OUTPUT" output type, no output folder shoud be created
String destPath = "./target/nooutput_" + UUID.randomUUID().toString();
final Launcher launcher = new Launcher();
launcher.addInputResource("./src/test/java/spoon/test/api/testclasses/Bar.java");
launcher.setSourceOutputDirectory(destPath);
launcher.getEnvironment().setOutputType(OutputType.NO_OUTPUT);
launcher.getEnvironment().setNoClasspath(true);
launcher.getEnvironment().setCommentEnabled(true);
launcher.run();
File outputDir = new File(destPath);
System.out.println(destPath);
assertFalse("Output dir should not exist: "+outputDir.getAbsolutePath(), outputDir.exists());
}


}

0 comments on commit 24f6b6c

Please sign in to comment.