Skip to content

Commit

Permalink
Add new build command tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ShammiL committed Dec 1, 2023
1 parent 6c5e1a1 commit 888c06e
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void execute(Project project) {
boolean hasTomlErrors = project.currentPackage().manifest().diagnostics().hasErrors();
if (hasTomlErrors) {
toolDiagnostics.forEach(outStream::println);
throw createLauncherException("Ballerina.toml validation for pre build tool execution contains errors");
throw createLauncherException("ballerina.toml validation for pre build tool execution contains errors");
}
List<Tool> tools = project.currentPackage().manifest().tools();
ServiceLoader<BuildToolRunner> buildRunners = ServiceLoader.load(BuildToolRunner.class);
Expand Down Expand Up @@ -103,7 +103,7 @@ private void validateOptionsToml(Toml optionsToml, String toolName) throws IOExc
optionsToml.diagnostics().forEach(outStream::println);
for (Diagnostic d : optionsToml.diagnostics()) {
if (d.diagnosticInfo().severity().equals(DiagnosticSeverity.ERROR)) {
throw new ProjectException("Ballerina.toml validation for build tool execution contains errors");
throw new ProjectException("ballerina.toml validation for build tool execution contains errors");
}
}

Check warning on line 108 in cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunBallerinaPreBuildToolsTask.java

View check run for this annotation

Codecov / codecov/patch

cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunBallerinaPreBuildToolsTask.java#L108

Added line #L108 was not covered by tests
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1169,17 +1169,22 @@ public Object[][] provideToolPropertiesDiagnostics() {
{
"build-tool-with-invalid-missing-toml-properties",
"build-tool-with-invalid-missing-toml-properties.txt",
"error: Ballerina toml validation for pre build tool execution contains errors"
"error: ballerina.toml validation for pre build tool execution contains errors"
},
{
"build-tool-with-invalid-missing-optional-toml-properties",
"build-tool-with-invalid-missing-optional.txt",
"error: Ballerina toml validation for build tool execution contains errors",
"error: ballerina.toml validation for build tool execution contains errors"
},
{
"build-tool-with-diagnostics",
"build-tool-with-diagnostics.txt",
"error: Pre build tool openapi execution contains errors"
"error: pre-build tool openapi execution contains errors"
},
{
"build-tool-with-recurring-tool-properties",
"build-tool-with-recurring-tool-properties.txt",
"error: ballerina.toml validation for pre build tool execution contains errors"
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
org = "foo"
name = "winery"
version = "0.1.0"

[[tool.openapi]]
id = "generate-delivery-client"
filePath = "delivery.json"
targetModule = "delivery"
options.mode = "client"

[[tool.openapi]]
id = "generate-delivery-client"
filePath = "delivery1.json"
options.mode = "client"

[[tool.grpc]]
id = "generate-grpc-client"
filePath = "delivery2.json"
targetModule = "delivery"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public function main() {
return "Hello, World!";
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ERROR [Ballerina.toml:(6:1,9:24)] empty string found for key '[filePath]'
ERROR [Ballerina.toml:(6:1,9:24)] missing key '[targetModule]' in table '[tool.openapi]' in 'Ballerina.toml'.
ERROR [Ballerina.toml:(6:1,9:24)] empty string found for key '[filePath]' in table '[tool.openapi]'.
WARNING [Ballerina.toml:(6:1,9:24)] missing key '[targetModule]' in table '[tool.openapi]'. Default module will be taken as target module.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ERROR [Ballerina.toml:(6:1,10:24)] recurring target module delivery found in Ballerina.toml. Target module must be unique for each tool
ERROR [Ballerina.toml:(6:1,10:24)] recurring tool id generate-delivery-client found in Ballerina.toml. Tool id must be unique for each tool
WARNING [Ballerina.toml:(12:1,15:24)] missing key '[targetModule]' in table '[tool.openapi]'. Default module will be taken as target module.
WARNING [Ballerina.toml:(17:1,20:26)] tool options validation skipped due to: Schema file not found: grpc-options-schema.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ERROR [Ballerina.toml:(6:1,9:24)] empty string found for key '[filePath]'
ERROR [Ballerina.toml:(6:1,9:24)] missing key '[targetModule]' in table '[tool.openapi]' in 'Ballerina.toml'.
ERROR [Ballerina.toml:(6:1,9:24)] empty string found for key '[filePath]' in table '[tool.openapi]'.
WARNING [Ballerina.toml:(6:1,9:24)] missing key '[targetModule]' in table '[tool.openapi]'. Default module will be taken as target module.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ERROR [Ballerina.toml:(6:1,10:24)] recurring target module delivery found in Ballerina.toml. Target module must be unique for each tool
ERROR [Ballerina.toml:(6:1,10:24)] recurring tool id generate-delivery-client found in Ballerina.toml. Tool id must be unique for each tool
WARNING [Ballerina.toml:(12:1,15:24)] missing key '[targetModule]' in table '[tool.openapi]'. Default module will be taken as target module.
WARNING [Ballerina.toml:(17:1,20:26)] tool options validation skipped due to: Schema file not found: grpc-options-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ public Object[][] provideBallerinaTomlWithInvalidEntries() {
return new Object[][] {
{
"missing-tool-entries.toml",
"missing key '[filePath]' in table '[tool.openapi]' in 'Ballerina.toml'.",
"missing key '[targetModule]' in table '[tool.openapi]' in 'Ballerina.toml'."
"missing key '[filePath]' in table '[tool.openapi]'.",
"missing key '[id]' in table '[tool.openapi]'."
},
{
"invalid-tool-entries.toml",
"empty string found for key '[filePath]'",
"empty string found for key '[filePath]' in table '[tool.openapi]'.",
"incompatible type found for key '[targetModule]': expected 'STRING'"
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ org = "foo"
version = "0.1.0"

[[tool.openapi]]
id = "generate-delivery-client"
options.mode = "client"

0 comments on commit 888c06e

Please sign in to comment.