Permalink
Browse files

Allow test to be run from repo root/clone dir

  • Loading branch information...
1 parent 62e62a1 commit 4ff45611e84ba1689afd2fcae4ca8104802c9612 @fictorial fictorial committed Apr 19, 2010
Showing with 14 additions and 6 deletions.
  1. +14 −6 test/test.js
View
@@ -1713,12 +1713,20 @@ function testLargeGetSet() {
function testStoreAnImage(callback) {
showTestBanner("testStoreAnImage");
- var fileContents = fs.readFileSync('sample.png', 'binary');
-
- if (!fileContents || fileContents.length == 0) {
- sys.error("\nFailed to load sample.png -- skipping binary-safety test.\n");
- testSUBSCRIBEandPUBLISH();
- return;
+ var paths = [ "sample.png", "test/sample.png" ];
+ var path = paths.shift();
+ while (true) {
+ try {
+ var fileContents = fs.readFileSync(path, 'binary');
+ break;
+ } catch (e) {
+ path = paths.shift();
+ if (!path) {
+ sys.error("\nFailed to load sample.png -- skipping binary-safety test.\n");
+ testSUBSCRIBEandPUBLISH();
+ return;
+ }
+ }
}
// You can pass Buffer objects to the client's methods.

0 comments on commit 4ff4561

Please sign in to comment.