每当文件更改时运行测试
arv.autotest的Python项目详细描述
简介
监视文件更改(事件)和触发器的简单应用程序 响应程序的执行。它正在与ci一起开发 记住,但也可以用于其他目的。
te程序处于pre-alpha状态,但其功能足以测试 本身。
内部概述
- 监视器为更改设置文件/目录(pynotify)
- 决定要处理的事件(event_filters.py)。过滤器 可以按类型删除事件,因为事件将变快等。 这里实施的是拥挤。
- 执行命令以响应(runner.py)
- 处理命令(reporters)的输出。
- 在屏幕上显示输出
- 完成时显示通知 有一个概念证明预处理器,可以修改 输出(忽略并突出显示行)。
- 动态调整喉道
配置文件
下面的示例是由^{tt5}使用的配置文件$ 测试自身:
{ "command": "nosetests --verbosity=2", "global_ignore": ["\\..*"], "watch" : [ { "path" : "arv", "include" : [".*\\.py"] }, { "path" : "tests", "include" : ["test_.*\\.py"] } ] }
在command键中指定的命令将在 在监视的任何文件(匹配的文件)中检测到更改 *.py在arv目录中以及那些匹配的 test_*.py在tests目录中)。与任何 global_ignore模式(示例中隐藏的文件)将是 忽略。
为了确定是否处理或忽略事件:
- 如果文件名与global_ignoreregex中的任何一个匹配,则 忽略事件。使用此选项可忽略临时文件、VCS 文件等
- 寻找最特别的手表
匹配路径:
- 如果文件名与任何对应的^{tt13}匹配$ 模式事件被忽略。
- 如果文件匹配任何include模式,则事件为 处理。
- 否则将被忽略。
配置选项
顶级选项:
command: | string, required. Command to be executed on every file change. |
---|---|
watch: | a list of watches. See below. |
global_ignore: | a list of regexes (strings), optional. If a file name (not path) matches any regex the events related to that file are ignored. |
throttling: | See below. |
peprocessor: | A list of directives. See below. |
观看选项:
path: | string, required. Path of the directory. |
---|---|
recurse: | boolean, default ^{tt15}$. If ^{tt15}$ sub-directories will be monitored recursively. |
auto_add: | boolean, default ^{tt15}$. If ^{tt15}$ newly created sub-directories will be automatically monitored. |
include: | list of regexes (strings). Regexes matching included files. |
exclude: | list of regexes (strings). Regexes matching excluded files. |
预处理器选项:
regex: | regular expression. If the regex matches the whole line the corresponding action i executed. |
---|---|
action: | action identifier. Currently two actions are defined:
|
限制选项:
max_events_second: | |
---|---|
limit the maximum number of events that will be processed per second. |
关于regex
正则表达式是re正则表达式,而不是shell全局。使用.* 不是*。
正则表达式与文件名而不是路径匹配。
将$添加到正则表达式的末尾,因此test_.*\\.py将 匹配test_foo.py,但不匹配test_foo.py.bak。使用 test_.*\\.py.*匹配两者。
小心斜杠,json加载程序要求它们 逃跑了(加倍)。
联系信息
Alexis Roda,^ {A2}
如果你发现一个有进步的小虫子,你可以把它扔下去 电子邮件。