Add symbolication support to DevServerHelper

Reviewed By: javache

Differential Revision: D4929829

fbshipit-source-id: 6babdb868d27c1b0da0332cc6aee38502f35704f
This commit is contained in:
Gerald Monaco
2017-04-25 11:01:36 -07:00
committed by Facebook Github Bot
parent 57b0039ce1
commit 102f990861
4 changed files with 260 additions and 20 deletions

View File

@@ -22,6 +22,7 @@ rn_robolectric_test(
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/devsupport:devsupport"),
react_native_target("java/com/facebook/react/devsupport:interfaces"),
react_native_tests_target("java/com/facebook/react/bridge:testhelpers"),
],
)

View File

@@ -0,0 +1,53 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.react.devsupport;
import com.facebook.react.devsupport.interfaces.StackFrame;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.fest.assertions.api.Assertions.failBecauseExceptionWasNotThrown;
@RunWith(RobolectricTestRunner.class)
public class StackTraceHelperTest {
@Test
public void testParseStackFrameWithMethod() {
final StackFrame frame = StackTraceHelper.convertJsStackTrace(
"render@Test.bundle:1:2000")[0];
assertThat(frame.getMethod()).isEqualTo("render");
assertThat(frame.getFileName()).isEqualTo("Test.bundle");
assertThat(frame.getLine()).isEqualTo(1);
assertThat(frame.getColumn()).isEqualTo(2000);
}
@Test
public void testParseStackFrameWithoutMethod() {
final StackFrame frame = StackTraceHelper.convertJsStackTrace(
"Test.bundle:1:2000")[0];
assertThat(frame.getMethod()).isEqualTo("(unknown)");
assertThat(frame.getFileName()).isEqualTo("Test.bundle");
assertThat(frame.getLine()).isEqualTo(1);
assertThat(frame.getColumn()).isEqualTo(2000);
}
@Test
public void testParseStackFrameWithInvalidFrame() {
try {
StackTraceHelper.convertJsStackTrace("Test.bundle:ten:twenty");
failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
} catch (Exception e) {
assertThat(e).isInstanceOf(IllegalArgumentException.class);
}
}
}