1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# limitations under the License.
14+ from collections import defaultdict
1415from pathlib import Path
1516import time
1617
1718import requests
1819from invoke .tasks import task
1920from robot .libdoc import libdoc
21+ from robot .api import ExecutionResult , ResultVisitor
22+ from robot .result .model import TestCase
2023
2124ROOT_DIR = Path (__file__ ).parent
2225ATEST_OUTPUT_DIR = ROOT_DIR / "atest" / "output"
@@ -92,6 +95,39 @@ def docs(ctx, version: str | None = None):
9295 output .rename (target )
9396
9497
98+ class ExecutionTimeChecker (ResultVisitor ):
99+ def __init__ (self , names : dict [str , int ]):
100+ self .names = names
101+ self .visited_names = defaultdict (int )
102+
103+ def visit_test (self , test : TestCase ):
104+ if name := self ._test_found (test ):
105+ self .visited_names [name ] += 1
106+ if self .visited_names [name ] > self .names [name ]:
107+ test .status = "FAIL"
108+ else :
109+ test .status = "FAIL"
110+
111+ def _test_found (self , test : TestCase ):
112+ for name in self .names :
113+ if name in test .name :
114+ return name
115+ return False
116+
117+
118+
119+ def check_tests (output_xml ):
120+ result = ExecutionResult (output_xml )
121+ test = {
122+ "DELETE /" : 5 ,
123+ "PUT /" : 5 ,
124+ "GET / " : 1 ,
125+ "GET /items/{item_id}" : 5 ,
126+ }
127+ result .visit (ExecutionTimeChecker (test ))
128+ result .save (output_xml )
129+
130+
95131@task (pre = [test_app ])
96132def atest (ctx ):
97133 """Run acceptance tests."""
@@ -105,7 +141,26 @@ def atest(ctx):
105141 "." ,
106142 "--outputdir" ,
107143 ATEST_OUTPUT_DIR .as_posix (),
144+ "--log" ,
145+ "NONE" ,
146+ "--report" ,
147+ "NONE" ,
108148 "atest/test" ,
109149 ]
110150 ATEST_OUTPUT_DIR .mkdir (parents = True , exist_ok = True )
111151 ctx .run (" " .join (args ))
152+ output_xml = ATEST_OUTPUT_DIR / "output.xml"
153+ check_tests (output_xml .as_posix ())
154+ log_file = ATEST_OUTPUT_DIR / "log.html"
155+ report_file = ATEST_OUTPUT_DIR / "report.html"
156+ rebot_args = [
157+ "uv" ,
158+ "run" ,
159+ "rebot" ,
160+ "--log" ,
161+ log_file .as_posix (),
162+ "--report" ,
163+ report_file .as_posix (),
164+ output_xml .as_posix (),
165+ ]
166+ ctx .run (" " .join (rebot_args ))
0 commit comments