Skip to content
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

[Bug]: `re \(`` in source code breaks the test report #43670

Open
gayaldassanayake opened this issue Dec 3, 2024 · 0 comments
Open

[Bug]: `re \(`` in source code breaks the test report #43670

gayaldassanayake opened this issue Dec 3, 2024 · 0 comments
Labels
Area/TestFramework Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Bug

Comments

@gayaldassanayake
Copy link
Contributor

Description

When using the code, final string:RegExp regBracketSplitter = re `\(`;, the test_results.json has the below invalid syntax error.

image

The suspected reason for this is,

String json = gson.toJson(testReport).replace("\\(", "(");
which removes the escape character (\\( -> \().

Steps to Reproduce

import ballerina/io;

final string:RegExp regSpaceSplitter = re ` `;
final string:RegExp regBracketSplitter = re `\(`;

public function main() {
    string desc = "1000 x cost comp (0.1 annual)";
    string cleanDesc = getCleanInvoiceItemDescription(desc);
    io:println("Clean Description: ", cleanDesc);
}

public function getCleanInvoiceItemDescription(string description) returns string {
    string[] descriptionParts = regBracketSplitter.split(description);
    string[] descriptionParts2 = regSpaceSplitter.split(descriptionParts[0]);
    string cleanDescription = string:'join(" ", ...descriptionParts2.slice(2));
    return cleanDescription;
}

And to a bal test --test-report --code-coverage.

Affected Version(s)

Tested on Ballerina 2201.8.x, 2201.10.x

OS, DB, other environment details and versions

No response

Related area

-> Test Framework

Related issue(s) (optional)

https://github.com/wso2-enterprise/internal-support-ballerina/issues/849

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Area/TestFramework labels Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/TestFramework Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Bug
Projects
None yet
Development

No branches or pull requests

2 participants