diff options
Diffstat (limited to 'tests/wildcard')
-rw-r--r-- | tests/wildcard/driver.cxx | 32 | ||||
-rw-r--r-- | tests/wildcard/testscript | 178 |
2 files changed, 207 insertions, 3 deletions
diff --git a/tests/wildcard/driver.cxx b/tests/wildcard/driver.cxx index b3aae62..5744969 100644 --- a/tests/wildcard/driver.cxx +++ b/tests/wildcard/driver.cxx @@ -39,7 +39,10 @@ int _CRT_glob = 0; // Search for paths matching the pattern in the directory specified (absent // directory means the current one). Print the matching canonicalized paths // to STDOUT in the ascending order. Succeed if at least one matching path -// is found. Note that this option must go first in the command line, +// is found. Note that this option must go first in the command line. +// +// Also note that the driver excludes from search file system entries which +// names start from dot, unless the pattern explicitly matches them. // // -n // Do not sort paths found. @@ -87,9 +90,32 @@ try assert (i == argc); // All args parsed, vector<path> paths; - auto add = [&paths] (path&& p) -> bool + auto add = + [&paths, &start] (path&& p, const std::string& pt, bool interim) -> bool { - paths.emplace_back (move (p.canonicalize ())); + bool pd (!pt.empty () && pt[0] == '.'); // Dot-started pattern. + + const path& fp (!p.empty () + ? p + : path_cast<path> (!start.empty () + ? start + : path::current_directory ())); + + const string& s (fp.leaf ().string ()); + assert (!s.empty ()); + + bool ld (s[0] == '.'); // Dot-started leaf. + + // Skip dot-started names if pattern is not dot-started. + // + bool skip (ld && !pd); + + if (interim) + return !skip; + + if (!skip) + paths.emplace_back (move (p.canonicalize ())); + return true; }; diff --git a/tests/wildcard/testscript b/tests/wildcard/testscript index 4a6c532..48159e2 100644 --- a/tests/wildcard/testscript +++ b/tests/wildcard/testscript @@ -388,4 +388,182 @@ } } } + + : dot-started + : + { + +mkdir -p z/.z/.z z/z a/.z .a/.z + +touch z/.z.cxx z/z.cxx z/.z/.z.cxx z/.z/z.cxx z/z/.z.cxx z/z/z.cxx \ + a/z.cxx a/.z.cxx .a/z.cxx .a/.z.cxx + + wd=../../.. + + : recursive + : + { + : simple + : + { + : file + : + $* *z**.cxx $wd >>/EOO + a/z.cxx + z/z.cxx + z/z/z.cxx + EOO + + : dot-leading-file + : + $* .z**.cxx $wd >>/EOO + a/.z.cxx + z/.z.cxx + z/z/.z.cxx + EOO + + : dir + : + $* **z/ $wd >>/EOO + z/ + z/z/ + EOO + + : dot-leading-dir + : + $* .**z/ $wd >>/EOO + a/.z/ + z/.z/ + EOO + } + + : z-compound + : + { + : not-dot-leading + : + $* **z/*z.cxx $wd >>/EOO + z/z.cxx + z/z/z.cxx + EOO + + : dot-leading + : + $* .z**/*z.cxx $wd >>/EOO + z/.z/z.cxx + EOO + } + + : compound + : + { + : not-dot-leading + : + $* **/*z.cxx $wd >>/EOO + a/z.cxx + z/z.cxx + z/z/z.cxx + EOO + + : dot-leading + : + $* .**/*z.cxx $wd >>/EOO + .a/z.cxx + z/.z/z.cxx + EOO + } + + : self + : + { + : not-dot-leading + : + $* *z***/*z.cxx $wd/z >>/EOO + z.cxx + z/z.cxx + EOO + + : dot-leading + : + $* .z***/*z.cxx $wd/z >>/EOO + .z/z.cxx + EOO + } + } + + : immediate + : + { + : simple + : + { + : file + : + $* *z*.cxx $wd/z >>/EOO + z.cxx + EOO + + : dot-leading-file + : + $* .z*.cxx $wd/z >>/EOO + .z.cxx + EOO + + : file-dot-leading-start + : + $* *z*.cxx $wd/z/.z >>/EOO + z.cxx + EOO + + : dot-leading-file-dot-leading-start + : + $* .z*.cxx $wd/z/.z >>/EOO + .z.cxx + EOO + + : dir + : + $* *z/ $wd/ >>/EOO + z/ + EOO + + : dot-leading-dir + : + $* .*z/ $wd/z >>/EOO + .z/ + EOO + } + + : z-compound + : + { + : not-dot-leading + : + $* *z/*z.cxx $wd/z >>/EOO + z/z.cxx + EOO + + : dot-leading + : + $* .z*/*z.cxx $wd/z >>/EOO + .z/z.cxx + EOO + } + + : compound + : + { + : not-dot-leading + : + $* */*z.cxx $wd >>/EOO + a/z.cxx + z/z.cxx + EOO + + : dot-leading + : + $* .*/*z.cxx $wd >>/EOO + .a/z.cxx + EOO + } + } + } } |