Description
In gapic-node-processing/src/combine-libraries.ts, setOnlyDefaultSystemTests() filters out sample test fixtures from non-default versions when combining multi-version libraries (e.g., google-iam with v2 and v3).
It currently uses .includes(defaultVersion) on the full absolute file path:
function setOnlyDefaultSystemTests(defaultVersion: string, filePaths: FilePaths[]) {
const systemTestRegex = new RegExp('system-test/fixtures/sample/src');
for (let i = filePaths.length - 1; i >= 0; i--) {
const filePathObj = filePaths[i];
const normalizedPath = filePathObj.filePath.replace(/\\/g, '/');
if (systemTestRegex.test(normalizedPath) &&
!normalizedPath.includes(defaultVersion)) {
filePaths.splice(i, 1);
}
}
}
Bug Behavior
If the workspace or temporary directory path where Librarian/generator runs happens to contain the substring defaultVersion (for example, /tmp/upgrade-nodejs-v2Mp8W containing "v2"), normalizedPath.includes("v2") evaluates to true for all API versions (including v3).
As a result:
!normalizedPath.includes(defaultVersion) evaluates to false.
v3 fixture files are not filtered out.
v3 sample fixtures overwrite v2 sample fixtures, generating unintended client diffs (e.g., packages/google-iam/system-test/fixtures/sample/src/index.ts exporting AccessPoliciesClient instead of PoliciesClient).
Reference PR & CI Breakage
This issue was observed during Librarian version upgrade in:
Suggested Fix
Match the version directory boundary specifically rather than performing an unconstrained substring check across the absolute path:
const versionDirRegex = new RegExp(`(^|/)${defaultVersion}(/|$)`);
if (systemTestRegex.test(normalizedPath) && !versionDirRegex.test(normalizedPath)) {
filePaths.splice(i, 1);
}
Description
In
gapic-node-processing/src/combine-libraries.ts,setOnlyDefaultSystemTests()filters out sample test fixtures from non-default versions when combining multi-version libraries (e.g.,google-iamwithv2andv3).It currently uses
.includes(defaultVersion)on the full absolute file path:Bug Behavior
If the workspace or temporary directory path where Librarian/generator runs happens to contain the substring
defaultVersion(for example,/tmp/upgrade-nodejs-v2Mp8Wcontaining"v2"),normalizedPath.includes("v2")evaluates totruefor all API versions (includingv3).As a result:
!normalizedPath.includes(defaultVersion)evaluates tofalse.v3fixture files are not filtered out.v3sample fixtures overwritev2sample fixtures, generating unintended client diffs (e.g.,packages/google-iam/system-test/fixtures/sample/src/index.tsexportingAccessPoliciesClientinstead ofPoliciesClient).Reference PR & CI Breakage
This issue was observed during Librarian version upgrade in:
559da2d4(wheremktemp -dgenerated/tmp/upgrade-nodejs-v2Mp8W)v2in path did not generate thev3diffs, causing agit diffdiscrepancy).Suggested Fix
Match the version directory boundary specifically rather than performing an unconstrained substring check across the absolute path: