-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update framework to ignore most formatting differences between #542
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
import java.math.BigDecimal; | ||
import java.sql.Types; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
|
@@ -91,6 +92,32 @@ public int hashCode() { | |
return hash; | ||
} | ||
|
||
// remove spaces unless they are in a string | ||
private List<String> splitStringBySpace(String input) { | ||
List<String> result = new ArrayList<String>(); | ||
int start = 0; | ||
boolean inQuotes = false; | ||
for (int current = 0; current < input.length(); current++) { | ||
if (input.charAt(current) == '\"') inQuotes = !inQuotes; // toggle state | ||
boolean atLastChar = (current == input.length() - 1); | ||
if(atLastChar) result.add(input.substring(start)); | ||
else if (input.charAt(current) == ' ' && !inQuotes) { | ||
result.add(input.substring(start, current)); | ||
start = current + 1; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
private String removeStringSpace(String input) { | ||
List<String> tokens = splitStringBySpace(input); | ||
StringBuilder sb = new StringBuilder(); | ||
for(String t : tokens) { | ||
sb.append(t); | ||
} | ||
return sb.toString(); | ||
} | ||
|
||
/** | ||
* String representation of the ColumnList object | ||
*/ | ||
|
@@ -101,14 +128,17 @@ public String toString() { | |
int type = (Integer) (types.get(i)); | ||
if (Simba && (type == Types.VARCHAR)) { | ||
String s1 = String.valueOf(values.get(i)); | ||
// if the field has a JSON string or list, then remove newlines so that | ||
// each record fits on a single line in the actual output file. | ||
// sometimes Drill returns records in different orders, and by | ||
// ensuring each reoord is on a single line, they can be matched in any | ||
// order | ||
// Sometimes Simba returns records that span multiple lines. | ||
// If the field has a JSON string or list, then remove newlines | ||
// so that each record fits on a single line in the actual output | ||
// file. json/json_kvgenflatten/kvgen/kvgen7.q | ||
// Also, sometimes Simba returns varchars with white spaces | ||
// in different places. Remove the white space. | ||
// convert/convert32.q | ||
if ((s1.length() > 0) && | ||
((s1.charAt(0) == '{') || (s1.charAt(0) == '[')) ) { | ||
s1 = Utils.removeNewLines(s1); | ||
s1 = removeStringSpace(s1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There might be libraries that do the reverse of prettifying JSON string, including stripping down extra spaces. Consider having a single Util method that does something like |
||
values.set(i, s1); | ||
} | ||
} | ||
|
@@ -117,14 +147,17 @@ public String toString() { | |
int type = (Integer) (types.get(values.size()-1)); | ||
if (Simba && (type == Types.VARCHAR)) { | ||
String s1 = String.valueOf(values.get(values.size()-1)); | ||
// if the field has a JSON string or list, then remove newlines so that | ||
// each record fits on a single line in the actual output file. | ||
// sometimes Drill returns records in different orders, and by | ||
// ensuring each reoord is on a single line, they can be matched in any | ||
// order | ||
// Sometimes Simba returns records that span multiple lines. | ||
// If the field has a JSON string or list, then remove newlines | ||
// so that each record fits on a single line in the actual output | ||
// file. json/json_kvgenflatten/kvgen/kvgen7.q | ||
// Also, sometimes Simba returns varchars with white spaces | ||
// in different places. Remove the white space. | ||
// convert/convert32.q | ||
if ((s1.length() > 0) && | ||
((s1.charAt(0) == '{') || (s1.charAt(0) == '[')) ) { | ||
s1 = Utils.removeNewLines(s1); | ||
s1 = removeStringSpace(s1); | ||
values.set(values.size()-1, s1); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,8 +384,13 @@ private static String getExpectedFile(String queryFile, String queryFileExt, | |
} else { | ||
// if expected results file with driver extension exists, then use it | ||
// i.e. query.e_tsv.sjdbc | ||
// else if expected result file with driver extension and .fail exists, and skip this test | ||
// else if expected result file with driver extension and .fail exists, | ||
// and skip this test | ||
// i.e. query.e_tsv.sjdbc.fail | ||
// else if expected result file with driver extension and .fail exists, | ||
// and skip this test | ||
// i.e. query.e_tsv.xxx.sjdbc.fail where 'xxx' can be anything, such as a jira | ||
// i.e. query.e_tsv.md4862.sjdbc.fail | ||
// else use Apache. | ||
Filename = queryFile.substring(0, idx).concat(expectedFileExt.substring(2)); | ||
FilenameJDBC = Filename.concat(".").concat(driverExt); | ||
|
@@ -398,7 +403,24 @@ private static String getExpectedFile(String queryFile, String queryFileExt, | |
if (driverFile.exists()) { | ||
return null; | ||
} else { | ||
return Filename; | ||
File parent = driverFile.getParentFile(); | ||
String basename = Filename.substring(Filename.lastIndexOf('/') + 1); | ||
File[] listOfFiles = parent.listFiles(); | ||
boolean FOUNDFAILED = false; | ||
for (File file: listOfFiles) { | ||
if (file.isFile()) { | ||
if (file.getName().startsWith(basename) && | ||
file.getName().endsWith(".sjdbc.fail")) { | ||
FOUNDFAILED = true; | ||
break; | ||
} | ||
} | ||
} | ||
if (FOUNDFAILED) { | ||
return null; | ||
} else { | ||
return Filename; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Variables need to be in lower camel case |
||
} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should ideally be set as
isSimba