Skip to content

Commit

Permalink
Update gradle scripts and compiler plugin errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SasinduDilshara committed Aug 15, 2024
1 parent 978a6d0 commit 0914fea
Show file tree
Hide file tree
Showing 24 changed files with 396 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ target
bin/

# IDEA Files
.idea/
.idea2/
*.iml
*.ipr
*.iws
Expand Down
33 changes: 26 additions & 7 deletions ballerina-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
plugins {
id 'jacoco'
id 'groovy'
}

import org.apache.tools.ant.taskdefs.condition.Os
Expand Down Expand Up @@ -49,7 +50,7 @@ def stripBallerinaExtensionVersion(String extVersion) {
}
}

task clean {
clean {
delete "${project.projectDir}/${testCommonPackage}/target"

testPackages.each { testPackage ->
Expand Down Expand Up @@ -162,13 +163,25 @@ task publishTestCommonPackageToLocal {
}
}

task commitTomlFiles {
doLast {
project.exec {
ignoreExitValue true
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'cmd', '/c', "git commit -m \"[Automated] Update the native jar versions\" Ballerina.toml Dependencies.toml"
} else {
commandLine 'sh', '-c', "git commit -m '[Automated] Update the native jar versions' Ballerina.toml Dependencies.toml"
}
}
}
}

task ballerinaTest {
inputs.dir file(project.projectDir)
dependsOn(":${packageName}-${packageOrg}:build")
dependsOn(updateTomlVersions)
dependsOn(initializeVariables)
dependsOn(publishTestCommonPackageToLocal)
dependsOn(deleteDependencyTomlFile)
finalizedBy(commitTomlFiles)

doLast {
testPackages.each { testPackage ->
Expand Down Expand Up @@ -214,10 +227,16 @@ publishing {
}
}

task test {
test {
dependsOn(ballerinaTest)
}

task build {
dependsOn(test)
}
build.dependsOn ":${packageName}-ballerina:build"
build.dependsOn ":${packageName}-compiler-plugin:build"

test.dependsOn ":${packageName}-ballerina:build"
test.dependsOn ":${packageName}-compiler-plugin:build"
test.dependsOn ":${packageName}-compiler-plugin-tests:test"

publishToMavenLocal.dependsOn build
publish.dependsOn build
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,9 @@ function testParseListsWithOutputHeaders() {
["a", true, 1]
]);

ct1bt1 = csv:parseList([["a", "b", "c"], ["a", "b", "c"]], {headersRows: 2});
test:assertEquals(ct1bt1, []);
[string, boolean, int][]|[anydata...][]|csv:Error ct1bt1_union = csv:parseList([["a", "b", "c"], ["a", "b", "c"]], {headersRows: 2});
test:assertTrue(ct1bt1_union is csv:Error);
test:assertEquals((<error>ct1bt1_union).message(), "Custom headers should be provided");

ct1bt1 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headersRows: 1, customHeaders: ["h1", "h2", "h3"]});
test:assertEquals(ct1bt1, [
Expand All @@ -469,17 +470,14 @@ function testParseListsWithOutputHeaders() {
["a", true, 1]
]);

ct1bt1 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headersRows: 21});
ct1bt1 = csv:parseList([["a", "true", "1"]], {headersRows: 1});
test:assertEquals(ct1bt1, []);

(string|boolean|int)[][]|csv:Error ct1bt1_2 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headersRows: 1});
test:assertEquals(ct1bt1_2, [
["a", true, 1]
]);

ct1bt1_2 = csv:parseList([["a", "b", "c"], ["a", "b", "c"]], {headersRows: 2});
test:assertEquals(ct1bt1_2, []);

ct1bt1_2 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headersRows: 1, customHeaders: ["h1", "h2", "h3"]});
test:assertEquals(ct1bt1_2, [
["a", true, 1]
Expand All @@ -491,23 +489,12 @@ function testParseListsWithOutputHeaders() {
["a", true, 1]
]);

ct1bt1_2 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headersRows: 21});
test:assertEquals(ct1bt1_2, []);

[string, boolean, int][]|csv:Error ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headersRows: 1, outputWithHeaders: true});
test:assertEquals(ct1bt1_3, [
["a", true, 1],
["a", true, 1]
]);

ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headersRows: 2, outputWithHeaders: true});
test:assertTrue(ct1bt1_3 is csv:Error);
test:assertEquals((<error>ct1bt1_3).message(), "Custom headers should be provided");

ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"], ["a", "true", "1"]], {headersRows: 2, outputWithHeaders: true});
test:assertTrue(ct1bt1_3 is csv:Error);
test:assertEquals((<error>ct1bt1_3).message(), "Custom headers should be provided");

ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headersRows: 1, customHeaders: ["h1", "h2", "h3"], outputWithHeaders: true});
test:assertTrue(ct1bt1_3 is csv:Error);
test:assertEquals((<error>ct1bt1_3).message(), common:generateErrorMessageForInvalidValueForArrayType("h2", "1", "boolean"));
Expand All @@ -516,8 +503,9 @@ function testParseListsWithOutputHeaders() {
test:assertTrue(ct1bt1_3 is csv:Error);
test:assertEquals((<error>ct1bt1_3).message(), common:generateErrorMessageForInvalidValueForArrayType("h2", "1", "boolean"));

ct1bt1_3 = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headersRows: 21, outputWithHeaders: true});
test:assertEquals(ct1bt1_3, []);
[string, boolean, int|string][]|[anydata...][]|csv:Error ct1bt1_3_with_union = csv:parseList([["a", "true", "1"], ["a", "true", "1"]], {headersRows: 21, outputWithHeaders: true});
test:assertTrue(ct1bt1_3_with_union is csv:Error);
test:assertEquals((<error>ct1bt1_3_with_union).message(), "Custom headers should be provided");

