xref: /netbsd-src/external/bsd/kyua-cli/dist/engine/kyuafile.hpp (revision 6b3a42af15b5e090c339512c790dd68f3d11a9d8)
1*6b3a42afSjmmv // Copyright 2010 Google Inc.
2*6b3a42afSjmmv // All rights reserved.
3*6b3a42afSjmmv //
4*6b3a42afSjmmv // Redistribution and use in source and binary forms, with or without
5*6b3a42afSjmmv // modification, are permitted provided that the following conditions are
6*6b3a42afSjmmv // met:
7*6b3a42afSjmmv //
8*6b3a42afSjmmv // * Redistributions of source code must retain the above copyright
9*6b3a42afSjmmv //   notice, this list of conditions and the following disclaimer.
10*6b3a42afSjmmv // * Redistributions in binary form must reproduce the above copyright
11*6b3a42afSjmmv //   notice, this list of conditions and the following disclaimer in the
12*6b3a42afSjmmv //   documentation and/or other materials provided with the distribution.
13*6b3a42afSjmmv // * Neither the name of Google Inc. nor the names of its contributors
14*6b3a42afSjmmv //   may be used to endorse or promote products derived from this software
15*6b3a42afSjmmv //   without specific prior written permission.
16*6b3a42afSjmmv //
17*6b3a42afSjmmv // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18*6b3a42afSjmmv // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19*6b3a42afSjmmv // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20*6b3a42afSjmmv // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21*6b3a42afSjmmv // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22*6b3a42afSjmmv // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23*6b3a42afSjmmv // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24*6b3a42afSjmmv // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25*6b3a42afSjmmv // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*6b3a42afSjmmv // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27*6b3a42afSjmmv // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*6b3a42afSjmmv 
29*6b3a42afSjmmv /// \file engine/kyuafile.hpp
30*6b3a42afSjmmv /// Test suite configuration parsing and representation.
31*6b3a42afSjmmv 
32*6b3a42afSjmmv #if !defined(ENGINE_KYUAFILE_HPP)
33*6b3a42afSjmmv #define ENGINE_KYUAFILE_HPP
34*6b3a42afSjmmv 
35*6b3a42afSjmmv #include <string>
36*6b3a42afSjmmv #include <vector>
37*6b3a42afSjmmv 
38*6b3a42afSjmmv #include <lutok/state.hpp>
39*6b3a42afSjmmv 
40*6b3a42afSjmmv #include "engine/test_program.hpp"
41*6b3a42afSjmmv #include "utils/fs/path.hpp"
42*6b3a42afSjmmv #include "utils/optional.hpp"
43*6b3a42afSjmmv 
44*6b3a42afSjmmv namespace engine {
45*6b3a42afSjmmv 
46*6b3a42afSjmmv 
47*6b3a42afSjmmv /// Representation of the configuration of a test suite.
48*6b3a42afSjmmv ///
49*6b3a42afSjmmv /// Test suites are collections of related test programs.  They are described by
50*6b3a42afSjmmv /// a configuration file.
51*6b3a42afSjmmv ///
52*6b3a42afSjmmv /// Test suites have two path references: one to the "source root" and another
53*6b3a42afSjmmv /// one to the "build root".  The source root points to the directory from which
54*6b3a42afSjmmv /// the Kyuafile is being read, and all recursive inclusions are resolved
55*6b3a42afSjmmv /// relative to that directory.  The build root points to the directory
56*6b3a42afSjmmv /// containing the generated test programs and is prepended to the absolute path
57*6b3a42afSjmmv /// of the test programs referenced by the Kyuafiles.  In general, the build
58*6b3a42afSjmmv /// root will be the same as the source root; however, when using a build system
59*6b3a42afSjmmv /// that supports "build directories", providing this option comes in handy to
60*6b3a42afSjmmv /// allow running the tests without much hassle.
61*6b3a42afSjmmv ///
62*6b3a42afSjmmv /// This class provides the parser for test suite configuration files and
63*6b3a42afSjmmv /// methods to access the parsed data.
64*6b3a42afSjmmv class kyuafile {
65*6b3a42afSjmmv     /// Path to the directory containing the top-level Kyuafile loaded.
66*6b3a42afSjmmv     utils::fs::path _source_root;
67*6b3a42afSjmmv 
68*6b3a42afSjmmv     /// Path to the directory containing the test programs.
69*6b3a42afSjmmv     utils::fs::path _build_root;
70*6b3a42afSjmmv 
71*6b3a42afSjmmv     /// Collection of the test programs defined in the Kyuafile.
72*6b3a42afSjmmv     test_programs_vector _test_programs;
73*6b3a42afSjmmv 
74*6b3a42afSjmmv public:
75*6b3a42afSjmmv     explicit kyuafile(const utils::fs::path&, const utils::fs::path&,
76*6b3a42afSjmmv                       const test_programs_vector&);
77*6b3a42afSjmmv     ~kyuafile(void);
78*6b3a42afSjmmv 
79*6b3a42afSjmmv     static kyuafile load(const utils::fs::path&,
80*6b3a42afSjmmv                          const utils::optional< utils::fs::path >);
81*6b3a42afSjmmv 
82*6b3a42afSjmmv     const utils::fs::path& source_root(void) const;
83*6b3a42afSjmmv     const utils::fs::path& build_root(void) const;
84*6b3a42afSjmmv     const test_programs_vector& test_programs(void) const;
85*6b3a42afSjmmv };
86*6b3a42afSjmmv 
87*6b3a42afSjmmv 
88*6b3a42afSjmmv }  // namespace engine
89*6b3a42afSjmmv 
90*6b3a42afSjmmv #endif  // !defined(ENGINE_KYUAFILE_HPP)
91