object-introspection/test/integration/thrift_isset.toml
Jake Hillion 4c6f232766 containers: add required features (#374)
Summary:
Adds the option for required features to container definitions. These cause the container not to be passed to `DrgnParser` if that feature is not enabled during code generation. The thrift isset type does not currently work with `tree-builder-v2` and only provides benefit with `capture-thrift-isset`. This change makes sure the container is ignored if it won't be useful, allowing code generation under `tree-builder-v2`.


Test Plan: - CI

Differential Revision: D49960512

Pulled By: JakeHillion
2023-10-09 17:50:39 -04:00

234 lines
7.8 KiB
TOML

thrift_definitions = '''
include "thrift/annotation/cpp.thrift"
include "thrift/annotation/thrift.thrift"
struct MyThriftStructUnpacked {
1: optional i32 a;
2: optional i32 b;
3: optional i32 c;
}
@cpp.PackIsset
struct MyThriftStructPacked {
1: optional i32 a;
2: optional i32 b;
3: optional i32 c;
4: optional i32 d;
5: optional i32 e;
6: optional i32 f;
7: optional i32 g;
8: optional i32 h;
9: optional i32 i;
10: optional i32 j;
}
@cpp.PackIsset{atomic = false}
struct MyThriftStructPackedNonAtomic {
1: optional i32 a;
2: optional i32 b;
3: optional i32 c;
4: optional i32 d;
}
struct MyThriftStructOutOfOrder {
3: i32 a;
1: i32 b;
2: i32 c;
}
struct MyThriftStructRequired {
1: required i32 a;
2: optional i32 b;
3: optional i32 c;
4: required i32 d;
5: required i32 e;
6: optional i32 f;
}
struct MyThriftStructBoxed {
@cpp.Ref{type = cpp.RefType.Unique}
1: optional i32 a;
@thrift.Box
2: optional i32 b;
3: optional i32 c;
4: optional i32 d;
5: optional i32 e;
}
'''
raw_definitions = '''
namespace cpp2 {
MyThriftStructBoxed::MyThriftStructBoxed() :
__fbthrift_field_b(),
__fbthrift_field_c(),
__fbthrift_field_d(),
__fbthrift_field_e() {
}
MyThriftStructBoxed::~MyThriftStructBoxed() {}
MyThriftStructBoxed::MyThriftStructBoxed(::cpp2::MyThriftStructBoxed&& other) noexcept :
__fbthrift_field_a(std::move(other.__fbthrift_field_a)),
__fbthrift_field_b(std::move(other.__fbthrift_field_b)),
__fbthrift_field_c(std::move(other.__fbthrift_field_c)),
__fbthrift_field_d(std::move(other.__fbthrift_field_d)),
__fbthrift_field_e(std::move(other.__fbthrift_field_e)),
__isset(other.__isset) {
}
} // namespace cpp2
'''
[cases]
[cases.unpacked]
oil_skip = 'oil does not support thrift isset yet' # https://github.com/facebookexperimental/object-introspection/issues/296
param_types = ["const cpp2::MyThriftStructUnpacked&"]
setup = '''
cpp2::MyThriftStructUnpacked ret;
ret.a_ref() = 1;
ret.c_ref() = 1;
return ret;
'''
cli_options = ["-fcapture-thrift-isset"]
expect_json = '''[{
"staticSize":16,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_b", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":true},
{"name":"__isset", "staticSize":3}
]}]'''
[cases.packed]
oil_skip = 'oil does not support thrift isset yet' # https://github.com/facebookexperimental/object-introspection/issues/296
param_types = ["const cpp2::MyThriftStructPacked&"]
setup = '''
cpp2::MyThriftStructPacked ret;
ret.a_ref() = 1;
ret.c_ref() = 1;
ret.d_ref() = 1;
ret.g_ref() = 1;
ret.h_ref() = 1;
ret.j_ref() = 1;
return ret;
'''
cli_options = ["-fcapture-thrift-isset"]
expect_json = '''[{
"staticSize":44,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_b", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_d", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_e", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_f", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_g", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_h", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_i", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_j", "staticSize":4, "isset":true},
{"name":"__isset", "staticSize":2}
]}]'''
[cases.packed_non_atomic]
oil_skip = 'oil does not support thrift isset yet' # https://github.com/facebookexperimental/object-introspection/issues/296
param_types = ["const cpp2::MyThriftStructPackedNonAtomic&"]
setup = '''
cpp2::MyThriftStructPackedNonAtomic ret;
ret.a_ref() = 1;
ret.c_ref() = 1;
return ret;
'''
cli_options = ["-fcapture-thrift-isset"]
expect_json = '''[{
"staticSize":20,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_b", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_d", "staticSize":4, "isset":false},
{"name":"__isset", "staticSize":1}
]}]'''
[cases.out_of_order]
oil_skip = 'oil does not support thrift isset yet' # https://github.com/facebookexperimental/object-introspection/issues/296
param_types = ["const cpp2::MyThriftStructOutOfOrder&"]
setup = '''
cpp2::MyThriftStructOutOfOrder ret;
ret.b_ref() = 1;
return ret;
'''
cli_options = ["-fcapture-thrift-isset"]
expect_json = '''[{
"staticSize":16,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_b", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":false},
{"name":"__isset", "staticSize":3}
]}]'''
[cases.required]
oil_skip = 'oil does not support thrift isset yet' # https://github.com/facebookexperimental/object-introspection/issues/296
param_types = ["const cpp2::MyThriftStructRequired&"]
setup = '''
cpp2::MyThriftStructRequired ret;
ret.b_ref() = 1;
ret.f_ref() = 1;
return ret;
'''
cli_options = ["-fcapture-thrift-isset"]
expect_json = '''[{
"staticSize":28,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "NOT":"isset"},
{"name":"__fbthrift_field_b", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_d", "staticSize":4, "NOT":"isset"},
{"name":"__fbthrift_field_e", "staticSize":4, "NOT":"isset"},
{"name":"__fbthrift_field_f", "staticSize":4, "isset":true},
{"name":"__isset", "staticSize":3}
]}]'''
[cases.box]
oil_skip = 'oil does not support thrift isset yet' # https://github.com/facebookexperimental/object-introspection/issues/296
param_types = ["const cpp2::MyThriftStructBoxed&"]
setup = '''
cpp2::MyThriftStructBoxed ret;
ret.d_ref() = 1;
ret.e_ref() = 1;
return ret;
'''
cli_options = ["-fcapture-thrift-isset"]
expect_json = '''[{
"staticSize":32,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":8, "NOT":"isset"},
{"name":"__fbthrift_field_b", "staticSize":8, "NOT":"isset"},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_d", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_e", "staticSize":4, "isset":true},
{"name":"__isset", "staticSize":3}
]}]'''
[cases.no_capture]
param_types = ["const cpp2::MyThriftStructBoxed&"]
setup = '''
cpp2::MyThriftStructBoxed ret;
ret.d_ref() = 1;
ret.e_ref() = 1;
return ret;
'''
expect_json = '''[{
"staticSize":32,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":8, "NOT":"isset"},
{"name":"__fbthrift_field_b", "staticSize":8, "NOT":"isset"},
{"name":"__fbthrift_field_c", "staticSize":4, "NOT":"isset"},
{"name":"__fbthrift_field_d", "staticSize":4, "NOT":"isset"},
{"name":"__fbthrift_field_e", "staticSize":4, "NOT":"isset"},
{"name":"__isset", "staticSize":3}
]}]'''