Skip to content

Commit 022517f

Browse files
committed
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
1 parent d00be1e commit 022517f

File tree

11 files changed

+777
-24
lines changed

11 files changed

+777
-24
lines changed

.robotignore

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
sdist/
20+
var/
21+
wheels/
22+
share/python-wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.nox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*.cover
48+
*.py,cover
49+
.hypothesis/
50+
.pytest_cache/
51+
cover/
52+
53+
# profiler
54+
prof/
55+
56+
# Translations
57+
*.mo
58+
*.pot
59+
60+
# Django stuff:
61+
*.log
62+
local_settings.py
63+
db.sqlite3
64+
db.sqlite3-journal
65+
66+
# Flask stuff:
67+
instance/
68+
.webassets-cache
69+
70+
# Scrapy stuff:
71+
.scrapy
72+
73+
# Sphinx documentation
74+
docs/_build/
75+
76+
# PyBuilder
77+
.pybuilder/
78+
target/
79+
80+
# Jupyter Notebook
81+
.ipynb_checkpoints
82+
83+
# IPython
84+
profile_default/
85+
ipython_config.py
86+
87+
# pyenv
88+
# For a library or package, you might want to ignore these files since the code is
89+
# intended to run in multiple environments; otherwise, check them in:
90+
# .python-version
91+
92+
# pipenv
93+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
95+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
96+
# install all needed dependencies.
97+
#Pipfile.lock
98+
99+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
100+
__pypackages__/
101+
102+
# Celery stuff
103+
celerybeat-schedule
104+
celerybeat.pid
105+
106+
# SageMath parsed files
107+
*.sage.py
108+
109+
# Environments
110+
.env
111+
.venv
112+
env/
113+
venv/
114+
ENV/
115+
env.bak/
116+
venv.bak/
117+
.hatch/
118+
119+
# Spyder project settings
120+
.spyderproject
121+
.spyproject
122+
123+
# Rope project settings
124+
.ropeproject
125+
126+
# mkdocs documentation
127+
/site
128+
129+
# mypy
130+
.mypy_cache/
131+
.dmypy.json
132+
dmypy.json
133+
134+
# Pyre type checker
135+
.pyre/
136+
137+
# pytype static type analyzer
138+
.pytype/
139+
140+
# Cython debug symbols
141+
cython_debug/
142+
143+
.vscode/*
144+
#!.vscode/settings.json
145+
!.vscode/tasks.json
146+
!.vscode/launch.json
147+
!.vscode/extensions.json
148+
*.code-workspace
149+
150+
# Local History for Visual Studio Code
151+
.history/
152+
153+
# Logs
154+
logs
155+
*.log
156+
npm-debug.log*
157+
yarn-debug.log*
158+
yarn-error.log*
159+
lerna-debug.log*
160+
161+
# Diagnostic reports (https://nodejs.org/api/report.html)
162+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
163+
164+
# Runtime data
165+
pids
166+
*.pid
167+
*.seed
168+
*.pid.lock
169+
170+
# Directory for instrumented libs generated by jscoverage/JSCover
171+
lib-cov
172+
173+
# Coverage directory used by tools like istanbul
174+
coverage
175+
*.lcov
176+
177+
# nyc test coverage
178+
.nyc_output
179+
180+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
181+
.grunt
182+
183+
# Bower dependency directory (https://bower.io/)
184+
bower_components
185+
186+
# node-waf configuration
187+
.lock-wscript
188+
189+
# Compiled binary addons (https://nodejs.org/api/addons.html)
190+
build/Release
191+
192+
# Dependency directories
193+
node_modules/
194+
jspm_packages/
195+
196+
# Snowpack dependency directory (https://snowpack.dev/)
197+
web_modules/
198+
199+
# TypeScript cache
200+
*.tsbuildinfo
201+
202+
# Optional npm cache directory
203+
.npm
204+
205+
# Optional eslint cache
206+
.eslintcache
207+
208+
# Microbundle cache
209+
.rpt2_cache/
210+
.rts2_cache_cjs/
211+
.rts2_cache_es/
212+
.rts2_cache_umd/
213+
214+
# Optional REPL history
215+
.node_repl_history
216+
217+
# Output of 'npm pack'
218+
*.tgz
219+
220+
# Yarn Integrity file
221+
.yarn-integrity
222+
223+
# dotenv environment variables file
224+
.env
225+
.env.test
226+
227+
# parcel-bundler cache (https://parceljs.org/)
228+
.cache
229+
.parcel-cache
230+
231+
# Next.js build output
232+
.next
233+
out
234+
235+
# Nuxt.js build / generate output
236+
.nuxt
237+
dist
238+
239+
# Gatsby files
240+
.cache/
241+
# Comment in the public line in if your project uses Gatsby and not Next.js
242+
# https://nextjs.org/blog/next-9-1#public-directory-support
243+
# public
244+
245+
# vuepress build output
246+
.vuepress/dist
247+
248+
# Serverless directories
249+
.serverless/
250+
251+
# FuseBox cache
252+
.fusebox/
253+
254+
# DynamoDB Local files
255+
.dynamodb/
256+
257+
# TernJS port file
258+
.tern-port
259+
260+
# Stores VSCode versions used for testing VSCode extensions
261+
.vscode-test
262+
263+
vscode.d.ts
264+
vscode.proposed.d.ts
265+
266+
# yarn v2
267+
.yarn/cache
268+
.yarn/unplugged
269+
.yarn/build-state.yml
270+
.yarn/install-state.gz
271+
.pnp.*
272+
273+
*.vsix
274+
275+
# playground files
276+
playground/
277+
278+
# pycharm
279+
.idea/
280+
281+
# test results
282+
test-results
283+
results.html
284+
report.html
285+
286+
# pyenv
287+
.python-version
288+
289+
# robotcode
290+
.robotcode_cache/
291+
292+
# ruff
293+
.ruff_cache/
294+
295+
bundled/libs
296+
297+
# robotframework
298+
results/
299+
300+
# data
301+
_regtest_outputs/

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
// "analyze",
4848

4949
"discover",
50-
"tests",
50+
"suites",
5151
// "discover", "tests", "--tags"
5252
"."
5353
]

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -832,14 +832,13 @@
832832
"robotcode.workspace.excludePatterns": {
833833
"type": "array",
834834
"default": [
835-
"**/.git/",
836-
"**/.hatch/",
837-
"**/.venv/",
838-
"**/node_modules/",
839-
"**/.pytest_cache/",
840-
"**/__pycache__/",
841-
"**/.mypy_cache/",
842-
"**/.robotcode_cache/"
835+
".hatch/",
836+
".venv/",
837+
"node_modules/",
838+
".pytest_cache/",
839+
"__pycache__/",
840+
".mypy_cache/",
841+
".robotcode_cache/"
843842
],
844843
"items": {
845844
"type": "string"

0 commit comments

Comments
 (0)