From 15c53f7563087d86db0a75ece9cb3ab8e2b0d450 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Mon, 2 Nov 2015 10:58:55 -0800 Subject: [PATCH] Fix ReferenceImages resolving for `buck test` Reviewed By: nicklockwood Differential Revision: D2605694 fb-gh-sync-id: 90e65974c73405d482476c9eb2ddf1377f9a1401 --- Libraries/RCTTest/RCTTestRunner.h | 13 +++++++------ Libraries/RCTTest/RCTTestRunner.m | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Libraries/RCTTest/RCTTestRunner.h b/Libraries/RCTTest/RCTTestRunner.h index 72a2b3127..efde32f21 100644 --- a/Libraries/RCTTest/RCTTestRunner.h +++ b/Libraries/RCTTest/RCTTestRunner.h @@ -9,12 +9,13 @@ #import +#ifndef FB_REFERENCE_IMAGE_DIR +#define FB_REFERENCE_IMAGE_DIR "" +#endif + /** - * Use the RCTInitRunnerForApp macro for typical usage. - * - * Add this to your test target's gcc preprocessor macros: - * - * FB_REFERENCE_IMAGE_DIR="\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\"" + * Use the RCTInitRunnerForApp macro for typical usage. See FBSnapshotTestCase.h for more information + * on how to configure the snapshotting system. */ #define RCTInitRunnerForApp(app__, moduleProvider__) \ [[RCTTestRunner alloc] initWithApp:(app__) \ @@ -31,7 +32,7 @@ * macro instead of calling this directly. * * @param app The path to the app bundle without suffixes, e.g. IntegrationTests/IntegrationTestsApp - * @param referenceDirectory The path for snapshot references images. The RCTInitRunnerForApp macro uses FB_REFERENCE_IMAGE_DIR for this automatically. + * @param referenceDirectory The path for snapshot references images. * @param block A block that returns an array of extra modules to be used by the test runner. */ - (instancetype)initWithApp:(NSString *)app diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index 0da2c8388..ea67bbe36 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -34,6 +34,9 @@ static const NSTimeInterval kTestTeardownTimeoutSeconds = 30; RCTAssertParam(referenceDirectory); if ((self = [super init])) { + if (!referenceDirectory.length) { + referenceDirectory = [[NSBundle bundleForClass:self.class].resourcePath stringByAppendingPathComponent:@"ReferenceImages"]; + } NSString *sanitizedAppName = [app stringByReplacingOccurrencesOfString:@"/" withString:@"-"]; sanitizedAppName = [sanitizedAppName stringByReplacingOccurrencesOfString:@"\\" withString:@"-"];