[asterisk-commits] mnicholson: testsuite/asterisk/trunk r708 - in /asterisk/trunk/asttest: lib/ ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 5 10:03:03 CDT 2010
Author: mnicholson
Date: Thu Aug 5 10:02:59 2010
New Revision: 708
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=708
Log:
Make asttest automatically skip directories that start with '_'. Also added a self test for this.
Added:
asterisk/trunk/asttest/self-tests/test_skip/tests/.hidden_skip/
asterisk/trunk/asttest/self-tests/test_skip/tests/.hidden_skip/test.lua (with props)
asterisk/trunk/asttest/self-tests/test_skip/tests/_auto_skip/
asterisk/trunk/asttest/self-tests/test_skip/tests/_auto_skip/test.lua (with props)
Modified:
asterisk/trunk/asttest/lib/testutils.c
asterisk/trunk/asttest/self-tests/test_skip/test.lua
Modified: asterisk/trunk/asttest/lib/testutils.c
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/lib/testutils.c?view=diff&rev=708&r1=707&r2=708
==============================================================================
--- asterisk/trunk/asttest/lib/testutils.c (original)
+++ asterisk/trunk/asttest/lib/testutils.c Thu Aug 5 10:02:59 2010
@@ -239,17 +239,27 @@
return S_ISDIR(st.st_mode);
}
-static int ignored_dir(const char *dir) {
- char *dir_dup = strdup(dir); /* dup the string as basename may modify it */
- char *base_dir = basename(dir_dup);
- int res = 0;
-
- if (base_dir[0] == '.') {
- res = 1;
- }
-
- free(dir_dup);
- return res;
+static int ignored_dir(struct testsuite *ts, const char *test_name, const char *full_path) {
+ if (!test_name || strlen(test_name) < 1) {
+ return 1;
+ }
+
+ if (!is_directory(full_path)) {
+ return 1;
+ }
+
+ if (test_name[0] == '.') {
+ /* skip hidden directories */
+ return 1;
+ } else if (test_name[0] == '_') {
+ /* skip directories starting with '_' and log the skippage */
+ ts_log(ts, test_name, "automatically skipping test because test name starts with '_'\n");
+ print_test_name(ts, test_name);
+ print_test_result(ts_skip(ts, test_name));
+ return 1;
+ }
+
+ return 0;
}
int process_single_test(struct asttest_opts *opts) {
@@ -290,7 +300,7 @@
while ((ent = readdir(main_dir))) {
snprintf(full_path, sizeof(full_path), "%s/%s", path, ent->d_name);
- if (is_directory(full_path) && !ignored_dir(full_path)) {
+ if (!ignored_dir(&ts, ent->d_name, full_path)) {
print_test_name(&ts, ent->d_name);
result = run_test(&ts, ent->d_name, full_path);
print_test_result(result);
Modified: asterisk/trunk/asttest/self-tests/test_skip/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/self-tests/test_skip/test.lua?view=diff&rev=708&r1=707&r2=708
==============================================================================
--- asterisk/trunk/asttest/self-tests/test_skip/test.lua (original)
+++ asterisk/trunk/asttest/self-tests/test_skip/test.lua Thu Aug 5 10:02:59 2010
@@ -5,4 +5,6 @@
a = asttest.run("tests")
fail_if(a.results["standard_skip"] ~= "skip", "skip test failed")
+fail_if(a.results["_auto_skip"] ~= "skip", "_auto_skip was not automatically skipped")
+fail_if(a.results[".hidden_skip"] ~= nil, ".hidden_skip was not automatically and silently skipped")
Added: asterisk/trunk/asttest/self-tests/test_skip/tests/.hidden_skip/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/self-tests/test_skip/tests/.hidden_skip/test.lua?view=auto&rev=708
==============================================================================
--- asterisk/trunk/asttest/self-tests/test_skip/tests/.hidden_skip/test.lua (added)
+++ asterisk/trunk/asttest/self-tests/test_skip/tests/.hidden_skip/test.lua Thu Aug 5 10:02:59 2010
@@ -1,0 +1,2 @@
+-- test skip
+fail("this test should be silently and automatically skipped")
Propchange: asterisk/trunk/asttest/self-tests/test_skip/tests/.hidden_skip/test.lua
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/asttest/self-tests/test_skip/tests/.hidden_skip/test.lua
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/asttest/self-tests/test_skip/tests/.hidden_skip/test.lua
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: asterisk/trunk/asttest/self-tests/test_skip/tests/_auto_skip/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/self-tests/test_skip/tests/_auto_skip/test.lua?view=auto&rev=708
==============================================================================
--- asterisk/trunk/asttest/self-tests/test_skip/tests/_auto_skip/test.lua (added)
+++ asterisk/trunk/asttest/self-tests/test_skip/tests/_auto_skip/test.lua Thu Aug 5 10:02:59 2010
@@ -1,0 +1,2 @@
+-- test skip
+fail("this test should be automatically skipped")
Propchange: asterisk/trunk/asttest/self-tests/test_skip/tests/_auto_skip/test.lua
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/asttest/self-tests/test_skip/tests/_auto_skip/test.lua
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/asttest/self-tests/test_skip/tests/_auto_skip/test.lua
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the asterisk-commits
mailing list