string[][]|csv:Error ct1bt1_4 = csv:parseList([["a", "b", "c"], ["a", "true", "1"]], {headersRows: 1, outputWithHeaders: true});
test:assertEquals(ct1bt1_4, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedType7() {

@test:Config
function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() {
record{string a; boolean b; int c;}[]|csv:Error ct1br4 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 0, customHeaders: ["a", "c", "b"], outputWithHeaders: true});
record{string a; boolean b; int c;}[]|csv:Error ct1br4 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 0, customHeaders: ["a", "c", "b"]});
test:assertEquals(ct1br4, [
{a: "a", b: true, c: 1},
{a: "a", b: true, c: 1},
Expand All @@ -564,84 +564,84 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() {
{a: "a", b: true, c: 1}
]);

record{string a; boolean b; int c;}[]|csv:Error ct1br4_3 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 1, customHeaders: ["a", "c", "b"], outputWithHeaders: true});
record{string a; boolean b; int c;}[]|csv:Error ct1br4_3 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 1, customHeaders: ["a", "c", "b"]});
test:assertEquals(ct1br4_3, [
{a: "a", b: true, c: 1},
{a: "a", b: true, c: 1}
]);


record{string a; boolean b; int c;}[]|csv:Error ct1br4_4 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, customHeaders: ["a", "c", "b"], outputWithHeaders: true});
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, customHeaders: ["a", "c", "b"]});
test:assertEquals(ct1br4_4, [
{a: "a", b: true, c: 1}
]);

record{string a; boolean b; int c;}[]|csv:Error ct1br4_5 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, outputWithHeaders: true});
record{string a; boolean b; int c;}[]|record{}[]|csv:Error ct1br4_5 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2});
test:assertTrue(ct1br4_5 is csv:Error);
test:assertEquals((<error>ct1br4_5).message(), "Custom headers should be provided");

record{|string a; boolean b; int...;|}[]|csv:Error ct1br4_4_2 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, customHeaders: ["a", "c", "b"], outputWithHeaders: true});
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, customHeaders: ["a", "c", "b"]});
test:assertEquals(ct1br4_4_2, [
{a: "a", b: true, c: 1}
]);

record{|string a; boolean b; int...;|}[]|csv:Error ct1br4_5_2 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, outputWithHeaders: true});
record{|string a; boolean b; int...;|}[]|record{}[]|csv:Error ct1br4_5_2 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2});
test:assertTrue(ct1br4_5_2 is csv:Error);
test:assertEquals((<error>ct1br4_5).message(), "Custom headers should be provided");

map<int|string|boolean>[]|csv:Error ct2br4_3 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 1, customHeaders: ["a", "c", "b"], outputWithHeaders: true});
map<int|string|boolean>[]|csv:Error ct2br4_3 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 1, customHeaders: ["a", "c", "b"]});
test:assertEquals(ct2br4_3, [
{a: "a", b: true, c: 1},
{a: "a", b: true, c: 1}
]);

map<int|string|boolean>[]|csv:Error ct2br4_3_2 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 3, customHeaders: ["a", "c", "b"], outputWithHeaders: true});
map<int|string|boolean>[]|csv:Error ct2br4_3_2 = csv:parseList([["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 3, customHeaders: ["a", "c", "b"]});
test:assertEquals(ct2br4_3_2, []);

map<anydata>[]|csv:Error ct2br4_4 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, customHeaders: ["a", "c", "b"], outputWithHeaders: true});
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, customHeaders: ["a", "c", "b"]});
test:assertEquals(ct2br4_4, [
{a: "a", b: true, c: 1}
]);

map<string>[]|csv:Error ct2br4_5 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, customHeaders: ["a", "c", "b"], outputWithHeaders: true});
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, customHeaders: ["a", "c", "b"]});
test:assertEquals(ct2br4_5, [
{a: "a", b: "true", c: "1"},
{a: "a", b: "true", c: "1"}
]);

map<string>[]|csv:Error ct2br4_7 = csv:parseList(
map<string>[]|record{}[]|csv:Error ct2br4_7 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 4, customHeaders: ["a", "c", "b"], outputWithHeaders: true});
test:assertEquals(ct2br4_7, []);

