Skip to content

Commit

Permalink
test(git): advanced test cases for include/exclude filters (#5472)
Browse files Browse the repository at this point in the history
* test(git): group test cases into semantic contexts

* test(git): fine-grained semantic contexts for include/exclude filters

* test: excessive test cases for include filter

To make sure include filter behaves equally when exclude is empty and undefined

* test: one more test-case for include filter

When the filename matches the filter, but the file path does not.

* test: test-case for globs in include filter for files

* test: test-case for globs in include filter for directories

* test(git): more test cases for exclude filter

* test(git): more detailed test cases for include filter

* test(git): more test cases for include/exclude filter

* test(git): do not check hashes for empty files in filter tests

This does not make much sense.
Hashes must be verified in the disk-based test projects.
This makes the results fo the failed tests more readable.

* test(git): (tmp) disable failing tests fir git-repo

* test: move exclude/include tests to own context

* test: use the right Garden instance in `getTreeVersion` tests

* test: move `getTreeVersion` tests to `git.ts`

To test the function against both `VcsHandler` implementations:
 - `GitHandler`
 - `GitRepoHandler`

* test: fix scan mode definition in tests

Make sure the same scan mode is used in all git handlers created while testing.

* refactor(test): extract function to run git handler tests

* refactor(test): simplified parameteric tests for exclude filter
  • Loading branch information
vvagaytsev authored Dec 4, 2023
1 parent 1687b11 commit 59a63dd
Show file tree
Hide file tree
Showing 4 changed files with 657 additions and 322 deletions.
8 changes: 8 additions & 0 deletions core/src/util/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { dedent, naturalList } from "./string.js"
import pathIsInside from "path-is-inside"
import { join, resolve } from "path"
import { DEFAULT_BUILD_TIMEOUT_SEC, GARDEN_CORE_ROOT, GardenApiVersion } from "../constants.js"
import type { GitScanMode } from "../constants.js"
import { getRootLogger } from "../logger/logger.js"
import stripAnsi from "strip-ansi"
import type { VcsHandler } from "../vcs/vcs.js"
Expand All @@ -44,6 +45,7 @@ import type {
} from "../commands/base.js"
import { validateSchema } from "../config/validation.js"
import fsExtra from "fs-extra"

const { mkdirp, remove } = fsExtra
import { GlobalConfigStore } from "../config-store/global.js"
import { isPromise } from "./objects.js"
Expand Down Expand Up @@ -166,6 +168,7 @@ export type TestGardenOpts = Partial<GardenOpts> & {
onlySpecifiedPlugins?: boolean
remoteContainerAuth?: boolean
clearConfigsOnScan?: boolean
gitScanMode?: GitScanMode
}

export class TestGarden extends Garden {
Expand Down Expand Up @@ -208,6 +211,11 @@ export class TestGarden extends Garden {
params.plugins = opts?.plugins || []
} else {
params = await resolveGardenParams(currentDirectory, { commandInfo: defaultCommandInfo, ...opts })
if (opts?.gitScanMode) {
params.projectConfig.scan = params.projectConfig.scan ?? { git: { mode: opts.gitScanMode } }
params.projectConfig.scan.git = params.projectConfig.scan.git ?? { mode: opts.gitScanMode }
params.projectConfig.scan.git.mode = opts.gitScanMode
}
if (cacheKey) {
paramCache[cacheKey] = cloneDeep({ ...params, log: <any>{}, plugins: [] })
}
Expand Down
5 changes: 2 additions & 3 deletions core/test/unit/src/vcs/git-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { GitRepoHandler } from "../../../../src/vcs/git-repo.js"
import { commonGitHandlerTests } from "./git.js"
import { runGitHandlerTests } from "./git.js"

describe("GitRepoHandler", () => {
commonGitHandlerTests(GitRepoHandler)
runGitHandlerTests("repo")
})
Loading

0 comments on commit 59a63dd

Please sign in to comment.