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

Increase verbosity of testExtensionSchemaValidation tests #1010

Merged
merged 10 commits into from
Jul 23, 2024
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and what APIs have changed, if applicable.

## [Unreleased]

## [29.58.1] - 2024-07-19
- Increase verbosity of testExtensionSchemaValidation tests

## [29.58.0] - 2024-07-11
- Allow both @extension and @grpcExtension extensions in schema validation

Expand Down Expand Up @@ -5710,7 +5713,8 @@ patch operations can re-use these classes for generating patch messages.

## [0.14.1]

[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.58.0...master
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.58.1...master
[29.58.1]: https://github.com/linkedin/rest.li/compare/v29.58.0...v29.58.1
[29.58.0]: https://github.com/linkedin/rest.li/compare/v29.57.2...v29.58.0
[29.57.2]: https://github.com/linkedin/rest.li/compare/v29.57.1...v29.57.2
[29.57.1]: https://github.com/linkedin/rest.li/compare/v29.57.0...v29.57.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.SkipWhenEmpty;
import org.gradle.api.tasks.TaskAction;
import org.gradle.process.ExecResult;

import static com.linkedin.pegasus.gradle.SharedFileUtils.*;

Expand Down Expand Up @@ -154,7 +155,7 @@ public void validateExtensionSchema() throws IOException

ByteArrayOutputStream validationOutput = new ByteArrayOutputStream();

getProject().javaexec(javaExecSpec -> {
ExecResult result = getProject().javaexec(javaExecSpec -> {
String resolverPathArg = resolverPathStr;
if (isEnableArgFile())
{
Expand All @@ -167,8 +168,15 @@ public void validateExtensionSchema() throws IOException
javaExecSpec.args(_inputDir.getAbsolutePath());
javaExecSpec.setStandardOutput(validationOutput);
javaExecSpec.setErrorOutput(validationOutput);

// Handle failure after exec to output error to build log
javaExecSpec.setIgnoreExitValue(true);
});

IOUtil.writeText(getOutputFile(), validationOutput.toString(StandardCharsets.UTF_8.name()));
String validationOutputString = validationOutput.toString(StandardCharsets.UTF_8.name());
IOUtil.writeText(getOutputFile(), validationOutputString);
if (result.getExitValue() != 0) {
throw new GradleException("Error occurred during schema extension validation:\n" + validationOutputString);
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=29.58.0
version=29.58.1
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import java.io.File;

import org.testng.Assert;
import org.testng.asserts.SoftAssert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -86,15 +86,19 @@ public void testExtensionSchemaValidation(String inputDir, boolean isValid, Stri
{
String resolverPath = testPegasusDir;
String inputPath = testExtensionDir + File.separator + inputDir;

SoftAssert softAssert = new SoftAssert();
try
{
ExtensionSchemaValidationCmdLineApp.parseAndValidateExtensionSchemas(resolverPath, new File(inputPath));
Assert.assertTrue(isValid);
softAssert.assertTrue(isValid);
softAssert.assertEquals(null, errorMessage);
}
catch (Exception e)
{
Assert.assertTrue(!isValid);
Assert.assertEquals(e.getMessage(), errorMessage);
softAssert.assertTrue(!isValid);
softAssert.assertEquals(e.getMessage(), errorMessage);
}
softAssert.assertAll();
}
}
Loading