3
3
* subunit C child-side bindings: report on tests being run.
4
4
* Copyright (C) 2006 Robert Collins <robertc@robertcollins.net>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6
* Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
7
* license at the users choice. A copy of both licenses are available in the
8
* project source as Apache-2.0 and BSD. You may not use this file except in
9
* compliance with one of these two licences.
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under these licenses is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the license you chose for the specific language governing permissions
15
* and limitations under that license.
22
19
#include <string.h>
23
20
#include "subunit/child.h"
22
/* Write details about a test event. It is the callers responsibility to ensure
23
* that details are only provided for events the protocol expects details on.
24
* @event: The event - e.g. 'skip'
25
* @name: The test name/id.
26
* @details: The details of the event, may be NULL if no details are present.
29
subunit_send_event(char const * const event, char const * const name,
30
char const * const details)
32
if (NULL == details) {
33
fprintf(stdout, "%s: %s\n", event, name);
35
fprintf(stdout, "%s: %s [\n", event, name);
36
fprintf(stdout, "%s", details);
37
if (details[strlen(details) - 1] != '\n')
38
fprintf(stdout, "\n");
39
fprintf(stdout, "]\n");
25
44
/* these functions all flush to ensure that the test runner knows the action
26
45
* that has been taken even if the subsequent test etc takes a long time or
27
46
* never completes (i.e. a segfault).
31
50
subunit_test_start(char const * const name)
33
fprintf(stdout, "test: %s\n", name);
52
subunit_send_event("test", name, NULL);
39
57
subunit_test_pass(char const * const name)
41
fprintf(stdout, "success: %s\n", name);
59
/* TODO: add success details as an option */
60
subunit_send_event("success", name, NULL);
47
65
subunit_test_fail(char const * const name, char const * const error)
49
fprintf(stdout, "failure: %s [\n", name);
50
fprintf(stdout, "%s", error);
51
if (error[strlen(error) - 1] != '\n')
52
fprintf(stdout, "\n");
53
fprintf(stdout, "]\n");
67
subunit_send_event("failure", name, error);
59
72
subunit_test_error(char const * const name, char const * const error)
61
fprintf(stdout, "error: %s [\n", name);
62
fprintf(stdout, "%s", error);
63
if (error[strlen(error) - 1] != '\n')
64
fprintf(stdout, "\n");
65
fprintf(stdout, "]\n");
74
subunit_send_event("error", name, error);
79
subunit_test_skip(char const * const name, char const * const reason)
81
subunit_send_event("skip", name, reason);