File src/tooling/Traverser.cpp changed (mode: 100644) (index dd0ada6..654e13e) |
... |
... |
Traverser::search() |
53 |
53 |
bool |
bool |
54 |
54 |
Traverser::search(const boost::filesystem::path &path) |
Traverser::search(const boost::filesystem::path &path) |
55 |
55 |
{ |
{ |
56 |
|
auto match = [this](const std::string &file) { |
|
57 |
|
if (!config.shouldProcessFile(file)) { |
|
|
56 |
|
auto match = [this](const std::string &file, bool passedIn) { |
|
57 |
|
if (!passedIn && !config.shouldProcessFile(file)) { |
58 |
58 |
return false; |
return false; |
59 |
59 |
} |
} |
60 |
60 |
|
|
|
... |
... |
Traverser::search(const boost::filesystem::path &path) |
66 |
66 |
}; |
}; |
67 |
67 |
|
|
68 |
68 |
if (!fs::is_directory(path)) { |
if (!fs::is_directory(path)) { |
69 |
|
return match(path.string()); |
|
|
69 |
|
return match(path.string(), /*passedIn=*/true); |
70 |
70 |
} |
} |
71 |
71 |
|
|
72 |
72 |
using it = fs::directory_iterator; |
using it = fs::directory_iterator; |
|
... |
... |
Traverser::search(const boost::filesystem::path &path) |
79 |
79 |
found |= search(path); |
found |= search(path); |
80 |
80 |
} |
} |
81 |
81 |
} else { |
} else { |
82 |
|
found |= match(path.string()); |
|
|
82 |
|
found |= match(path.string(), /*passedIn=*/false); |
83 |
83 |
} |
} |
84 |
84 |
} |
} |
85 |
85 |
return found; |
return found; |
File tests/tooling/Traverser.cpp changed (mode: 100644) (index f508763..c128efd) |
23 |
23 |
|
|
24 |
24 |
#include "tests.hpp" |
#include "tests.hpp" |
25 |
25 |
|
|
|
26 |
|
TEST_CASE("Traverser doesn't exclude passed in paths", "[tooling][traverser]") |
|
27 |
|
{ |
|
28 |
|
TempDir tempDir("config"); |
|
29 |
|
REQUIRE(boost::filesystem::create_directory(tempDir.str() + "/.zs")); |
|
30 |
|
makeFile(tempDir.str() + "/.zs/exclude", { "test.c" }); |
|
31 |
|
std::string file = tempDir.str() + "/test.c"; |
|
32 |
|
makeFile(file, { }); |
|
33 |
|
|
|
34 |
|
std::vector<std::string> paths; |
|
35 |
|
auto handler = [&](const std::string &path) { |
|
36 |
|
paths.push_back(path); |
|
37 |
|
return true; |
|
38 |
|
}; |
|
39 |
|
|
|
40 |
|
Chdir chdirInsideTmpDir(tempDir.str()); |
|
41 |
|
Environment env; |
|
42 |
|
|
|
43 |
|
CHECK(!Traverser({ tempDir }, "", env.getConfig(), handler).search()); |
|
44 |
|
CHECK(paths.size() == 0); |
|
45 |
|
CHECK(Traverser({ file }, "", env.getConfig(), handler).search()); |
|
46 |
|
CHECK(paths.size() == 1); |
|
47 |
|
} |
|
48 |
|
|
26 |
49 |
TEST_CASE("Traverser accounts for lang attribute", "[tooling][traverser]") |
TEST_CASE("Traverser accounts for lang attribute", "[tooling][traverser]") |
27 |
50 |
{ |
{ |
28 |
51 |
TempDir tempDir("config"); |
TempDir tempDir("config"); |