From 305636884f769dcced0e3d4a8974b26a0715296b Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Tue, 2 May 2023 02:34:44 -0700 Subject: [PATCH] RN: Make `hermes-inspector-msggen` tests visible for jest matcher (#37131) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37131 Changelog: [Internal] Looks like all this time jest was not running these tests, because their file names are not matching the https://www.internalfb.com/code/fbsource/[1e8a1b307ffd]/xplat/js/react-native-github/jest.config.js?lines=30 - Renamed tests to kebab-case - Some of them were failing, now updated Differential Revision: D45368748 fbshipit-source-id: b37ddd6c614badacf4be4d32e8dfe836a880fb33 --- .../{CommandTest.js => command-test.js} | 0 .../__tests__/{EventTest.js => event-test.js} | 0 .../__tests__/{GraphTest.js => graph-test.js} | 16 +++++++++------- ...HeaderWriterTest.js => header-writer-test.js} | 4 ++++ ...iterTest.js => implementation-writer-test.js} | 0 .../{PropertyTest.js => property-test.js} | 0 .../__tests__/{TypeTest.js => type-test.js} | 0 7 files changed, 13 insertions(+), 7 deletions(-) rename packages/hermes-inspector-msggen/__tests__/{CommandTest.js => command-test.js} (100%) rename packages/hermes-inspector-msggen/__tests__/{EventTest.js => event-test.js} (100%) rename packages/hermes-inspector-msggen/__tests__/{GraphTest.js => graph-test.js} (84%) rename packages/hermes-inspector-msggen/__tests__/{HeaderWriterTest.js => header-writer-test.js} (95%) rename packages/hermes-inspector-msggen/__tests__/{ImplementationWriterTest.js => implementation-writer-test.js} (100%) rename packages/hermes-inspector-msggen/__tests__/{PropertyTest.js => property-test.js} (100%) rename packages/hermes-inspector-msggen/__tests__/{TypeTest.js => type-test.js} (100%) diff --git a/packages/hermes-inspector-msggen/__tests__/CommandTest.js b/packages/hermes-inspector-msggen/__tests__/command-test.js similarity index 100% rename from packages/hermes-inspector-msggen/__tests__/CommandTest.js rename to packages/hermes-inspector-msggen/__tests__/command-test.js diff --git a/packages/hermes-inspector-msggen/__tests__/EventTest.js b/packages/hermes-inspector-msggen/__tests__/event-test.js similarity index 100% rename from packages/hermes-inspector-msggen/__tests__/EventTest.js rename to packages/hermes-inspector-msggen/__tests__/event-test.js diff --git a/packages/hermes-inspector-msggen/__tests__/GraphTest.js b/packages/hermes-inspector-msggen/__tests__/graph-test.js similarity index 84% rename from packages/hermes-inspector-msggen/__tests__/GraphTest.js rename to packages/hermes-inspector-msggen/__tests__/graph-test.js index b890c050ea8905..5d4043b80e0017 100644 --- a/packages/hermes-inspector-msggen/__tests__/GraphTest.js +++ b/packages/hermes-inspector-msggen/__tests__/graph-test.js @@ -25,8 +25,8 @@ beforeEach(() => { // checks id1 occurs after id2 in arr function expectOccursAfter(arr, id1, id2) { - let idx1 = arr.indexOf(id1); - let idx2 = arr.indexOf(id2); + const idx1 = arr.indexOf(id1); + const idx2 = arr.indexOf(id2); expect(idx1).not.toBe(-1); expect(idx2).not.toBe(-1); @@ -35,7 +35,9 @@ function expectOccursAfter(arr, id1, id2) { test('detects cycle', () => { graph.addEdge('C2', 'A1'); - expect(() => graph.traverse(['A2'])).toThrow(/^Not a DAG/); + + const {cycles} = graph.traverse(['A2']); + expect(cycles).toContainEqual({from: 'A1', to: 'B1'}); }); test('checks for presence of root', () => { @@ -43,10 +45,10 @@ test('checks for presence of root', () => { }); test('traverses partial graph', () => { - let ids = graph.traverse(['B1', 'A3']); + const {nodes: ids} = graph.traverse(['B1', 'A3']); // Check that expected nodes are there - let sortedIds = ids.slice().sort(); + const sortedIds = ids.slice().sort(); expect(sortedIds).toEqual(['A3', 'B1', 'B2', 'C1', 'C2', 'C3']); // Check that the result is topologically sorted @@ -59,10 +61,10 @@ test('traverses partial graph', () => { }); test('traverses complete graph', () => { - let ids = graph.traverse(['A1', 'A2', 'A3']); + const {nodes: ids} = graph.traverse(['A1', 'A2', 'A3']); // Check that expected nodes are there - let sortedIds = ids.slice().sort(); + const sortedIds = ids.slice().sort(); expect(sortedIds).toEqual(['A1', 'A2', 'A3', 'B1', 'B2', 'C1', 'C2', 'C3']); // Check that the result is topologically sorted diff --git a/packages/hermes-inspector-msggen/__tests__/HeaderWriterTest.js b/packages/hermes-inspector-msggen/__tests__/header-writer-test.js similarity index 95% rename from packages/hermes-inspector-msggen/__tests__/HeaderWriterTest.js rename to packages/hermes-inspector-msggen/__tests__/header-writer-test.js index da8bf0c03a6b50..5ba2bb2a1158b5 100644 --- a/packages/hermes-inspector-msggen/__tests__/HeaderWriterTest.js +++ b/packages/hermes-inspector-msggen/__tests__/header-writer-test.js @@ -40,8 +40,12 @@ test('emits type decl', () => { expectCodeIsEqual(stream.get(), ` struct debugger::Location : public Serializable { Location() = default; + Location(Location&&) = default; + Location(const Location&) = delete; explicit Location(const folly::dynamic &obj); folly::dynamic toDynamic() const override; + Location& operator=(const Location&) = delete; + Location& operator=(Location&&) = default; runtime::ScriptId scriptId{}; int lineNumber{}; diff --git a/packages/hermes-inspector-msggen/__tests__/ImplementationWriterTest.js b/packages/hermes-inspector-msggen/__tests__/implementation-writer-test.js similarity index 100% rename from packages/hermes-inspector-msggen/__tests__/ImplementationWriterTest.js rename to packages/hermes-inspector-msggen/__tests__/implementation-writer-test.js diff --git a/packages/hermes-inspector-msggen/__tests__/PropertyTest.js b/packages/hermes-inspector-msggen/__tests__/property-test.js similarity index 100% rename from packages/hermes-inspector-msggen/__tests__/PropertyTest.js rename to packages/hermes-inspector-msggen/__tests__/property-test.js diff --git a/packages/hermes-inspector-msggen/__tests__/TypeTest.js b/packages/hermes-inspector-msggen/__tests__/type-test.js similarity index 100% rename from packages/hermes-inspector-msggen/__tests__/TypeTest.js rename to packages/hermes-inspector-msggen/__tests__/type-test.js