Update JSStackTrace to support segment ids

Reviewed By: jeanlauliac

Differential Revision: D13504222

fbshipit-source-id: ffda11697838ea03d15a28704d401e1051058b49
This commit is contained in:
Alex Dvornikov
2018-12-18 16:23:39 -08:00
committed by Facebook Github Bot
parent 0407d8c8fd
commit ae121690eb
3 changed files with 70 additions and 9 deletions
@@ -0,0 +1,19 @@
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_target", "rn_robolectric_test")
rn_robolectric_test(
name = "util",
srcs = glob(["**/*.java"]),
visibility = [
"PUBLIC",
],
deps = [
react_native_dep("libraries/fbcore/src/test/java/com/facebook/powermock:powermock"),
react_native_dep("third-party/java/fest:fest"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_dep("third-party/java/junit:junit"),
react_native_dep("third-party/java/mockito:mockito"),
react_native_dep("third-party/java/robolectric3/robolectric:robolectric"),
react_native_target("java/com/facebook/react/util:util"),
react_native_target("java/com/facebook/react/bridge:bridge"),
],
)
@@ -0,0 +1,40 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.util;
import org.junit.Test;
import org.junit.Assert;
import com.facebook.react.bridge.JavaOnlyMap;
import com.facebook.react.bridge.JavaOnlyArray;
public class JSStackTraceTest {
@Test
public void testSymbolication() {
JavaOnlyArray values = JavaOnlyArray.of(
JavaOnlyMap.of("methodName", "method_from_bundle", "column", 11, "lineNumber", 7, "file", "Fb4aBundle.js"),
JavaOnlyMap.of("methodName", "method_from_ram_bundle", "column", 13, "lineNumber", 18, "file", "199.js"),
JavaOnlyMap.of("methodName", "method_from_ram_bundle_with_address", "column", 13, "lineNumber", 18, "file", "address at 199.js"),
JavaOnlyMap.of("methodName", "method_from_segment", "column", 18, "lineNumber", 9, "file", "seg-1.js"),
JavaOnlyMap.of("methodName", "method_from_segment_with_address", "column", 18, "lineNumber", 9, "file", "address at seg-1.js"),
JavaOnlyMap.of("methodName", "method_from_ram_segment", "column", 20, "lineNumber", 10, "file", "seg-3_198.js"),
JavaOnlyMap.of("methodName", "method_from_ram_segment_with_address", "column", 20, "lineNumber", 10, "file", "address at seg-3_198.js")
);
String message = JSStackTrace.format("Error", values);
Assert.assertEquals(message, "Error, stack:\n"
+ "method_from_bundle@7:11\n"
+ "method_from_ram_bundle@199.js:18:13\n"
+ "method_from_ram_bundle_with_address@199.js:18:13\n"
+ "method_from_segment@seg-1.js:9:18\n"
+ "method_from_segment_with_address@seg-1.js:9:18\n"
+ "method_from_ram_segment@seg-3_198.js:10:20\n"
+ "method_from_ram_segment_with_address@seg-3_198.js:10:20\n"
);
}
}