monotone

monotone Mtn Source Tree

Root/tester-plaf.hh

1#ifndef __TESTER_PLAF_HH__
2#define __TESTER_PLAF_HH__
3
4// Copyright (C) 2007 Zack Weinberg <zackw@panix.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13// this describes functions to be found, alternatively, in win32/* or unix/*
14// directories and used only by the tester.
15
16#include <ctime>
17
18void make_accessible(std::string const & name);
19std::time_t get_last_write_time(char const * name);
20void do_copy_file(std::string const & from, std::string const & to);
21void set_env(char const * var, char const * val);
22void unset_env(char const * var);
23int do_umask(int mask);
24char * make_temp_dir();
25bool running_as_root();
26
27// This function has a decidedly awkward interface because (a) Windows
28// doesn't have fork(), (b) platform files can't talk directly to the Lua
29// interpreter. [Also it would be nice not to have to declare the full
30// content of the callback functors, but that is not so bad.]
31//
32// next_test() is called repeatedly until it returns false. Each time it
33// returns true, it shall fill in its test_to_run argument with the number
34// and name of the next test to run.
35//
36// For each such test, *either* invoke() is called in a forked child
37// process, *or* the program named in 'runner' is spawned with argument
38// vector [runner, '-r', testfile, firstdir, test-name]. Either way, the
39// child process is running in a just-created, empty directory which is
40// exclusive to that test. Standard I/O is not touched; the child is
41// expected not to use stdin, stdout, or stderr. If invoke() is called,
42// its return value is the process exit code.
43//
44// After each per-test child process completes, cleanup() is called for that
45// test. If cleanup() returns true, the per-test directory is deleted.
46
47struct lua_State;
48
49struct test_to_run
50{
51 int number;
52 std::string name;
53};
54
55struct test_enumerator
56{
57 lua_State * st;
58 int table_ref;
59 mutable int last_index;
60 mutable bool iteration_begun;
61 test_enumerator(lua_State *st, int t)
62 : st(st), table_ref(t), last_index(0), iteration_begun(false) {}
63 bool operator()(test_to_run & next_test) const;
64};
65
66struct test_invoker
67{
68 lua_State * st;
69 test_invoker(lua_State *st) : st(st) {}
70 int operator()(std::string const & testname) const;
71};
72
73struct test_cleaner
74{
75 lua_State * st;
76 int reporter_ref;
77 test_cleaner(lua_State *st, int r) : st(st), reporter_ref(r) {}
78 bool operator()(test_to_run const & test, int status) const;
79};
80
81void run_tests_in_children(test_enumerator const & next_test,
82 test_invoker const & invoke,
83 test_cleaner const & cleanup,
84 std::string const & run_dir,
85 std::string const & runner,
86 std::string const & testfile,
87 std::string const & firstdir);
88void prepare_for_parallel_testcases(int, int, int);
89
90// These functions are actually in tester.cc but are used by tester-plaf.cc.
91void do_remove_recursive(std::string const & dir);
92
93// Local Variables:
94// mode: C++
95// fill-column: 76
96// c-file-style: "gnu"
97// indent-tabs-mode: nil
98// End:
99// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
100
101#endif
102

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status