[Test or Build?] How to add dummy files and dirs to a test?

Dear all, I'm putting the finishing touches to a Posix-conformant boost::glob function that I'd like to submit to Boost (assuming there's some interest). However, before I do so, I'd like to get the regression tests running smoothly. Currently my 'test' directory contains: $ ls .oo* foo* foo1bar foo bar foo!bar foo]bar foo*bar foocbar foo.hpp fooabar foo-bar foo?bar foo{bar foo\bar foo.cpp .oobar foo^bar foo,bar foo[bar foo}bar foobbar foo.cxx All 20 of these files have zero size; the idea is to test boost::glob's ability to find matches. However, I'd rather not have them as part of the library. How do I get the test framework to create them for me before running a test? Regards, Angus

"Angus Leeming" <angus.leeming@btopenworld.com> wrote in message news:cj1nmh$jbp$1@sea.gmane.org...
Dear all,
I'm putting the finishing touches to a Posix-conformant boost::glob function that I'd like to submit to Boost (assuming there's some interest). However, before I do so, I'd like to get the regression tests running smoothly.
Currently my 'test' directory contains: $ ls .oo* foo* foo1bar foo bar foo!bar foo]bar foo*bar foocbar foo.hpp fooabar foo-bar foo?bar foo{bar foo\bar foo.cpp .oobar foo^bar foo,bar foo[bar foo}bar foobbar foo.cxx
All 20 of these files have zero size; the idea is to test boost::glob's ability to find matches. However, I'd rather not have them as part of the library. How do I get the test framework to create them for me before running a test?
Regards, Angus
Boost.Test does not have an ability to create bunch of files for testing. Why don't you create them yourself in your test program? If you see something that worth reusing we could discuss it. Gennadiy.

Gennadiy Rozental wrote:
All 20 of these files have zero size; the idea is to test boost::glob's ability to find matches. However, I'd rather not have them as part of the library. How do I get the test framework to create them for me before running a test?
Regards, Angus
Boost.Test does not have an ability to create bunch of files for testing.
Ok. My misunderstanding.
Why don't you create them yourself in your test program?
Sure, I could do that... done. Angus

From: Angus Leeming <angus.leeming@btopenworld.com>
Currently my 'test' directory contains: $ ls .oo* foo* foo1bar foo bar foo!bar foo]bar foo*bar foocbar foo.hpp fooabar foo-bar foo?bar foo{bar foo\bar foo.cpp .oobar foo^bar foo,bar foo[bar foo}bar foobbar foo.cxx
All 20 of these files have zero size; the idea is to test boost::glob's ability to find matches. However, I'd rather not have them as part of the library. How do I get the test framework to create them for me before running a test?
I don't know how to do what you ask, but you need more cases than shown. You should test with special characters at the start, middle, and end of the filename. You might even test with them in those positions of the suffix and the rest of the filename. Also, you should test with longer filenames and with multiple suffixes. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;

Rob Stewart wrote:
From: Angus Leeming <angus.leeming@btopenworld.com>
Currently my 'test' directory contains: $ ls .oo* foo* foo1bar foo bar foo!bar foo]bar foo*bar foocbar foo.hpp fooabar foo-bar foo?bar foo{bar foo\bar foo.cpp .oobar foo^bar foo,bar foo[bar foo}bar foobbar foo.cxx
All 20 of these files have zero size; the idea is to test boost::glob's ability to find matches. However, I'd rather not have them as part of the library. How do I get the test framework to create them for me before running a test?
I don't know how to do what you ask, but you need more cases than shown. You should test with special characters at the start, middle, and end of the filename. You might even test with them in those positions of the suffix and the rest of the filename. Also, you should test with longer filenames and with multiple suffixes.
I know, but it's a start. The real work is actually done by Boost.Filesystem and Boost.Regex. All I do is transform the glob into an equivalent regex using Boost.Spirit and then loop recursively over the "pattern tree" to build up the list of matching files. I think I've got all the corner cases covered, but the test suite will evolve... Regards, Angus PS, here's the test at the moment. "succeeded" means that the expected number of matches were found. $ ls -a ../../../bin/boost/libs/glob/test/test_glob.test/gcc/debug/glob_test_dir/ . fooabar foo-bar foo?bar foo{bar foobbar foo.cxx .. foo^bar foo,bar foo[bar foo}bar foocbar foo.hpp foo1bar foo bar foo!bar foo]bar foo*bar foo.cpp .oobar $ ../../../bin/boost/libs/glob/test/test_glob.test/gcc/debug/test_glob Matching glob_te*/fooabar succeeded. 1 match found. Matching glob_te*/foo bar succeeded. 1 match found. Matching glob_te*/foo?bar succeeded. 15 matches found. Matching glob_te*/foo*bar succeeded. 15 matches found. Matching glob_te*/?oo?bar succeeded. 15 matches found. Matching glob_te*/*bar succeeded. 15 matches found. Matching glob_te*/.*bar succeeded. 1 match found. Matching glob_te*/foo[[:alpha:]]bar succeeded. 3 matches found. Matching glob_te*/foo[!]bar succeeded. 0 matches found. Matching glob_te*/foo[\!]bar succeeded. 1 match found. Matching glob_te*/foo[!!]bar succeeded. 14 matches found. Matching glob_te*/foo[]]bar succeeded. 1 match found. Matching glob_te*/foo[!]]bar succeeded. 14 matches found. Matching glob_te*/foo[a]]bar succeeded. 0 matches found. Matching glob_te*/foo[]a]bar succeeded. 2 matches found. Matching glob_te*/foo[^]bar succeeded. 1 match found. Matching glob_te*/foo[\^]bar succeeded. 1 match found. Matching glob_te*/foo[!^]bar succeeded. 14 matches found. Matching glob_te*/foo[!\^]bar succeeded. 14 matches found. Matching glob_te*/foo[*]bar succeeded. 1 match found. Matching glob_te*/foo[\*]bar succeeded. 1 match found. Matching glob_te*/foo[{]bar succeeded. 1 match found. Matching glob_te*/foo[a-]bar succeeded. 2 matches found. Matching glob_te*/foo[a-c]bar succeeded. 3 matches found. Matching glob_te*/foo.{c{pp,xx},hpp} succeeded. 3 matches found. Matching glob_te*/foo.{c*,hpp} succeeded. 3 matches found. *** No errors detected

From: Angus Leeming <angus.leeming@btopenworld.com>
Rob Stewart wrote:
From: Angus Leeming <angus.leeming@btopenworld.com>
Currently my 'test' directory contains: $ ls .oo* foo* foo1bar foo bar foo!bar foo]bar foo*bar foocbar foo.hpp fooabar foo-bar foo?bar foo{bar foo\bar foo.cpp .oobar foo^bar foo,bar foo[bar foo}bar foobbar foo.cxx
All 20 of these files have zero size; the idea is to test boost::glob's ability to find matches. However, I'd rather not have them as part of the library. How do I get the test framework to create them for me before running a test?
I don't know how to do what you ask, but you need more cases than shown. You should test with special characters at the start, middle, and end of the filename. You might even test with them in those positions of the suffix and the rest of the filename. Also, you should test with longer filenames and with multiple suffixes.
I know, but it's a start.
No argument there.
The real work is actually done by Boost.Filesystem and Boost.Regex. All I do is transform the glob into an equivalent regex using Boost.Spirit and then loop recursively over the "pattern tree" to build up the list of matching files. I think I've got all the corner cases covered, but the test suite will evolve...
Regards, Angus
PS, here's the test at the moment. "succeeded" means that the expected number of matches were found.
$ ls -a ../../../bin/boost/libs/glob/test/test_glob.test/gcc/debug/glob_test_dir/ . fooabar foo-bar foo?bar foo{bar foobbar foo.cxx .. foo^bar foo,bar foo[bar foo}bar foocbar foo.hpp foo1bar foo bar foo!bar foo]bar foo*bar foo.cpp .oobar
$ ../../../bin/boost/libs/glob/test/test_glob.test/gcc/debug/test_glob Matching glob_te*/fooabar succeeded. 1 match found. Matching glob_te*/foo bar succeeded. 1 match found. Matching glob_te*/foo?bar succeeded. 15 matches found. Matching glob_te*/foo*bar succeeded. 15 matches found. Matching glob_te*/?oo?bar succeeded. 15 matches found. Matching glob_te*/*bar succeeded. 15 matches found. Matching glob_te*/.*bar succeeded. 1 match found. Matching glob_te*/foo[[:alpha:]]bar succeeded. 3 matches found. Matching glob_te*/foo[!]bar succeeded. 0 matches found. Matching glob_te*/foo[\!]bar succeeded. 1 match found. Matching glob_te*/foo[!!]bar succeeded. 14 matches found. Matching glob_te*/foo[]]bar succeeded. 1 match found. Matching glob_te*/foo[!]]bar succeeded. 14 matches found. Matching glob_te*/foo[a]]bar succeeded. 0 matches found. Matching glob_te*/foo[]a]bar succeeded. 2 matches found. Matching glob_te*/foo[^]bar succeeded. 1 match found. Matching glob_te*/foo[\^]bar succeeded. 1 match found. Matching glob_te*/foo[!^]bar succeeded. 14 matches found. Matching glob_te*/foo[!\^]bar succeeded. 14 matches found. Matching glob_te*/foo[*]bar succeeded. 1 match found. Matching glob_te*/foo[\*]bar succeeded. 1 match found. Matching glob_te*/foo[{]bar succeeded. 1 match found. Matching glob_te*/foo[a-]bar succeeded. 2 matches found. Matching glob_te*/foo[a-c]bar succeeded. 3 matches found. Matching glob_te*/foo.{c{pp,xx},hpp} succeeded. 3 matches found. Matching glob_te*/foo.{c*,hpp} succeeded. 3 matches found.
*** No errors detected
Looks great! -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;

Angus Leeming wrote:
I know, but it's a start.
The real work is actually done by Boost.Filesystem and Boost.Regex. All I do is transform the glob into an equivalent regex using Boost.Spirit and then loop recursively over the "pattern tree" to build up the list of matching files.
Then, why do you need real files for testing? If you're creating Boost.Regex from glob pattern, you can test the created regex on strings, assuming Boost.Filesystem is not buggy and returns the right filenames ;-) - Volodya

From: Vladimir Prus <ghost@cs.msu.su>
Angus Leeming wrote:
The real work is actually done by Boost.Filesystem and Boost.Regex. All I do is transform the glob into an equivalent regex using Boost.Spirit and then loop recursively over the "pattern tree" to build up the list of matching files.
Then, why do you need real files for testing? If you're creating Boost.Regex from glob pattern, you can test the created regex on strings, assuming Boost.Filesystem is not buggy and returns the right filenames ;-)
What if his code doesn't use Boost.Regex or Boost.Filesystem correctly now or in the future? The tests should cover all of his code, shouldn't they? -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;
participants (4)
-
Angus Leeming
-
Gennadiy Rozental
-
Rob Stewart
-
Vladimir Prus