Skip to content

Commit bc9edb4

Browse files
authored
fix: filtering with --spec option for projects in Docker container root (#23535)
* fix: updating globbing patterns to work when mounted to the root directory * Adding unit tests for globby calls * Updating a few tests. Reordering for cleaner diff. * Refactoring after develop merge * Persist binary for validation * Using arch-specific path sep
1 parent 2324d70 commit bc9edb4

File tree

3 files changed

+245
-93
lines changed

3 files changed

+245
-93
lines changed

circle.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ commands:
132132
- run:
133133
name: Check current branch to persist artifacts
134134
command: |
135-
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "tbiethman/22272-globbing-working-dir" ]]; then
135+
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "tbiethman/23380-root-spec-pattern" ]]; then
136136
echo "Not uploading artifacts or posting install comment for this branch."
137137
circleci-agent step halt
138138
fi

packages/data-context/src/sources/FileDataSource.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import { toPosix } from '../util/file'
99

1010
const debug = Debug('cypress:data-context:sources:FileDataSource')
1111

12+
export const matchGlobs = async (globs: string | string[], globbyOptions?: GlobbyOptions) => {
13+
return await globby(globs, globbyOptions)
14+
}
15+
1216
export class FileDataSource {
1317
constructor (private ctx: DataContext) {}
1418

@@ -32,12 +36,14 @@ export class FileDataSource {
3236

3337
async getFilesByGlob (cwd: string, glob: string | string[], globOptions?: GlobbyOptions) {
3438
const globs = ([] as string[]).concat(glob).map((globPattern) => {
39+
const workingDirectoryPrefix = path.join(cwd, path.sep)
40+
3541
// If the pattern includes the working directory, we strip it from the pattern.
3642
// The working directory path may include characters that conflict with glob
3743
// syntax (brackets, parentheses, etc.) and cause our searches to inadvertently fail.
3844
// We scope our search to the working directory using the `cwd` globby option.
39-
if (globPattern.startsWith(cwd)) {
40-
return globPattern.replace(cwd, '.')
45+
if (globPattern.startsWith(workingDirectoryPrefix)) {
46+
return globPattern.replace(workingDirectoryPrefix, '')
4147
}
4248

4349
return globPattern
@@ -62,7 +68,7 @@ export class FileDataSource {
6268
debug('globbing pattern(s): %o', globs)
6369
debug('within directory: %s', cwd)
6470

65-
const files = await globby(globs, { onlyFiles: true, absolute: true, cwd, ...globOptions, ignore: ignoreGlob })
71+
const files = await matchGlobs(globs, { onlyFiles: true, absolute: true, cwd, ...globOptions, ignore: ignoreGlob })
6672

6773
return files
6874
} catch (e) {

0 commit comments

Comments
 (0)