Skip to content

Commit

Permalink
Laundry on /bugs test cases (java, cpp, charp)
Browse files Browse the repository at this point in the history
Signed-off-by: mmazas <mmazas@ITEM-S104678.emea.msad.sopra>
  • Loading branch information
mmazas authored and mmazas committed Aug 23, 2024
1 parent 8e43ff8 commit b21b9f6
Show file tree
Hide file tree
Showing 16 changed files with 899 additions and 153 deletions.
36 changes: 22 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
**/vs2017/
# Structure
classes/
target/
# Eclipse file
bin/

# Maven
**/interpolated-*.*

# IDEs & plugins
.classpath
.project
.settings/
.idea
bin/
.gradle
.groovy
.checkstyle
*.iml

local-repo/
# it local repositories
it/local-repo/

# Compiled class file
# Compiled classes
*.class

# Log file
*.log

# BlueJ files
*.ctxt
# Logs
**/*.log

# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Results
**/*.out
**/*.err

# Package Files #
# Packaging
*.jar
*.war
*.nar
Expand All @@ -31,9 +38,10 @@ local-repo/
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
# jvm crash logs
hs_err_pid*

# MS objects
*.suo
*.exe
*.ilk
Expand Down
99 changes: 79 additions & 20 deletions bugs/bug001/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,55 @@ THE POSSIBILITY OF SUCH DAMAGE.

<build>
<plugins>


<!-- clear the tests results files -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clear-res</id>
<phase>test</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>test</directory>
<includes>
<include>*.out, *.err</include>
</includes>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>

<!-- execute the tests -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>clc1.test</id>
<id>exec-1</id>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>clc.ComplexLineComment</mainClass>
<arguments>
<argument>${project.basedir}/test/clc1.in</argument>
<argument>${project.basedir}/test/clc1.in2</argument>
<argument>${project.basedir}/test/clc1.out</argument>
<argument>${project.basedir}/test/clc1.err</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>clc2.test</id>
<id>exec-2</id>
<phase>test</phase>
<goals>
<goal>java</goal>
Expand All @@ -84,62 +111,94 @@ THE POSSIBILITY OF SUCH DAMAGE.
</execution>
</executions>
</plugin>


<!-- check the tests results -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>compare-clc1</id>
<id>check-res-1</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>false</skip>
<target unless="maven.test.skip">
<available file="${project.basedir}/test/clc1.out" property="isActualAvailable" />
<fail unless="isActualAvailable"
<!-- out -->
<available file="${project.basedir}/test/clc1.out" property="isActualOutAvailable" />
<fail unless="isActualOutAvailable"
message="${project.basedir}/test/clc1.out does not exist!" />
<available file="${project.basedir}/test/clc1.ref" property="isExpectedAvailable" />
<fail unless="isExpectedAvailable"
message="${project.basedir}/test/clc1.ref does not exist!" />
<condition property="files.match">
<filesmatch file1="${project.basedir}/test/clc1.out"
file2="${project.basedir}/test/clc1.ref" textfile="true" />
<available file="${project.basedir}/test/clc1.exp_out"
property="isExpectedOutAvailable" />
<fail unless="isExpectedOutAvailable"
message="${project.basedir}/test/clc1.exp_out does not exist!" />
<condition property="out.files.match">
<filesmatch textfile="true" file1="${project.basedir}/test/clc1.out"
file2="${project.basedir}/test/clc1.exp_out" />
</condition>
<fail unless="files.match"
message="${project.basedir}/test/clc1.out does not match ${project.basedir}/test/clc1.ref!" />
<fail unless="out.files.match"
message="${project.basedir}/test/clc1.out does not match ${project.basedir}/test/clc1.exp_out!" />
<!-- err -->
<available file="${project.basedir}/test/clc1.err" property="isActualErrAvailable" />
<fail unless="isActualErrAvailable"
message="${project.basedir}/test/clc1.err does not exist!" />
<available file="${project.basedir}/test/clc1.exp_err"
property="isExpectedErrAvailable" />
<fail unless="isExpectedErrAvailable"
message="${project.basedir}/test/clc1.exp_err does not exist!" />
<condition property="err.files.match">
<filesmatch textfile="true" file1="${project.basedir}/test/clc1.err"
file2="${project.basedir}/test/clc1.exp_err" />
</condition>
<fail unless="err.files.match"
message="${project.basedir}/test/clc1.err does not match ${project.basedir}/test/clc1.exp_err!" />
</target>
</configuration>
</execution>
<execution>
<id>compare-clc2</id>
<id>check-res-2</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>false</skip>
<target unless="maven.test.skip">
<!-- out -->
<available file="${project.basedir}/test/clc2.out" property="isActualAvailable" />
<fail unless="isActualAvailable"
message="${project.basedir}/test/clc2.out does not exist!" />
<available file="${project.basedir}/test/clc2.ref" property="isExpectedAvailable" />
<fail unless="isExpectedAvailable"
message="${project.basedir}/test/clc2.ref does not exist!" />
<condition property="files.match">
<filesmatch file1="${project.basedir}/test/clc2.out"
file2="${project.basedir}/test/clc2.ref" textfile="true" />
<filesmatch textfile="true" file1="${project.basedir}/test/clc2.out"
file2="${project.basedir}/test/clc2.ref" />
</condition>
<fail unless="files.match"
message="${project.basedir}/test/clc2.out does not match ${project.basedir}/test/clc2.ref!" />
<!-- err -->
<available file="${project.basedir}/test/clc2.err" property="isActualErrAvailable" />
<fail unless="isActualErrAvailable"
message="${project.basedir}/test/clc2.err does not exist!" />
<available file="${project.basedir}/test/clc2.exp_err"
property="isExpectedErrAvailable" />
<fail unless="isExpectedErrAvailable"
message="${project.basedir}/test/clc2.exp_err does not exist!" />
<condition property="err.files.match">
<filesmatch textfile="true" file1="${project.basedir}/test/clc2.err"
file2="${project.basedir}/test/clc2.exp_err" />
</condition>
<fail unless="err.files.match"
message="${project.basedir}/test/clc2.err does not match ${project.basedir}/test/clc2.exp_err!" />
</target>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
93 changes: 64 additions & 29 deletions bugs/bug001/src/main/javacc/ComplexLineComment.jj
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
options {
DEBUG_TOKEN_MANAGER=true;
}

PARSER_BEGIN(ComplexLineComment)
package clc;

Expand All @@ -8,55 +12,86 @@ import java.io.PrintStream;

public class ComplexLineComment {

public static void main(String args[]) throws FileNotFoundException {
InputStream input = System.in;
PrintStream output = System.out;
PrintStream error = System.err;
InputStream prevInput = null;
PrintStream prevOutput = null;
PrintStream prevError = null;
if (args.length == 3) {
prevInput = input; input = new FileInputStream(args[0]);
prevOutput = output; output = new PrintStream(args[1]);
prevError = error; error = new PrintStream(args[2]);
System.setIn(input);
System.setOut(output);
System.setErr(error);
public static void main(String args[]) {
if (args.length != 3) {
System.err.println("Error: invalid number of arguments (" + args.length + ")");
System.err.println("Usage: ComplexLineComment inputfile outputfile errorfile");
System.exit(4);
}
String fn = null;
InputStream stdInput = null;
PrintStream stdOutput = null;
PrintStream stdError = null;
try {
ComplexLineComment parser = new ComplexLineComment(System.in);
parser.Input();
// open files and redirect standard streams to them
fn = "input";
stdInput = System.in;
System.setIn(new FileInputStream(args[0]));
fn = "output";
stdOutput = System.out;
System.setOut(new PrintStream(args[1]));
fn = "error";
stdError = System.err;
System.setErr(new PrintStream(args[2]));
// parse
ComplexLineComment parser = new ComplexLineComment(System.in);
parser.Input();
System.err.println("Input file parsed successfully");
} catch (FileNotFoundException e) {
System.err.println("Error opening " + fn + " file");
System.err.println(e.getMessage());
} catch (Exception e) {
error.println(e.getMessage());
System.err.println("Error parsing input file");
System.err.println(e.getMessage());
} finally {
if (prevInput != null) System.setIn(prevInput);
if (prevOutput != null) System.setOut(prevOutput);
if (prevError != null) System.setErr(prevError);
// restore standard streams
if (stdInput != null) System.setIn(stdInput);
if (stdOutput != null) System.setOut(stdOutput);
if (stdError != null) System.setErr(stdError);
}
}

}

PARSER_END(ComplexLineComment)

SKIP : { " " | "\t" | "\n" | "\r" }
SKIP : { " " | "\t" | "\n" | "\r" }

TOKEN:
{ <#NA : ~["-","\r","\n"] >
| <#EOL : ("\n"|"\r"|"\r\n") >
TOKEN :
{
<#NA : ~[ "-", "\r", "\n" ] >
| <#EOL : ( "\n" | "\r" | "\r\n" ) >
}

SPECIAL_TOKEN : {"--":LineComment}
<LineComment>SPECIAL_TOKEN :{<(<NA>|"-"<NA>)*(<EOL>|"-"<EOL>|"-""-")?>:DEFAULT}
SPECIAL_TOKEN :
{
"--" : LineComment
}

< LineComment >
SPECIAL_TOKEN :
{
< (
< NA >
| "-" < NA >
)*
(
< EOL >
| "-" < EOL >
| "-" "-"
)? > : DEFAULT
}

TOKEN :
{
< Id: ["a"-"z","A"-"Z"] ( ["a"-"z","A"-"Z","0"-"9", "-"] )* > { System.out.println(matchedToken.toString()); }
< Id: ["a"-"z", "A"-"Z"] ( ["a"-"z", "A"-"Z", "0"-"9", "-"] )* >
{ System.out.println(matchedToken.toString()); }
}

void Input() :
{}
{
( <Id> )+ <EOF>
( <Id> )*
// { System.out.println("Finished ID+"); System.err.println("Finished ID+"); }
<EOF>
// { System.out.println("EOF found"); System.err.println("EOF found"); }
}
Empty file removed bugs/bug001/test/clc1.err
Empty file.
Loading

0 comments on commit b21b9f6

Please sign in to comment.