• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 
15 #include "pw_unit_test/internal/rpc_event_handler.h"
16 #include "pw_unit_test/unit_test_service.h"
17 
18 namespace pw::unit_test::internal {
19 
RpcEventHandler(UnitTestService & service)20 RpcEventHandler::RpcEventHandler(UnitTestService& service)
21     : service_(service) {}
22 
ExecuteTests(span<std::string_view> suites_to_run)23 void RpcEventHandler::ExecuteTests(span<std::string_view> suites_to_run) {
24   RegisterEventHandler(this);
25   SetTestSuitesToRun(suites_to_run);
26 
27   PW_LOG_DEBUG("%u test suite filters applied",
28                static_cast<unsigned>(suites_to_run.size()));
29 
30   RUN_ALL_TESTS();
31 
32   RegisterEventHandler(nullptr);
33   SetTestSuitesToRun({});
34 }
35 
RunAllTestsStart()36 void RpcEventHandler::RunAllTestsStart() { service_.WriteTestRunStart(); }
37 
RunAllTestsEnd(const RunTestsSummary & run_tests_summary)38 void RpcEventHandler::RunAllTestsEnd(const RunTestsSummary& run_tests_summary) {
39   service_.WriteTestRunEnd(run_tests_summary);
40 }
41 
TestCaseStart(const TestCase & test_case)42 void RpcEventHandler::TestCaseStart(const TestCase& test_case) {
43   service_.WriteTestCaseStart(test_case);
44 }
45 
TestCaseEnd(const TestCase &,TestResult result)46 void RpcEventHandler::TestCaseEnd(const TestCase&, TestResult result) {
47   service_.WriteTestCaseEnd(result);
48 }
49 
TestCaseExpect(const TestCase &,const TestExpectation & expectation)50 void RpcEventHandler::TestCaseExpect(const TestCase&,
51                                      const TestExpectation& expectation) {
52   service_.WriteTestCaseExpectation(expectation);
53 }
54 
TestCaseDisabled(const TestCase & test_case)55 void RpcEventHandler::TestCaseDisabled(const TestCase& test_case) {
56   service_.WriteTestCaseDisabled(test_case);
57 }
58 
59 }  // namespace pw::unit_test::internal
60