Skip to content

Commit

Permalink
Fix some bugs (#108)
Browse files Browse the repository at this point in the history
* fix some bugs

* optimize the code

* optimize code to resolve possible error for para parsing

* modify some config and resolve a bug for genrs

* modify a code error

* update mo-tester-1.0-SNAPSHOT.jar

* delete some log print and modfiy template cases
  • Loading branch information
aressu1985 authored Sep 15, 2022
1 parent ebb8ee1 commit 73def01
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 16 deletions.
7 changes: 0 additions & 7 deletions assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@
<include>mo.yml</include>
<include>run.yml</include>
<include>log4j.properties</include>
</includes>
<fileMode>755</fileMode>
<outputDirectory>./</outputDirectory>
</fileSet>
<fileSet>
<directory>./</directory>
<includes>
<include>run.sh</include>
</includes>
<fileMode>755</fileMode>
Expand Down
3 changes: 1 addition & 2 deletions cases/template.result
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ select min(int32),max(int32),max(int32)-1 from t1;
min(int32) max(int32) max(int32) - 1
-1 2147483647 2147483646
select min(int32),max(int32),max(int32)-1 from t1 group by a;
min(int32) max(int32) max(int32) - 1
-1 2147483647 2147483646
[unknown result because it is related to issue#1234]
drop table t1;
CREATE TABLE NATION (
N_NATIONKEY INTEGER NOT NULL,
Expand Down
2 changes: 2 additions & 0 deletions cases/template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ create table t1 ( a int not null default 1, int32 int primary key);
insert into t1 (int32) values (-1),(1234567890),(2147483647);
select * from t1 order by a desc, int32 asc;
select min(int32),max(int32),max(int32)-1 from t1;
-- @bvt:issue#1234
select min(int32),max(int32),max(int32)-1 from t1 group by a;
-- @bvt:issue
drop table t1;
CREATE TABLE NATION (
N_NATIONKEY INTEGER NOT NULL,
Expand Down
Binary file modified lib/mo-tester-1.0-SNAPSHOT.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</build>
<packaging>jar</packaging>

<name>morunner</name>
<name>mo-tester</name>
<url>http://maven.apache.org</url>

<properties>
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/io/mo/Tester.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ public static void main(String[] args){

public static void run(File file){
if(file.isFile()){
if(file.getName().endsWith(".result"))
if(!(file.getName().endsWith(".sql") || file.getName().endsWith(".test"))) {
return;
}

if(isInclude(file.getName())) {
ScriptParser.parseScript(file.getPath());
Expand All @@ -186,8 +187,9 @@ public static void run(File file){

public static void generateRs(File file){
if(file.isFile()){
if(file.getName().endsWith(".result"))
if(!(file.getName().endsWith(".sql") || file.getName().endsWith(".test"))) {
return;
}

if(isInclude(file.getName())) {
ScriptParser.parseScript(file.getPath());
Expand All @@ -209,8 +211,9 @@ public static void generateRs(File file){

public static void debug(File file){
if(file.isFile()){
if(file.getName().endsWith(".result"))
if(!(file.getName().endsWith(".sql") || file.getName().endsWith(".test"))) {
return;
}

if(isInclude(file.getName())) {
ScriptParser.parseScript(file.getPath());
Expand All @@ -228,8 +231,9 @@ public static void debug(File file){

public static void check(File file){
if(file.isFile()){
if(file.getName().endsWith(".result"))
if(!(file.getName().endsWith(".sql") || file.getName().endsWith(".test"))) {
return;
}
if(isInclude(file.getName())) {
ScriptParser.parseScript(file.getPath());
TestScript script = ScriptParser.getTestScript();
Expand Down
23 changes: 21 additions & 2 deletions src/main/java/io/mo/db/Executor.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,26 @@ public static boolean genRS(TestScript script){
ArrayList<SqlCommand> commands = script.getCommands();
for (int j = 0; j < commands.size(); j++) {
SqlCommand command = null;

try{
command = commands.get(j);

if(command.isIgnore()) {
rs_writer.write(command.getCommand().trim());
rs_writer.newLine();
if (isUpdate) {
if (command.getExpResult() != null) {
if (command.getExpResult().getType() != RESULT.STMT_RESULT_TYPE_NONE)
rs_writer.write(command.getExpResult().getOrginalRSText());
}
} else {
rs_writer.write("[unknown result because it is related to issue#" + command.getIssueNo() + "]");
}
if(j < commands.size() -1)
rs_writer.newLine();
continue;
}

connection = getConnection(command);
statement = connection.createStatement();

Expand All @@ -238,7 +256,8 @@ public static boolean genRS(TestScript script){
actResult.setCommand(command);
rs_writer.write(command.getCommand().trim());
rs_writer.newLine();
if(command.isIgnore()) {
rs_writer.write(actResult.toString());
/*if(command.isIgnore()) {
if (isUpdate) {
if (command.getExpResult() != null) {
if (command.getExpResult().getType() != RESULT.STMT_RESULT_TYPE_NONE)
Expand All @@ -254,7 +273,7 @@ public static boolean genRS(TestScript script){
}
else {
rs_writer.write(actResult.toString());
}
}*/

if(j < commands.size() -1)
rs_writer.newLine();
Expand Down

0 comments on commit 73def01

Please sign in to comment.