Skip to content

Commit 52cb1be

Browse files
hchokshimeta-codesync[bot]
authored andcommitted
Sync fixtures, update test suppressions for unsupported syntax
Summary: - Sync Haskell fixtures from fbthrift - Emit `;` terminator after empty package statement - the package grammer requires a quoted string or `;` literal, if empty, to follow the `package` keyword - Mark additional tests as failing, due to usage of Thrift features/syntax unsupported by the Haskell compiler parsing and/or pretty-printing - Include aliasing (`include "..." as foo`) - Bi-directional streaming - `performs Interaction;` syntax - Haskell parser does not store adequate location information to pretty print Reviewed By: vitaut Differential Revision: D92426921 fbshipit-source-id: 23b48474ee7166ba8cdf7b54b02a750a99a4c0fe
1 parent f205093 commit 52cb1be

175 files changed

Lines changed: 1378 additions & 36 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

exactprint/Thrift/ExactPrint/PrettyPrint.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ppHeader HPackage {..} = mconcat
7171
[ ppSAnns pkgSAnns
7272
, addHeader pkgKeywordLoc, "package"
7373
, foldMap addHeader pkgUriLoc
74-
, maybe mempty (\uri -> ppStr uri (fromMaybe DoubleQuote pkgQuoteType)) pkgUri
74+
, maybe ";" (\uri -> ppStr uri (fromMaybe DoubleQuote pkgQuoteType)) pkgUri
7575
]
7676

7777
-- Decls -----------------------------------------------------------------------

