}
for (int i = 0; i < FLAGS_readPath.count(); i++) {
- if (strlen(FLAGS_readPath[i]) < 1) {
+ const char* readPath = FLAGS_readPath[i];
+ if (strlen(readPath) < 1) {
break;
}
- SkOSFile::Iter iter(FLAGS_readPath[i]);
- SkString filename;
- if (iter.next(&filename)) {
- SkString directory(FLAGS_readPath[i]);
- append_path_separator_if_necessary(&directory);
- do {
- SkString fullname(directory);
- fullname.append(filename);
+ if (sk_isdir(readPath)) {
+ const char* dir = readPath;
+ SkOSFile::Iter iter(dir);
+ SkString filename;
+ while (iter.next(&filename)) {
+ SkString fullname = SkOSPath::SkPathJoin(dir, filename.c_str());
decodeFileAndWrite(fullname.c_str(), outDirPtr);
- } while (iter.next(&filename));
- } else {
- decodeFileAndWrite(FLAGS_readPath[i], outDirPtr);
+ }
+ } else if (sk_exists(readPath)) {
+ decodeFileAndWrite(readPath, outDirPtr);
}
}
import os
import subprocess
import sys
+import tempfile
class BinaryNotFoundException(Exception):
def __str__ (self):
# TODO(scroggo): Add a test that compares expectations and image files that
# are known to NOT match, and make sure it returns an error.
+ # Generate an expectations file from an empty directory.
+ empty_dir = tempfile.mkdtemp()
+ expectations_path = os.path.join(file_dir, "skimage", "output-actual",
+ "empty-dir", "expectations.json")
+ subprocess.check_call([skimage_binary, "--readPath", empty_dir,
+ "--createExpectationsPath", expectations_path])
+ golden_expectations = os.path.join(file_dir, "skimage", "output-expected",
+ "empty-dir", "expectations.json")
+ DieIfFilesMismatch(expected=golden_expectations, actual=expectations_path)
+ os.rmdir(empty_dir)
+
+ # Generate an expectations file from a nonexistent directory.
+ expectations_path = os.path.join(file_dir, "skimage", "output-actual",
+ "nonexistent-dir", "expectations.json")
+ subprocess.check_call([skimage_binary, "--readPath", "/nonexistent/dir",
+ "--createExpectationsPath", expectations_path])
+ golden_expectations = os.path.join(file_dir, "skimage", "output-expected",
+ "nonexistent-dir", "expectations.json")
+ DieIfFilesMismatch(expected=golden_expectations, actual=expectations_path)
+
# Done with all tests.
print "Self tests succeeded!"