Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: tests/skia_test.cpp

Issue 16098011: Fix bug in setting directories for tests. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comments Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/Test.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/skia_test.cpp
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index 238252d7377629e19f193b1f7de93d945fa75b0b..8cae6560893fcd6224f8bb5541a25d1db708983f 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -112,34 +112,6 @@ private:
bool fAllowThreaded;
};
-static const char* make_canonical_dir_path(const char* path, SkString* storage) {
- if (path) {
- // clean it up so it always has a trailing searator
- size_t len = strlen(path);
- if (0 == len) {
- path = NULL;
- } else if (SkPATH_SEPARATOR != path[len - 1]) {
- // resize to len + 1, to make room for searator
- storage->set(path, len + 1);
- storage->writable_str()[len] = SkPATH_SEPARATOR;
- path = storage->c_str();
- }
- }
- return path;
-}
-
-static SkString gTmpDir;
-
-const SkString& Test::GetTmpDir() {
- return gTmpDir;
-}
-
-static SkString gResourcePath;
-
-const SkString& Test::GetResourcePath() {
- return gResourcePath;
-}
-
DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n" \
"Multiple matches may be separated by spaces.\n" \
"~ causes a matching test to always be skipped\n" \
@@ -156,6 +128,16 @@ DEFINE_bool2(verbose, v, false, "enable verbose output.");
DEFINE_int32(threads, SkThreadPool::kThreadPerCore,
"Run threadsafe tests on a threadpool with this many threads.");
+SkString Test::GetTmpDir() {
+ const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0];
+ return SkString(tmpDir);
+}
+
+SkString Test::GetResourcePath() {
+ const char* resourcePath = FLAGS_resourcePath.isEmpty() ? NULL : FLAGS_resourcePath[0];
+ return SkString(resourcePath);
+}
+
// Deletes self when run.
class SkTestRunnable : public SkRunnable {
public:
@@ -218,13 +200,6 @@ int tool_main(int argc, char** argv) {
SkCommandLineFlags::SetUsage("");
SkCommandLineFlags::Parse(argc, argv);
- if (!FLAGS_tmpDir.isEmpty()) {
- make_canonical_dir_path(FLAGS_tmpDir[0], &gTmpDir);
- }
- if (!FLAGS_resourcePath.isEmpty()) {
- make_canonical_dir_path(FLAGS_resourcePath[0], &gResourcePath);
- }
-
#if SK_ENABLE_INST_COUNT
gPrintInstCount = true;
#endif
@@ -239,11 +214,13 @@ int tool_main(int argc, char** argv) {
header.appendf(" %s", FLAGS_match[index]);
}
}
- if (!gTmpDir.isEmpty()) {
- header.appendf(" --tmpDir %s", gTmpDir.c_str());
+ SkString tmpDir = Test::GetTmpDir();
+ if (!tmpDir.isEmpty()) {
+ header.appendf(" --tmpDir %s", tmpDir.c_str());
}
- if (!gResourcePath.isEmpty()) {
- header.appendf(" --resourcePath %s", gResourcePath.c_str());
+ SkString resourcePath = Test::GetResourcePath();
+ if (!resourcePath.isEmpty()) {
+ header.appendf(" --resourcePath %s", resourcePath.c_str());
}
#ifdef SK_DEBUG
header.append(" SK_DEBUG");
« no previous file with comments | « tests/Test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698