Skip to content

Commit

Permalink
fix: filtering with --spec option for projects in Docker container …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
tbiethman authored Aug 29, 2022
1 parent 2324d70 commit bc9edb4
Show file tree
Hide file tree
Showing 3 changed files with 245 additions and 93 deletions.
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ commands:
- run:
name: Check current branch to persist artifacts
command: |
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "tbiethman/22272-globbing-working-dir" ]]; then
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "tbiethman/23380-root-spec-pattern" ]]; then
echo "Not uploading artifacts or posting install comment for this branch."
circleci-agent step halt
fi
Expand Down
12 changes: 9 additions & 3 deletions packages/data-context/src/sources/FileDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { toPosix } from '../util/file'

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

export const matchGlobs = async (globs: string | string[], globbyOptions?: GlobbyOptions) => {
return await globby(globs, globbyOptions)
}

export class FileDataSource {
constructor (private ctx: DataContext) {}

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

async getFilesByGlob (cwd: string, glob: string | string[], globOptions?: GlobbyOptions) {
const globs = ([] as string[]).concat(glob).map((globPattern) => {
const workingDirectoryPrefix = path.join(cwd, path.sep)

// If the pattern includes the working directory, we strip it from the pattern.
// The working directory path may include characters that conflict with glob
// syntax (brackets, parentheses, etc.) and cause our searches to inadvertently fail.
// We scope our search to the working directory using the `cwd` globby option.
if (globPattern.startsWith(cwd)) {
return globPattern.replace(cwd, '.')
if (globPattern.startsWith(workingDirectoryPrefix)) {
return globPattern.replace(workingDirectoryPrefix, '')
}

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

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

return files
} catch (e) {
Expand Down
Loading

5 comments on commit bc9edb4

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on bc9edb4 Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.7.0/linux-x64/develop-bc9edb44523d62ca934827b8e870f38f86634ca4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on bc9edb4 Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.7.0/linux-arm64/develop-bc9edb44523d62ca934827b8e870f38f86634ca4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on bc9edb4 Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.7.0/darwin-arm64/develop-bc9edb44523d62ca934827b8e870f38f86634ca4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on bc9edb4 Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.7.0/darwin-x64/develop-bc9edb44523d62ca934827b8e870f38f86634ca4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on bc9edb4 Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.7.0/win32-x64/develop-bc9edb44523d62ca934827b8e870f38f86634ca4/cypress.tgz

Please sign in to comment.