| 122 | } |
| 123 | |
| 124 | int registerTests( |
| 125 | boost::unit_test::test_suite& _suite, |
| 126 | boost::filesystem::path const& _basepath, |
| 127 | boost::filesystem::path const& _path, |
| 128 | std::vector<std::string> const& _labels, |
| 129 | TestCase::TestCaseCreator _testCaseCreator, |
| 130 | solidity::test::Batcher& _batcher |
| 131 | ) |
| 132 | { |
| 133 | int numTestsAdded = 0; |
| 134 | fs::path fullpath = _basepath / _path; |
| 135 | TestCase::Config config{ |
| 136 | fullpath.string(), |
| 137 | solidity::test::CommonOptions::get().evmVersion(), |
| 138 | solidity::test::CommonOptions::get().eofVersion(), |
| 139 | solidity::test::CommonOptions::get().vmPaths, |
| 140 | solidity::test::CommonOptions::get().enforceGasTest, |
| 141 | solidity::test::CommonOptions::get().enforceGasTestMinValue, |
| 142 | }; |
| 143 | if (fs::is_directory(fullpath)) |
| 144 | { |
| 145 | test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string()); |
| 146 | for (auto const& entry: boost::iterator_range<fs::directory_iterator>( |
| 147 | fs::directory_iterator(fullpath), |
| 148 | fs::directory_iterator() |
| 149 | )) |
| 150 | if ( |
| 151 | solidity::test::isValidSemanticTestPath(entry) && |
| 152 | (fs::is_directory(entry.path()) || TestCase::isTestFilename(entry.path().filename())) |
| 153 | ) |
| 154 | numTestsAdded += registerTests( |
| 155 | *sub_suite, |
| 156 | _basepath, _path / entry.path().filename(), |
| 157 | _labels, |
| 158 | _testCaseCreator, |
| 159 | _batcher |
| 160 | ); |
| 161 | _suite.add(sub_suite); |
| 162 | } |
| 163 | else |
| 164 | { |
| 165 | // TODO would be better to set the test to disabled. |
| 166 | if (_batcher.checkAndAdvance()) |
| 167 | { |
| 168 | // This must be a vector of unique_ptrs because Boost.Test keeps the equivalent of a string_view to the filename |
| 169 | // that is passed in. If the strings were stored directly in the vector, pointers/references to them would be |
| 170 | // invalidated on reallocation. |
| 171 | static std::vector<std::unique_ptr<std::string const>> filenames; |
| 172 | |
| 173 | filenames.emplace_back(std::make_unique<std::string>(_path.string())); |
| 174 | auto test_case = make_test_case( |
| 175 | [config, _testCaseCreator] |
| 176 | { |
| 177 | BOOST_REQUIRE_NO_THROW({ |
| 178 | runTestCase(config, _testCaseCreator); |
| 179 | }); |
| 180 | }, |
| 181 | _path.stem().string(), |
no test coverage detected