You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(robotcode): introduce support for .gitignore and .robotignore during test suite discovery
Implemented support for `.gitignore` and `.robotignore` files in the discovery process of Robot Framework test suites and test cases.
**Motivation**:
The existing exclusion mechanism in Robot Framework, which only ignores files starting with `.` or `_`, and `CSV` directories, is insufficient for modern projects. These projects often include large repositories with test data, build directories, virtual environments (e.g., Python venv), `node_modules`, and other generated files that should be excluded during test discovery. Thus, additional flexibility was needed to control which files and directories should be ignored.
**`.robotignore` file**:
Introduced a new `.robotignore` file specifically for Robot Framework discovery.
- The syntax of `.robotignore` mirrors that of `.gitignore`, making it familiar and easy to use.
- When a `.robotignore` file is present, it takes priority over any `.gitignore` files in the same directory or its subdirectories. This allows users to fine-tune which files or directories to exclude, independent of the rules defined in the `.gitignore`.
- `.robotignore` files are hierarchical: if a `.robotignore` file is found in a directory, the discovery process will continue searching for `.robotignore` files in its subdirectories. Any `.gitignore` files found in those subdirectories will be ignored if a `.robotignore` file is present.
**`.gitignore` support**:
In addition to `.robotignore`, the discovery process now respects `.gitignore` files when a `.robotignore` file is absent. This brings better alignment with existing practices, as many projects already maintain `.gitignore` files to filter out unnecessary files and directories (e.g., build artifacts, dependency directories, etc.).
**Priority rules**:
- If both `.robotignore` and `.gitignore` files are found in the same directory, `.robotignore` takes precedence.
- If only a `.gitignore` file is present, it will be respected during test suite discovery.
**VSCode/RobotCode compatibility**:
Improved integration with the VSCode extension `RobotCode`. Specifically, users leveraging the `robotcode.workspace.excludePatterns` setting will benefit from optimized pattern matching:
- Files and directories are now ignored globally without the need for leading `**`, similar to `.gitignore` behavior.
**Benefits**:
- Provides more granular control over the test discovery process by allowing specific exclusions that are tailored to testing needs, rather than being tied to version control ignore rules.
- Helps improve performance and accuracy when running tests by preventing unnecessary files or directories from being included in the discovery process.
- Reduces potential conflicts between version control and test discovery exclusion needs, allowing each to be managed independently where necessary.
**Usage scenarios**:
- Large projects with complex directory structures can now use `.robotignore` to exclude directories like `venv`, `build`, `dist`, `node_modules`, etc., that would otherwise slow down the test discovery process.
- Teams can use `.robotignore` files to establish testing-specific exclusions without affecting the rules for version control maintained in `.gitignore`.
**Backward compatibility**:
The existing behavior of ignoring files that begin with `.` or `_` and `CSV` directories remains intact. The new `.robotignore` and `.gitignore` handling is additive, enhancing the flexibility without breaking current projects.
closes#286
0 commit comments