Make test fixtures portable to non-Maven build layouts - #897
Open
hectorcast-db wants to merge 1 commit into
Open
Make test fixtures portable to non-Maven build layouts#897hectorcast-db wants to merge 1 commit into
hectorcast-db wants to merge 1 commit into
Conversation
TestOSUtils.resource() located a fixture via getResource() and chmod-ed it in place. That only works when test resources are exploded on disk as writable files (Maven's target/test-classes); it fails when they are served from a jar or a read-only tree (e.g. building the SDK with Bazel), where File.setExecutable returns false and the test fails. DatabricksConfigTest.testConfigFileScopes had the same fragility, hardcoding HOME to the relative path "src/test/resources/testdata", which only resolves from the module root. Keep the in-place behavior when the resource is a writable file on disk, so the returned path stays under target/test-classes and the tests' prefix-relative path assertions (StaticEnv) still hold. Only when it cannot be chmod-ed in place -- served from a jar or a read-only tree -- copy the resource (a single file or a whole directory subtree, preserving its path) into a writable temp directory, chmod the copy, and return that. Route testConfigFileScopes through the same helper. Behavior under `mvn test` is unchanged. Signed-off-by: Hector Castejon Diaz <hector.castejon@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
hectorcast-db
force-pushed
the
fix-test-fixtures-portable-path
branch
from
August 21, 2026 12:13
904294f to
4d8e8e6
Compare
Contributor
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
mihaimitrea-db
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make
TestOSUtils.resource()copy a test fixture — a single file or a wholedirectory subtree, preserving its path — into a writable temp directory and
return that path, instead of
chmod-ing the resource in place. RouteDatabricksConfigTest.testConfigFileScopesthrough the same helper instead ofhardcoding a relative
HOME.Why
TestOSUtils.resource()didgetResource(file)→new File(path).setExecutable(true).That only works when test resources are exploded on disk as writable files
(Maven's
target/test-classes). When the SDK is built and tested outside Maven —for example with Bazel, where resources are served from a jar or a read-only tree —
File.setExecutablereturnsfalseand the tests fail.DatabricksConfigTest.testConfigFileScopeshad the same fragility: it hardcodedHOMEto the relative pathsrc/test/resources/testdata, which only resolves whenthe working directory is the module root.
The new helper handles both
file:andjar:resource URLs and preserves theresource's path (some tests assert on substrings like
testdata/corrupt/.databrickscfg). Behavior undermvn testis unchanged.Tests
mvn testin CI. Verified out-of-band thatDefaultProfileTest,DatabricksConfigTest, andDatabricksAuthManualTest— which previously could notlocate/execute their fixtures outside Maven's layout — pass when the suite is built
with Bazel. The change is behavior-preserving for the Maven build.