1
/* Copyright © 2006 Roger Leigh <rleigh@debian.org>
3
* schroot is free software; you can redistribute it and/or modify it
4
* under the terms of the GNU General Public License as published by
5
* the Free Software Foundation; either version 2 of the License, or
6
* (at your option) any later version.
8
* schroot is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18
*********************************************************************/
20
#include <sbuild/sbuild-dirstream.h>
21
#include <sbuild/sbuild-nostream.h>
22
#include <sbuild/sbuild-run-parts.h>
23
#include <sbuild/sbuild-util.h>
28
#include <cppunit/extensions/HelperMacros.h>
30
using namespace CppUnit;
32
class test_run_parts : public TestFixture
34
CPPUNIT_TEST_SUITE(test_run_parts);
35
CPPUNIT_TEST(test_construction);
36
CPPUNIT_TEST_EXCEPTION(test_construction_fail, sbuild::dirstream::error);
37
CPPUNIT_TEST(test_run);
38
CPPUNIT_TEST(test_run2);
39
CPPUNIT_TEST(test_run3);
40
CPPUNIT_TEST_SUITE_END();
42
std::streambuf *saved;
43
sbuild::basic_nbuf<char> *monitor;
52
this->monitor = new sbuild::basic_nbuf<char>();
53
this->saved = std::cerr.std::ios::rdbuf(this->monitor);
58
std::cerr.std::ios::rdbuf(this->saved);
63
virtual ~test_run_parts()
69
sbuild::run_parts rp(TESTDATADIR "/run-parts.ex1");
73
test_construction_fail()
75
sbuild::run_parts rp(TESTDATADIR "/invalid_dir");
80
sbuild::run_parts rp(TESTDATADIR "/run-parts.ex1");
84
sbuild::string_list command;
85
sbuild::environment env(environ);
87
command.push_back("ok");
88
status = rp.run(command, env);
89
CPPUNIT_ASSERT(status == EXIT_SUCCESS);
92
command.push_back("fail");
93
status = rp.run(command, env);
94
CPPUNIT_ASSERT(status == EXIT_FAILURE);
97
command.push_back("fail2");
98
status = rp.run(command, env);
99
CPPUNIT_ASSERT(status == EXIT_FAILURE);
104
sbuild::run_parts rp(TESTDATADIR "/run-parts.ex2");
108
sbuild::string_list command;
109
sbuild::environment env(environ);
111
command.push_back("ok");
112
status = rp.run(command, env);
113
CPPUNIT_ASSERT(status == EXIT_SUCCESS);
118
sbuild::run_parts rp(TESTDATADIR "/run-parts.ex3");
122
sbuild::string_list command;
123
sbuild::environment env(environ);
125
command.push_back("ok");
126
status = rp.run(command, env);
127
CPPUNIT_ASSERT(status == EXIT_FAILURE);
132
CPPUNIT_TEST_SUITE_REGISTRATION(test_run_parts);