[PATCH] D47185: [LNT] API: add Tests resource.

Martin Liška via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 25 01:00:02 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL333259: API: add Tests resource. (authored by marxin, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47185?vs=147959&id=148561#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47185

Files:
  lnt/trunk/docs/api.rst
  lnt/trunk/lnt/server/ui/api.py
  lnt/trunk/tests/server/ui/test_api.py


Index: lnt/trunk/lnt/server/ui/api.py
===================================================================
--- lnt/trunk/lnt/server/ui/api.py
+++ lnt/trunk/lnt/server/ui/api.py
@@ -72,6 +72,21 @@
         result = common_fields_factory()
         result['fields'] = [{'column_id': i, 'column_name': f.column.name}
                 for i, f in enumerate(ts.sample_fields)]
+
+        return result
+
+class Tests(Resource):
+    """List all the tests in the test suite."""
+    method_decorators = [in_db]
+
+    @staticmethod
+    def get():
+        ts = request.get_testsuite()
+
+        result = common_fields_factory()
+        tests = request.session.query(ts.Test).all()
+        result['tests'] = [t.__json__() for t in tests]
+
         return result
 
 class Machines(Resource):
@@ -513,6 +528,7 @@
             resp.headers.extend(headers)
         return resp
 
+    api.add_resource(Tests, ts_path("tests"), ts_path("tests/"))
     api.add_resource(Fields, ts_path("fields"), ts_path("fields/"))
     api.add_resource(Machines, ts_path("machines"), ts_path("machines/"))
     api.add_resource(Machine, ts_path("machines/<machine_spec>"))
Index: lnt/trunk/docs/api.rst
===================================================================
--- lnt/trunk/docs/api.rst
+++ lnt/trunk/docs/api.rst
@@ -40,6 +40,8 @@
 +---------------------------+------------------------------------------------------------------------------------------+
 | /fields                   | Return all fields in this testsuite.                                                     |
 +---------------------------+------------------------------------------------------------------------------------------+
+| /tests                    | Return all tests in this testsuite.                                                      |
++---------------------------+------------------------------------------------------------------------------------------+
 
 .. _auth_tokens:
 
Index: lnt/trunk/tests/server/ui/test_api.py
===================================================================
--- lnt/trunk/tests/server/ui/test_api.py
+++ lnt/trunk/tests/server/ui/test_api.py
@@ -257,6 +257,21 @@
         self.assertEqual(0, f0['column_id'])
         self.assertEqual('compile_status', f0['column_name'])
 
+    def test_tests_api(self):
+        """Tests API."""
+        client = self.client
+        j = check_json(client, 'api/db_default/v4/nts/tests')
+
+        tests = j['tests']
+
+        # check number of tests
+        self.assertEqual(9, len(tests))
+
+        # check first test
+        t0 = tests[0]
+        self.assertEqual(1, t0['id'])
+        self.assertEqual('SingleSource/UnitTests/2006-12-01-float_varg', t0['name'])
+
     def test_schema(self):
         client = self.client
         rest_schema = check_json(client, 'api/db_default/v4/nts/schema')


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47185.148561.patch
Type: text/x-patch
Size: 2849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180525/4cb92a16/attachment.bin>


More information about the llvm-commits mailing list