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 15syntax = "proto3"; 16 17package pw.unit_test; 18 19message TestCaseDescriptor { 20 // Name of the test suite to which this test case belongs. 21 string suite_name = 1; 22 23 // Name of the test case. 24 string test_name = 2; 25 26 // Path to the file in which the test case is defined. 27 string file_name = 3; 28} 29 30message TestCaseExpectation { 31 // The source code for the expression which was run. 32 string expression = 1; 33 34 // The expression with arguments evaluated. 35 string evaluated_expression = 2; 36 37 // Line number at which the expectation is located. 38 uint32 line_number = 3; 39 40 // Whether the expectation succeeded. 41 bool success = 4; 42} 43 44enum TestCaseResult { 45 SUCCESS = 0; 46 FAILURE = 1; 47 SKIPPED = 2; 48} 49 50message TestRunStart {} 51 52message TestRunEnd { 53 uint32 passed = 1; 54 uint32 failed = 2; 55 uint32 skipped = 3; 56 uint32 disabled = 4; 57} 58 59message Event { 60 oneof type { 61 // Unit test run has started. 62 TestRunStart test_run_start = 1; 63 64 // Unit test run has ended. 65 TestRunEnd test_run_end = 2; 66 67 // Start of a test case. 68 TestCaseDescriptor test_case_start = 3; 69 70 // End of a test case. 71 TestCaseResult test_case_end = 4; 72 73 // Encountered a disabled test case. 74 TestCaseDescriptor test_case_disabled = 5; 75 76 // Expectation statement within a test case. 77 TestCaseExpectation test_case_expectation = 6; 78 } 79}; 80 81message TestRunRequest { 82 // Whether to send expectation events for successful checks. 83 bool report_passed_expectations = 1; 84 85 // Optional list of test suites to run. 86 repeated string test_suite = 2; 87} 88 89service UnitTest { 90 // Runs registered unit tests, streaming back test events as they occur. 91 rpc Run(TestRunRequest) returns (stream Event) {} 92} 93