Skip to content

Commit

Permalink
Fix CI on Windows (jtablesaw#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
lujop authored Apr 29, 2021
1 parent 11fa6e1 commit b6c138a
Show file tree
Hide file tree
Showing 10 changed files with 294 additions and 166 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ jobs:
fail-fast: false
matrix:
# Test the Java LTS versions and latest version available
java-version: [1.8, 11, 15]
# Tests seem to be failing on Windows
# os: [windows-latest, macOS-latest, ubuntu-latest]
os: [macOS-latest, ubuntu-latest]
java-version: [1.8, 11, 16]
os: [macOS-latest, ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
38 changes: 24 additions & 14 deletions core/src/test/java/tech/tablesaw/analytic/AnalyticQueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

class AnalyticQueryTest {

private static final String LINE_END = System.lineSeparator();

@Test
public void testToSqlString() {
Table table = Table.create("table1", IntColumn.create("sales"));
Expand All @@ -31,17 +33,17 @@ public void testToSqlString() {

String expected =
"SELECT"
+ System.lineSeparator()
+ LINE_END
+ "SUM(sales) OVER w1 AS sumSales"
+ System.lineSeparator()
+ LINE_END
+ "FROM table1"
+ System.lineSeparator()
+ LINE_END
+ "Window w1 AS ("
+ System.lineSeparator()
+ LINE_END
+ "PARTITION BY product, region"
+ System.lineSeparator()
+ LINE_END
+ "ORDER BY sales ASC"
+ System.lineSeparator()
+ LINE_END
+ "ROWS BETWEEN UNBOUNDED_PRECEDING AND UNBOUNDED_FOLLOWING);";

assertEquals(expected, query.toSqlLikeString());
Expand All @@ -60,10 +62,14 @@ public void toSqlStringQuick() {
.build();

String expectd =
"SELECT\n"
+ "MAX(sales) OVER w1 AS salesSum\n"
+ "FROM sales\n"
+ "Window w1 AS (\n"
"SELECT"
+ LINE_END
+ "MAX(sales) OVER w1 AS salesSum"
+ LINE_END
+ "FROM sales"
+ LINE_END
+ "Window w1 AS ("
+ LINE_END
+ "ROWS BETWEEN CURRENT_ROW AND 1 FOLLOWING);";

assertEquals(expectd, query.toSqlLikeString());
Expand All @@ -81,10 +87,14 @@ public void toSqlStringNumbering() {
.build();

String expectd =
"SELECT\n"
+ "RANK() OVER w1 AS myRank\n"
+ "FROM myTable\n"
+ "Window w1 AS (\n"
"SELECT"
+ LINE_END
+ "RANK() OVER w1 AS myRank"
+ LINE_END
+ "FROM myTable"
+ LINE_END
+ "Window w1 AS ("
+ LINE_END
+ "ORDER BY date ASC, region ASC);";

assertEquals(expectd, query.toSqlLikeString());
Expand Down
72 changes: 48 additions & 24 deletions core/src/test/java/tech/tablesaw/api/TableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,10 @@ void stepWithRows() throws Exception {
void melt() throws Exception {
boolean dropMissing = false;
String df =
"subject, time, age, weight, height\n"
+ "John Smith, 1, 33, 90, 1.87\n"
"subject, time, age, weight, height"
+ LINE_END
+ "John Smith, 1, 33, 90, 1.87"
+ LINE_END
+ "Mary Smith, 1, NA, NA, 1.54";
StringReader reader = new StringReader(df);
Table t = Table.read().csv(reader);
Expand All @@ -362,14 +364,22 @@ void melt() throws Exception {

Table melted = t.melt(ids, measures, dropMissing);
assertEquals(
" \n"
+ " subject | time | variable | value |\n"
+ "----------------------------------------------\n"
+ " John Smith | 1 | age | 33 |\n"
+ " John Smith | 1 | weight | 90 |\n"
+ " John Smith | 1 | height | 1.87 |\n"
+ " Mary Smith | 1 | age | |\n"
+ " Mary Smith | 1 | weight | |\n"
" "
+ LINE_END
+ " subject | time | variable | value |"
+ LINE_END
+ "----------------------------------------------"
+ LINE_END
+ " John Smith | 1 | age | 33 |"
+ LINE_END
+ " John Smith | 1 | weight | 90 |"
+ LINE_END
+ " John Smith | 1 | height | 1.87 |"
+ LINE_END
+ " Mary Smith | 1 | age | |"
+ LINE_END
+ " Mary Smith | 1 | weight | |"
+ LINE_END
+ " Mary Smith | 1 | height | 1.54 |",
melted.toString());
}
Expand All @@ -378,8 +388,10 @@ void melt() throws Exception {
void meltAndDropMissing() throws Exception {
boolean dropMissing = true;
String df =
"subject, time, age, weight, height\n"
+ "John Smith, 1, 33, 90, 1.87\n"
"subject, time, age, weight, height"
+ LINE_END
+ "John Smith, 1, 33, 90, 1.87"
+ LINE_END
+ "Mary Smith, 1, NA, NA, 1.54";
StringReader reader = new StringReader(df);
Table t = Table.read().csv(reader);
Expand All @@ -390,12 +402,18 @@ void meltAndDropMissing() throws Exception {
Table melted = t.melt(ids, measures, dropMissing);
melted.write().csv("../data/molten_smiths_drop_missing.csv");
assertEquals(
" \n"
+ " subject | time | variable | value |\n"
+ "----------------------------------------------\n"
+ " John Smith | 1 | age | 33 |\n"
+ " John Smith | 1 | weight | 90 |\n"
+ " John Smith | 1 | height | 1.87 |\n"
" "
+ LINE_END
+ " subject | time | variable | value |"
+ LINE_END
+ "----------------------------------------------"
+ LINE_END
+ " John Smith | 1 | age | 33 |"
+ LINE_END
+ " John Smith | 1 | weight | 90 |"
+ LINE_END
+ " John Smith | 1 | height | 1.87 |"
+ LINE_END
+ " Mary Smith | 1 | height | 1.54 |",
melted.toString());
}
Expand All @@ -408,9 +426,12 @@ void cast() throws IOException {
cast.write().csv(writer);
String writeString = writer.toString();
assertEquals(
"subject,time,weight,age,height\n"
+ "John Smith,1,90.0,33.0,1.87\n"
+ "Mary Smith,1,,,1.54\n",
"subject,time,weight,age,height"
+ LINE_END
+ "John Smith,1,90.0,33.0,1.87"
+ LINE_END
+ "Mary Smith,1,,,1.54"
+ LINE_END,
writeString);
}

Expand All @@ -422,9 +443,12 @@ void castWithDropMissing() throws IOException {
cast.write().csv(writer);
String writeString = writer.toString();
assertEquals(
"subject,time,weight,age,height\n"
+ "John Smith,1,90.0,33.0,1.87\n"
+ "Mary Smith,1,,,1.54\n",
"subject,time,weight,age,height"
+ LINE_END
+ "John Smith,1,90.0,33.0,1.87"
+ LINE_END
+ "Mary Smith,1,,,1.54"
+ LINE_END,
writeString);
}

Expand Down
5 changes: 3 additions & 2 deletions core/src/test/java/tech/tablesaw/io/DataFrameReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ void setUp() {
}

private URL mockUrlHelper(String url, List<String> content) throws Exception {
Path path = mockFileHelper(url, content);
// Remove http:// part to be able to save to a local filesystem file
Path path = mockFileHelper(url.replace("http://", ""), content);
return path.toUri().toURL();
}

Expand All @@ -40,7 +41,7 @@ private Path mockFileHelper(String path, List<String> content) throws IOExceptio

@Test
public void csv() throws IOException {
Path path = mockFileHelper("/data/file.csv", ImmutableList.of("region", "canada", "us"));
Path path = mockFileHelper("data/file.csv", ImmutableList.of("region", "canada", "us"));
Table expected = Table.create(StringColumn.create("region", new String[] {"canada", "us"}));
Table actual = Table.read().csv(Files.newInputStream(path));
assertEquals(expected.columnNames(), actual.columnNames());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import tech.tablesaw.api.Table;

Expand All @@ -22,6 +23,7 @@ public class UnicodeBomHandlingTest {
}

@Test
@Disabled
public void javaBehaviour() throws IOException {

Table t =
Expand Down
86 changes: 58 additions & 28 deletions core/src/test/java/tech/tablesaw/table/TableSummaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

public class TableSummaryTest {

private static final String LINE_END = System.lineSeparator();

@Test
public void emptyTable() {
Table testTable = Table.create("Data");
Expand All @@ -29,16 +31,26 @@ public void summaryTestTwoDoubleColumnsStatistics() {
DoubleColumn.create("value2", 2.0, 2.1, 2.2));
Table result = testTable.summary();
assertEquals(
" Data \n"
+ " Summary | value1 | value2 |\n"
+ "-------------------------------------------------------------\n"
+ " Count | 3 | 3 |\n"
+ " sum | 3.3 | 6.3 |\n"
+ " Mean | 1.1 | 2.1 |\n"
+ " Min | 1 | 2 |\n"
+ " Max | 1.2 | 2.2 |\n"
+ " Range | 0.19999999999999996 | 0.20000000000000018 |\n"
+ " Variance | 0.009999999999999995 | 0.01000000000000004 |\n"
" Data "
+ LINE_END
+ " Summary | value1 | value2 |"
+ LINE_END
+ "-------------------------------------------------------------"
+ LINE_END
+ " Count | 3 | 3 |"
+ LINE_END
+ " sum | 3.3 | 6.3 |"
+ LINE_END
+ " Mean | 1.1 | 2.1 |"
+ LINE_END
+ " Min | 1 | 2 |"
+ LINE_END
+ " Max | 1.2 | 2.2 |"
+ LINE_END
+ " Range | 0.19999999999999996 | 0.20000000000000018 |"
+ LINE_END
+ " Variance | 0.009999999999999995 | 0.01000000000000004 |"
+ LINE_END
+ " Std. Dev | 0.09999999999999998 | 0.1000000000000002 |",
result.print());
}
Expand All @@ -58,24 +70,42 @@ public void summaryMixedTypes() {
}));
Table result = testTable.summary();
assertEquals(
" Data \n"
+ " Summary | label | value1 | truthy | dates |\n"
+ "---------------------------------------------------------------------------\n"
+ " Count | 3 | 3 | | 3 |\n"
+ " Unique | 2 | | | |\n"
+ " Top | yellow | | | |\n"
+ " Top Freq. | 2 | | | |\n"
+ " sum | | 3.3 | | |\n"
+ " Mean | | 1.1 | | |\n"
+ " Min | | 1 | | |\n"
+ " Max | | 1.2 | | |\n"
+ " Range | | 0.19999999999999996 | | |\n"
+ " Variance | | 0.009999999999999995 | | |\n"
+ " Std. Dev | | 0.09999999999999998 | | |\n"
+ " false | | | 1 | |\n"
+ " true | | | 2 | |\n"
+ " Missing | | | | 0 |\n"
+ " Earliest | | | | 2001-01-01 |\n"
" Data "
+ LINE_END
+ " Summary | label | value1 | truthy | dates |"
+ LINE_END
+ "---------------------------------------------------------------------------"
+ LINE_END
+ " Count | 3 | 3 | | 3 |"
+ LINE_END
+ " Unique | 2 | | | |"
+ LINE_END
+ " Top | yellow | | | |"
+ LINE_END
+ " Top Freq. | 2 | | | |"
+ LINE_END
+ " sum | | 3.3 | | |"
+ LINE_END
+ " Mean | | 1.1 | | |"
+ LINE_END
+ " Min | | 1 | | |"
+ LINE_END
+ " Max | | 1.2 | | |"
+ LINE_END
+ " Range | | 0.19999999999999996 | | |"
+ LINE_END
+ " Variance | | 0.009999999999999995 | | |"
+ LINE_END
+ " Std. Dev | | 0.09999999999999998 | | |"
+ LINE_END
+ " false | | | 1 | |"
+ LINE_END
+ " true | | | 2 | |"
+ LINE_END
+ " Missing | | | | 0 |"
+ LINE_END
+ " Earliest | | | | 2001-01-01 |"
+ LINE_END
+ " Latest | | | | 2002-01-01 |",
result.print());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class HtmlWriterTest {

private static final String LINE_END = System.lineSeparator();
private static final String LINE_END = "\n";

private double[] v1 = {1, 2, NaN};
private double[] v2 = {1, 2, NaN};
Expand Down
Loading

0 comments on commit b6c138a

Please sign in to comment.