map<string>[]|csv:Error ct2br4_6 = csv:parseList(
map<string>[]|record{}[]|csv:Error ct2br4_6 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 2, outputWithHeaders: true});
test:assertTrue(ct2br4_6 is csv:Error);
test:assertEquals((<error>ct1br4_5).message(), "Custom headers should be provided");

map<string>[]|csv:Error ct2br4_8 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 1, outputWithHeaders: true});
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 1});
test:assertEquals(ct2br4_8, [
{"a": "a", "1": "1", "true": "true"},
{"a": "a", "1": "1", "true": "true"},
{"a": "a", "1": "1", "true": "true"}
]);

map<string>[]|csv:Error ct2br4_8_2 = csv:parseList(
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 1, outputWithHeaders: false});
[["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"], ["a", "1", "true"]], {headersRows: 1});
test:assertEquals(ct2br4_8_2, [
{"a": "a", "1": "1", "true": "true"},
{"a": "a", "1": "1", "true": "true"},
{"a": "a", "1": "1", "true": "true"}
]);

map<string>[]|csv:Error ct2br4_9 = csv:parseList(
[["a", "c", "b"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headersRows: 1, outputWithHeaders: true});
[["a", "c", "b"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headersRows: 1});
test:assertEquals(ct2br4_9, [
{a: "a", b: "true", c: "2"},
{a: "a", b: "true", c: "3"},
Expand All @@ -650,7 +650,7 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() {
]);

map<boolean|int|string>[]|csv:Error ct2br4_10 = csv:parseList(
[["a", "b", "c"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headersRows: 1, outputWithHeaders: true});
[["a", "b", "c"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headersRows: 1});
test:assertEquals(ct2br4_10, [
{a: "a", c: true, b: 2},
{a: "a", c: true, b: 3},
Expand All @@ -659,17 +659,17 @@ function testFromCsvWithTypeForTupleAndRecordAsExpectedTypeWithHeaders() {
]);

map<boolean|int|string>[]|csv:Error ct2br4_10_2 = csv:parseList(
[["a", "b", "c"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headersRows: 1, outputWithHeaders: false});
[["a", "b", "c"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headersRows: 1});
test:assertEquals(ct2br4_10_2, [
{a: "a", c: true, b: 2},
{a: "a", c: true, b: 3},
{a: "a", c: true, b: 4},
{a: "a", c: true, b: 5}
]);

ct2br4_10_2 = csv:parseList(
map<boolean|int|string>[]|record{}[]|csv:Error ct2br4_10_3 = csv:parseList(
[["a", "b", "c"], ["a", "2", "true"], ["a", "3", "true"], ["a", "4", "true"], ["a", "5", "true"]], {headersRows: 1, customHeaders: ["c", "d", "e"], outputWithHeaders: false});
test:assertEquals(ct2br4_10_2, [
test:assertEquals(ct2br4_10_3, [
{c: "a", e: true, d: 2},
{c: "a", e: true, d: 3},
{c: "a", e: true, d: 4},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,16 +667,16 @@ function testsRecordsOutputWithHeadrs() {
test:assertTrue(bm3anyd3t_3 is csv:Error);
test:assertEquals((<error> bm3anyd3t_3).message(), "CSV data rows with varying headers are not yet supported");

record{}[]|csv:Error bm3anyd3t_4 = csv:transform([{"a": 1, "b": 2}, {"a": 3, "b": 4}], {outputWithHeaders: true});
record{}[]|csv:Error bm3anyd3t_4 = csv:transform([{"a": 1, "b": 2}, {"a": 3, "b": 4}]);
test:assertEquals(bm3anyd3t_4, [{"a": 1, "b": 2}, {"a": 3, "b": 4}]);

bm3anyd3t_4 = csv:transform([{"a": 1, "b": 2}, {"c": 3, "d": 4}], {outputWithHeaders: true});
bm3anyd3t_4 = csv:transform([{"a": 1, "b": 2}, {"c": 3, "d": 4}]);
test:assertEquals(bm3anyd3t_4, [{"a": 1, "b": 2}, {"c": 3, "d": 4}]);

bm3anyd3t_3 = csv:parseList([["a", "b"], ["c", "d", "e"]], {outputWithHeaders: true});
test:assertEquals(bm3anyd3t_3, [["a", "b"], ["c", "d", "e"]]);

bm3anyd3t_4 = csv:parseList([["a", "b"], ["c", "d", "e"]], {outputWithHeaders: true});
bm3anyd3t_4 = csv:parseList([["a", "b"], ["c", "d", "e"]]);
test:assertTrue(bm3anyd3t_4 is csv:Error);
test:assertEquals((<error> bm3anyd3t_4).message(), "CSV data rows with varying headers are not yet supported");
}
Loading

0 comments on commit 0914fea

Please sign in to comment.