exactprint/tests/RoundTripTest.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ headerSize = 4
2929
-- error message
3030
failingTests :: [FilePath]
3131
failingTests =
32-
[ "common/hs/thrift/exactprint/tests/fbthrift-tests/basic/src/module.thrift"
32+
[ "common/hs/thrift/exactprint/tests/fbthrift-tests/aliasing/src/module.thrift"
33+
, "common/hs/thrift/exactprint/tests/fbthrift-tests/basic/src/module.thrift"
3334
, "common/hs/thrift/exactprint/tests/fbthrift-tests/basic-annotations/src/module.thrift"
34-
, "common/hs/thrift/exactprint/tests/fbthrift-tests/basic-enum/src/module.thrift"
35+
, "common/hs/thrift/exactprint/tests/fbthrift-tests/bidi/src/module.thrift"
3536
, "common/hs/thrift/exactprint/tests/fbthrift-tests/constants/src/module.thrift"
37+
, "common/hs/thrift/exactprint/tests/fbthrift-tests/cpp2-struct-footprint/src/module.thrift"
3638
, "common/hs/thrift/exactprint/tests/fbthrift-tests/exceptions/src/module.thrift"
3739
, "common/hs/thrift/exactprint/tests/fbthrift-tests/fatal/src/module.thrift"
3840
, "common/hs/thrift/exactprint/tests/fbthrift-tests/from_map_construct/src/module.thrift"
@@ -42,7 +44,7 @@ failingTests =
4244
, "common/hs/thrift/exactprint/tests/fbthrift-tests/interactions/src/shared.thrift"
4345
, "common/hs/thrift/exactprint/tests/fbthrift-tests/json_experimental/src/ThriftdocTest.thrift"
4446
, "common/hs/thrift/exactprint/tests/fbthrift-tests/map_construct/src/module.thrift"
45-
, "common/hs/thrift/exactprint/tests/fbthrift-tests/mcpp2-compare/src/module.thrift"
47+
, "common/hs/thrift/exactprint/tests/fbthrift-tests/method_decorators/src/module.thrift"
4648
, "common/hs/thrift/exactprint/tests/fbthrift-tests/patch/src/module.thrift"
4749
, "common/hs/thrift/exactprint/tests/fbthrift-tests/php-migration/src/module.thrift"
4850
, "common/hs/thrift/exactprint/tests/fbthrift-tests/python_capi/src/serialized_dep.thrift"

exactprint/tests/fbthrift-tests/adapter/src/a.thrift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
*/
2020

2121
include "b.thrift"
22+
include "thrift/annotation/thrift.thrift"
23+
24+
@thrift.AllowLegacyMissingUris
25+
package;
2226

2327
struct MyStruct {
2428
1: b.B a;

exactprint/tests/fbthrift-tests/adapter/src/b.thrift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
include "thrift/annotation/python.thrift"
2222

2323
include "c.thrift"
24+
include "thrift/annotation/thrift.thrift"
25+
26+
@thrift.AllowLegacyMissingUris
27+
package;
2428

2529
typedef c.C1 C1
2630

exactprint/tests/fbthrift-tests/adapter/src/c.thrift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
*/
2020

2121
include "thrift/annotation/python.thrift"
22+
include "thrift/annotation/thrift.thrift"
23+
24+
@thrift.AllowLegacyMissingUris
25+
package;
2226

2327
@python.Adapter{
2428
name = "three.AdapterThree",

exactprint/tests/fbthrift-tests/adapter/src/module.thrift

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,40 @@ include "thrift/annotation/python.thrift"
2727
include "thrift/annotation/thrift.thrift"
2828
include "thrift/annotation/scope.thrift"
2929
include "thrift/annotation/hack.thrift"
30+
include "thrift/annotation/java.thrift"
3031
include "thrift/annotation/rust.thrift"
3132

3233
@thrift.Experimental
33-
package "facebook.com/thrift/test"
34+
package "facebook.com/thrift/test/fixtures/adapter"
3435

3536
@thrift.AllowLegacyTypedefUri
3637
@hack.Adapter{name = '\\Adapter2'}
3738
@cpp.Adapter{name = '::my::Adapter2'}
3839
@rust.Adapter{name = "::my::Adapter2"}
40+
@java.Adapter{
41+
adapterClassName = "com.facebook.thrift.my.Adapter2",
42+
typeClassName = "com.facebook.thrift.my.AdaptedSet_2",
43+
}
3944
typedef set<string> (py.adapter = 'my.Adapter2') SetWithAdapter
4045
@thrift.AllowLegacyTypedefUri
4146
@hack.Adapter{name = '\\Adapter1'}
4247
@cpp.Adapter{name = '::my::Adapter1'}
4348
@rust.Adapter{name = "::my::Adapter1"}
49+
@java.Adapter{
50+
adapterClassName = "com.facebook.thrift.my.Adapter1",
51+
typeClassName = "com.facebook.thrift.my.AdaptedString_1",
52+
}
4453
typedef string (py.adapter = 'my.Adapter1') StringWithAdapter
4554
@thrift.AllowLegacyTypedefUri
4655
typedef list<StringWithAdapter> ListWithElemAdapter
4756
@thrift.AllowLegacyTypedefUri
4857
@hack.Adapter{name = '\\Adapter2'}
4958
@cpp.Adapter{name = '::my::Adapter2'}
5059
@rust.Adapter{name = "::my::Adapter2"}
60+
@java.Adapter{
61+
adapterClassName = "com.facebook.thrift.my.Adapter2",
62+
typeClassName = "com.facebook.thrift.my.AdaptedList_2",
63+
}
5164
typedef ListWithElemAdapter ListWithElemAdapter_withAdapter
5265

5366
enum Color {
@@ -70,6 +83,10 @@ struct MyAnnotation {
7083
@thrift.AllowLegacyTypedefUri
7184
@cpp.Adapter{name = "::my::Adapter1"}
7285
@rust.Adapter{name = "::my::Adapter1"}
86+
@java.Adapter{
87+
adapterClassName = "com.facebook.thrift.my.Adapter1",
88+
typeClassName = "com.facebook.thrift.my.AdaptedI64_1",
89+
}
7390
@MyAnnotation{signature = "MyI64", color = Color.GREEN}
7491
typedef i64 MyI64
7592

@@ -80,40 +97,72 @@ typedef MyI64 DoubleTypedefI64
8097
@hack.Adapter{name = '\\Adapter1'}
8198
@cpp.Adapter{name = '::my::Adapter1'}
8299
@rust.Adapter{name = "::my::Adapter1"}
100+
@java.Adapter{
101+
adapterClassName = "com.facebook.thrift.my.Adapter1",
102+
typeClassName = "com.facebook.thrift.my.AdaptedI32_1",
103+
}
83104
typedef i32 MyI32
84105

85106
@cpp.EnableCustomTypeOrdering
86107
struct Foo {
87108
@hack.Adapter{name = '\\Adapter1'}
88109
@cpp.Adapter{name = '::my::Adapter1'}
89110
@rust.Adapter{name = "::my::Adapter1"}
111+
@java.Adapter{
112+
adapterClassName = "com.facebook.thrift.my.Adapter1",
113+
typeClassName = "com.facebook.thrift.my.AdaptedI32_5137_1",
114+
}
90115
1: i32_5137 intField;
91116
@hack.Adapter{name = '\\Adapter1'}
92117
@cpp.Adapter{name = '::my::Adapter1'}
93118
@rust.Adapter{name = "::my::Adapter1"}
119+
@java.Adapter{
120+
adapterClassName = "com.facebook.thrift.my.Adapter1",
121+
typeClassName = "com.facebook.thrift.my.AdaptedI32_5137_1",
122+
}
94123
2: optional i32_5137 optionalIntField;
95124
@hack.Adapter{name = '\\Adapter1'}
96125
@cpp.Adapter{name = '::my::Adapter1'}
97126
@rust.Adapter{name = "::my::Adapter1"}
127+
@java.Adapter{
128+
adapterClassName = "com.facebook.thrift.my.Adapter1",
129+
typeClassName = "com.facebook.thrift.my.AdaptedI32_5137_1",
130+
}
98131
3: i32_5137 intFieldWithDefault = 13;
99132
4: SetWithAdapter setField;
100133
5: optional SetWithAdapter optionalSetField;
101134
@hack.Adapter{name = '\\Adapter3'}
102135
@cpp.Adapter{name = '::my::Adapter3'}
103136
@rust.Adapter{name = "::my::Adapter3"}
137+
@java.Adapter{
138+
adapterClassName = "com.facebook.thrift.my.Adapter3",
139+
typeClassName = "com.facebook.thrift.my.AdaptedMap_string_ListWithElemAdapter_withAdapter_8454_3",
140+
}
104141
6: map_string_ListWithElemAdapter_withAdapter_8454 mapField;
105142
@hack.Adapter{name = '\\Adapter3'}
106143
@cpp.Adapter{name = '::my::Adapter3'}
107144
@rust.Adapter{name = "::my::Adapter3"}
145+
@java.Adapter{
146+
adapterClassName = "com.facebook.thrift.my.Adapter3",
147+
typeClassName = "com.facebook.thrift.my.AdaptedMap_string_ListWithElemAdapter_withAdapter_8454_3",
148+
}
108149
7: optional map_string_ListWithElemAdapter_withAdapter_8454 optionalMapField;
109150
@hack.Adapter{name = '\\Adapter1'}
110151
@cpp.Adapter{name = '::my::Adapter3'}
111152
@rust.Adapter{name = "::my::Adapter3"}
153+
@java.Adapter{
154+
adapterClassName = "com.facebook.thrift.my.Adapter3",
155+
typeClassName = "com.facebook.thrift.my.AdaptedBinary_5673_3",
156+
}
112157
8: binary_5673 binaryField;
113158
9: MyI64 longField;
114159
@cpp.Adapter{name = "::my::Adapter2"}
115160
@python.Adapter{name = "my.Adapter3", typeHint = "my.AdaptedType3[]"}
116161
@rust.Adapter{name = "::my::Adapter2"}
162+
@java.Adapter{
163+
adapterClassName = "com.facebook.thrift.my.Adapter2",
164+
typeClassName = "com.facebook.thrift.my.AdaptedMyI64_2",
165+
}
117166
10: MyI64 adaptedLongField;
118167
11: DoubleTypedefI64 doubleAdaptedField;
119168
@python.Adapter{name = "my.ListAdapter", typeHint = "typing.Sequence[int]"}
@@ -136,15 +185,27 @@ union Baz {
136185
@hack.Adapter{name = '\\Adapter1'}
137186
@cpp.Adapter{name = '::my::Adapter1'}
138187
@rust.Adapter{name = "::my::Adapter1"}
188+
@java.Adapter{
189+
adapterClassName = "com.facebook.thrift.my.Adapter1",
190+
typeClassName = "com.facebook.thrift.my.AdaptedI32_5137_1",
191+
}
139192
1: i32_5137 intField;
140193
4: SetWithAdapter setField;
141194
@hack.Adapter{name = '\\Adapter3'}
142195
@cpp.Adapter{name = '::my::Adapter3'}
143196
@rust.Adapter{name = "::my::Adapter3"}
197+
@java.Adapter{
198+
adapterClassName = "com.facebook.thrift.my.Adapter3",
199+
typeClassName = "com.facebook.thrift.my.AdaptedMap_string_ListWithElemAdapter_withAdapter_8454_3",
200+
}
144201
6: map_string_ListWithElemAdapter_withAdapter_8454 mapField;
145202
@hack.Adapter{name = '\\Adapter1'}
146203
@cpp.Adapter{name = '::my::Adapter1'}
147204
@rust.Adapter{name = "::my::Adapter1"}
205+
@java.Adapter{
206+
adapterClassName = "com.facebook.thrift.my.Adapter1",
207+
typeClassName = "com.facebook.thrift.my.AdaptedBinary_5673_1",
208+
}
148209
8: binary_5673 binaryField;
149210
9: MyI64 longField;
150211
}
@@ -153,8 +214,14 @@ union Baz {
153214
@hack.Adapter{name = '\\Adapter1'}
154215
@cpp.Adapter{name = '::my::Adapter1'}
155216
@rust.Adapter{name = "::my::Adapter1"}
217+
@java.Adapter{
218+
adapterClassName = "com.facebook.thrift.my.Adapter1",
219+
typeClassName = "com.facebook.thrift.my.AdaptedFoo_1",
220+
}
156221
typedef Foo FooWithAdapter
157222

223+
typedef list<Foo> ListOfFooTypedef
224+
158225
struct Bar {
159226
@hack.Adapter{name = '\\Adapter1'}
160227
@cpp.Adapter{name = '::my::Adapter1', adaptedType = '::my::Cpp::Type1'}
@@ -171,6 +238,7 @@ struct Bar {
171238
@cpp.Adapter{name = '::my::Adapter1'}
172239
6: optional Baz_7352 optionalUnionField;
173240
7: DirectlyAdapted adaptedStructField;
241+
8: ListOfFooTypedef structListFieldWithTypedef;
174242
}
175243

176244
@cpp.Adapter{name = "::my::Adapter"}
@@ -191,6 +259,10 @@ struct StructWithFieldAdapter {
191259
@cpp.Adapter{name = "::my::Adapter1"}
192260
@python.Adapter{name = "my.Adapter1", typeHint = "my.AdaptedType1"}
193261
@rust.Adapter{name = "::my::Adapter1<>"}
262+
@java.Adapter{
263+
adapterClassName = "com.facebook.thrift.my.Adapter1",
264+
typeClassName = "com.facebook.thrift.my.AdaptedI32_1",
265+
}
194266
1: i32 field;
195267
@cpp.Adapter{name = "::my::Adapter1"}
196268
@cpp.Ref{type = cpp.RefType.Shared}
@@ -199,6 +271,10 @@ struct StructWithFieldAdapter {
199271
@cpp.Adapter{name = "::my::Adapter1"}
200272
@cpp.Ref{type = cpp.RefType.Shared}
201273
@rust.Adapter{name = "::my::Adapter1<>"}
274+
@java.Adapter{
275+
adapterClassName = "com.facebook.thrift.my.Adapter1",
276+
typeClassName = "com.facebook.thrift.my.AdaptedI32_1",
277+
}
202278
3: optional i32 opt_shared_field;
203279
@cpp.Adapter{name = "::my::Adapter1"}
204280
@thrift.Box
@@ -235,11 +311,14 @@ struct B {
235311
typedef A AdaptedA
236312
struct A {}
237313

314+
@thrift.AllowLegacyTypedefUri
315+
@cpp.Adapter{name = "::my::Adapter2"}
316+
typedef string StringWithCppAdapter
317+
238318
service Service {
239319
MyI32_4873 func(
240320
1: StringWithAdapter_7208 arg1,
241-
@cpp.Adapter{name = "::my::Adapter2"}
242-
2: string arg2,
321+
2: StringWithCppAdapter arg2,
243322
3: Foo arg3,
244323
);
245324
}

exactprint/tests/fbthrift-tests/adapter/src/module_no_uri.thrift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
*/
2020

2121
include "thrift/annotation/cpp.thrift"
22+
include "thrift/annotation/thrift.thrift"
23+
24+
@thrift.AllowLegacyMissingUris
25+
package;
2226

2327
union RefUnion {
2428
@cpp.Adapter{name = '::my::Adapter1'}

exactprint/tests/fbthrift-tests/adapter/src/with_containers.thrift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
include "thrift/annotation/python.thrift"
2222
include "thrift/annotation/scope.thrift"
23+
include "thrift/annotation/thrift.thrift"
24+
25+
@thrift.AllowLegacyMissingUris
26+
package;
2327

2428
@python.Adapter{name = "my.Adapter", typeHint = "my.AdaptedType[]"}
2529
@scope.Transitive
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// THIS FILE IS COPIED FROM FBTHRIFT, DO NOT MODIFY ITS CONTENTS DIRECTLY
2+
// generated-by : fbcode/common/hs/thrift/exactprint/tests/sync-fbthrift-tests.sh
3+
// source: xplat/thrift/compiler/test/fixtures/*
4+
// @generated
5+
/*
6+
* Copyright (c) Meta Platforms, Inc. and affiliates.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
package "facebook.com/thrift/compiler/test/fixtures/aliasing"
22+
23+
include "other/module.thrift" as other_module
24+
include "not_module.thrift" as module
25+
26+
struct Foo {
27+
1: other_module.Foo other_foo;
28+
2: module.Foo yet_another_foo;
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// THIS FILE IS COPIED FROM FBTHRIFT, DO NOT MODIFY ITS CONTENTS DIRECTLY
2+
// generated-by : fbcode/common/hs/thrift/exactprint/tests/sync-fbthrift-tests.sh
3+
// source: xplat/thrift/compiler/test/fixtures/*
4+
// @generated
5+
/*
6+
* Copyright (c) Meta Platforms, Inc. and affiliates.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
include "thrift/annotation/thrift.thrift"
22+
23+
@thrift.AllowLegacyMissingUris
24+
package;
25+
26+
struct Foo {
27+
1: i64 baz;
28+
}

0 commit comments

Comments
 (0)