teamwalnut / graphql-ppx

GraphQL language primitives for ReScript/ReasonML written in ReasonML
https://graphql-ppx.com
MIT License
258 stars 53 forks source link

Bucklescript tests fail when following Contributing instructions #205

Closed mbirkegaard closed 3 years ago

mbirkegaard commented 3 years ago

It looks like there's a step missing in https://beta.graphql-ppx.com/docs/contributing/.

Running esy test runs the tests, but they all fail. The tests expect the snapshot (of course) but receive an empty string, so it seems like the bucklescript tests aren't being compiled. Am I missing something?

I have gotten the whole build to work previously but I think that's at least 7-8 months ago with the (now outdated) contribution instructions that used to be in the README

The native tests (esy dune runtest -f) all succeed.

jfrolich commented 3 years ago

Hey. They should work (they also run on the CI). Can you give more info on what is failing? Did you run npm install in the tests_bucklescript folder?

mbirkegaard commented 3 years ago

The tests fail as no code is generated and the snapshot is compared to the empty line and fails. That's the case for every single test. I've copied one of the test outputs below.

Generate Records › scalarsInput.re › output ``` expect.string(received).toMatchSnapshot(expected) Inspect your code changes or run Rely with the -u flag to update snapshots. - [@ocaml.ppx.context { tool_name: \"migrate_driver\", include_dirs: [], load_path: [], open_modules: [], for_package: None, debug: false, use_threads: false, use_vmthreads: false, recursive_types: false, principal: false, transparent_modules: false, unboxed_types: false, unsafe_string: false, cookies: [], } ]; module MyQuery: { module Raw: { type t = {scalarsInput: string}; type t_variables = {arg: t_variables_VariousScalarsInput} and t_variables_VariousScalarsInput = { nullableString: Js.Nullable.t(string), string, nullableInt: Js.Nullable.t(int), int, nullableFloat: Js.Nullable.t(float), float, nullableBoolean: Js.Nullable.t(bool), boolean: bool, nullableID: Js.Nullable.t(string), id: string, }; }; type t = {scalarsInput: string}; type t_variables = {arg: t_variables_VariousScalarsInput} and t_variables_VariousScalarsInput = { nullableString: option(string), string, nullableInt: option(int), int, nullableFloat: option(float), float, nullableBoolean: option(bool), boolean: bool, nullableID: option(string), id: string, }; /** The GraphQL query */ let query: string; /** Parse the JSON-compatible GraphQL data to ReasonML data types */ let parse: Raw.t => t; /** Serialize the ReasonML GraphQL data that was parsed using the parse function back to the original JSON compatible data */ let serialize: t => Raw.t; let serializeVariables: t_variables => Raw.t_variables; let serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput; let makeVariables: (~arg: t_variables_VariousScalarsInput, unit) => t_variables; let makeInputObjectVariousScalarsInput: ( ~nullableString: string=?, ~string: string, ~nullableInt: int=?, ~int: int, ~nullableFloat: float=?, ~float: float, ~nullableBoolean: bool=?, ~boolean: bool, ~nullableID: string=?, ~id: string, unit ) => t_variables_VariousScalarsInput; external unsafe_fromJson: Js.Json.t => Raw.t = \"%identity\"; external toJson: Raw.t => Js.Json.t = \"%identity\"; external variablesToJson: Raw.t_variables => Js.Json.t = \"%identity\"; } = { [@ocaml.warning \"-32\"]; module Raw = { type t = {scalarsInput: string}; type t_variables = {arg: t_variables_VariousScalarsInput} and t_variables_VariousScalarsInput = { nullableString: Js.Nullable.t(string), string, nullableInt: Js.Nullable.t(int), int, nullableFloat: Js.Nullable.t(float), float, nullableBoolean: Js.Nullable.t(bool), boolean: bool, nullableID: Js.Nullable.t(string), id: string, }; }; type t = {scalarsInput: string}; type t_variables = {arg: t_variables_VariousScalarsInput} and t_variables_VariousScalarsInput = { nullableString: option(string), string, nullableInt: option(int), int, nullableFloat: option(float), float, nullableBoolean: option(bool), boolean: bool, nullableID: option(string), id: string, }; let query = \"query ($arg: VariousScalarsInput!) {\\nscalarsInput(arg: $arg) \\n}\\n\"; let parse: Raw.t => t = (value) => ( { scalarsInput: { let value = (value: Raw.t).scalarsInput; value; }, }: t ); let serialize: t => Raw.t = (value) => ( { let scalarsInput = { let value = (value: t).scalarsInput; value; }; {scalarsInput: scalarsInput}; }: Raw.t ); let rec serializeVariables: t_variables => Raw.t_variables = inp => { arg: (a => serializeInputObjectVariousScalarsInput(a))( (inp: t_variables).arg, ), } and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = inp => { nullableString: ( a => switch (a) { | None => Js.Nullable.undefined | Some(b) => Js.Nullable.return((a => a)(b)) } )( (inp: t_variables_VariousScalarsInput).nullableString, ), string: (a => a)((inp: t_variables_VariousScalarsInput).string), nullableInt: ( a => switch (a) { | None => Js.Nullable.undefined | Some(b) => Js.Nullable.return((a => a)(b)) } )( (inp: t_variables_VariousScalarsInput).nullableInt, ), int: (a => a)((inp: t_variables_VariousScalarsInput).int), nullableFloat: ( a => switch (a) { | None => Js.Nullable.undefined | Some(b) => Js.Nullable.return((a => a)(b)) } )( (inp: t_variables_VariousScalarsInput).nullableFloat, ), float: (a => a)((inp: t_variables_VariousScalarsInput).float), nullableBoolean: ( a => switch (a) { | None => Js.Nullable.undefined | Some(b) => Js.Nullable.return((a => a)(b)) } )( (inp: t_variables_VariousScalarsInput).nullableBoolean, ), boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), nullableID: ( a => switch (a) { | None => Js.Nullable.undefined | Some(b) => Js.Nullable.return((a => a)(b)) } )( ^Cidentity\"; }; + ```

I was at first only following the instructions in the docs. Running

npm install -g esy@latest
esy install
esy build
esy test

Running npm install in tests_bucklescript makes a whole bunch of changes to tests_bucklescript/package-lock.json (--- a/tests_bucklescript/package-lock.json +++ b/tests_bucklescript/package-lock.json @@ -1,440 +1,9 @@) but tests still fail in exactly the same way.

I'm probably asking for the same thing as @amsross does in https://github.com/reasonml-community/graphql-ppx/issues/203#issuecomment-694230554: An almost assumption free guide spelling out exactly how to get started contributing

mbirkegaard commented 3 years ago

@jfrolich Is there anything obvious I'm doing wrong?

a-c-sreedhar-reddy commented 3 years ago

Hi @jfrolich I tried running the tests for bucklescript following the docs. All the tests failed. I am using ubuntu. Screenshot from 2021-01-21 23-55-44

a-c-sreedhar-reddy commented 3 years ago

Hey. They should work (they also run on the CI). Can you give more info on what is failing? Did you run npm install in the tests_bucklescript folder?

Hi @jfrolich . The issue is we had to do npm install in the root folder