Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit b456b2e

Browse files
committed
use #[cfg(test)] instead of a custom 'tests' feature
1 parent b627b4c commit b456b2e

17 files changed

+53
-56
lines changed

codegen/messages.rs.liquid

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::blob_type;
77
blob_type!(DiagnosticMessageBlob, DiagnosticMessage);
88
blob_type!(DiagnosticMessageListBlob, Vec<DiagnosticMessage>);
99

10-
#[cfg(feature = "tests")]
10+
#[cfg(test)]
1111
mod helpers {
1212
use super::*;
1313

@@ -26,7 +26,7 @@ mod helpers {
2626
}
2727

2828
{% for message in messages %}
29-
#[cfg(feature = "tests")]
29+
#[cfg(test)]
3030
#[no_mangle]
3131
pub extern "C" fn lib_ruby_parser__test__make_{{ message.camelcase_name | camelcase_to_snakecase }}_message() -> DiagnosticMessageBlob {
3232
DiagnosticMessageBlob::from(
@@ -52,7 +52,7 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_message(message: *mut DiagnosticMessage)
5252
unsafe { std::ptr::drop_in_place(message) }
5353
}
5454

55-
#[cfg(feature = "tests")]
55+
#[cfg(test)]
5656
#[no_mangle]
5757
pub extern "C" fn lib_ruby_parser__test__make_message_list() -> DiagnosticMessageListBlob {
5858
let mut v = helpers::make_messages();

codegen/nodes.rs.liquid

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::blob_type;
77
blob_type!(NodeBlob, Node);
88
blob_type!(NodeListBlob, Vec<Node>);
99

10-
#[cfg(feature = "tests")]
10+
#[cfg(test)]
1111
mod helpers {
1212
use super::*;
1313

@@ -41,7 +41,7 @@ mod helpers {
4141
}
4242

4343
{% for node in nodes %}
44-
#[cfg(feature = "tests")]
44+
#[cfg(test)]
4545
#[no_mangle]
4646
pub extern "C" fn lib_ruby_parser__test__make_{{ node.camelcase_name | camelcase_to_snakecase }}_node() -> NodeBlob {
4747
NodeBlob::from(
@@ -86,7 +86,7 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_node(node: *mut Node) {
8686
unsafe { std::ptr::drop_in_place(node) }
8787
}
8888

89-
#[cfg(feature = "tests")]
89+
#[cfg(test)]
9090
#[no_mangle]
9191
pub extern "C" fn lib_ruby_parser__test__make_node_list() -> NodeListBlob {
9292
let mut v = helpers::make_nodes();

ruby-parser-cpp/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ crate-type = ["staticlib"]
1111
[features]
1212
default = []
1313

14-
# Include test APIs to run C++ tests
15-
tests = []
16-
1714
[dependencies]
1815
lib-ruby-parser = {version = "4.0.2+ruby-3.1.1"}
1916

ruby-parser-cpp/src/bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use lib_ruby_parser::Bytes;
44
blob_type!(ByteListBlob, Vec<u8>);
55
blob_type!(BytesBlob, Bytes);
66

7-
#[cfg(feature = "tests")]
7+
#[cfg(test)]
88
#[no_mangle]
99
pub extern "C" fn lib_ruby_parser__test__make_byte_list(i1: u8, i2: u8, i3: u8) -> ByteListBlob {
1010
let mut v = vec![i1, i2, i3];
@@ -17,7 +17,7 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_byte_list(byte_list: *mut Vec<u8>) {
1717
unsafe { std::ptr::drop_in_place(byte_list) }
1818
}
1919

20-
#[cfg(feature = "tests")]
20+
#[cfg(test)]
2121
#[no_mangle]
2222
pub extern "C" fn lib_ruby_parser__test__make_bytes(i1: u8, i2: u8, i3: u8) -> BytesBlob {
2323
let mut v = vec![i1, i2, i3];

ruby-parser-cpp/src/comment.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@ use lib_ruby_parser::{
77

88
blob_type!(CommentListBlob, Vec<Comment>);
99

10-
#[cfg(feature = "tests")]
10+
#[cfg(test)]
1111
#[no_mangle]
1212
pub extern "C" fn lib_ruby_parser__test__make_comment_type_document() -> CommentType {
1313
CommentType::Document
1414
}
1515

16-
#[cfg(feature = "tests")]
16+
#[cfg(test)]
1717
#[no_mangle]
1818
pub extern "C" fn lib_ruby_parser__test__make_comment_type_inline() -> CommentType {
1919
CommentType::Inline
2020
}
2121

22-
#[cfg(feature = "tests")]
22+
#[cfg(test)]
2323
#[no_mangle]
2424
pub extern "C" fn lib_ruby_parser__test__make_comment_type_unknown() -> CommentType {
2525
CommentType::Unknown
2626
}
2727

28-
#[cfg(feature = "tests")]
28+
#[cfg(test)]
2929
#[no_mangle]
3030
pub extern "C" fn lib_ruby_parser__test__make_comment(location: Loc, kind: CommentType) -> Comment {
3131
Comment { location, kind }
3232
}
3333

34-
#[cfg(feature = "tests")]
34+
#[cfg(test)]
3535
#[no_mangle]
3636
pub extern "C" fn lib_ruby_parser__test__make_comment_list(comment: Comment) -> CommentListBlob {
3737
let mut v = vec![comment];

ruby-parser-cpp/src/decoder.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ blob_type!(InputErrorBlob, InputError);
66
blob_type!(DecoderResultBlob, DecoderResult);
77
blob_type!(MaybeDecoderBlob, Option<Decoder>);
88

9-
#[cfg(feature = "tests")]
9+
#[cfg(test)]
1010
#[no_mangle]
1111
pub extern "C" fn lib_ruby_parser__test__make_input_error__unsupported_encoding(
1212
s: StringBlob,
@@ -15,7 +15,7 @@ pub extern "C" fn lib_ruby_parser__test__make_input_error__unsupported_encoding(
1515
InputErrorBlob::from(InputError::UnsupportedEncoding(s))
1616
}
1717

18-
#[cfg(feature = "tests")]
18+
#[cfg(test)]
1919
#[no_mangle]
2020
pub extern "C" fn lib_ruby_parser__test__make_input_error__decoding_error(
2121
s: StringBlob,
@@ -28,15 +28,15 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_input_error(input_error: *mut InputError)
2828
unsafe { std::ptr::drop_in_place(input_error) }
2929
}
3030

31-
#[cfg(feature = "tests")]
31+
#[cfg(test)]
3232
#[no_mangle]
3333
pub extern "C" fn lib_ruby_parser__test__make_decoder_result__ok(
3434
bytes: ByteListBlob,
3535
) -> DecoderResultBlob {
3636
DecoderResultBlob::from(DecoderResult::Ok(bytes.into()))
3737
}
3838

39-
#[cfg(feature = "tests")]
39+
#[cfg(test)]
4040
#[no_mangle]
4141
pub extern "C" fn lib_ruby_parser__test__make_decoder_result__err(
4242
err: InputErrorBlob,
@@ -60,7 +60,7 @@ pub struct Decoder {
6060
pub state: *const std::ffi::c_void,
6161
}
6262

63-
#[cfg(feature = "tests")]
63+
#[cfg(test)]
6464
#[no_mangle]
6565
pub extern "C" fn lib_ruby_parser__test__always_ok_decoder(output: *const u8) -> Decoder {
6666
#[no_mangle]
@@ -84,7 +84,7 @@ pub extern "C" fn lib_ruby_parser__test__always_ok_decoder(output: *const u8) ->
8484
}
8585
}
8686

87-
#[cfg(feature = "tests")]
87+
#[cfg(test)]
8888
#[no_mangle]
8989
pub extern "C" fn lib_ruby_parser__test__always_err_decoder(output: *const u8) -> Decoder {
9090
#[no_mangle]
@@ -110,15 +110,15 @@ pub extern "C" fn lib_ruby_parser__test__always_err_decoder(output: *const u8) -
110110
}
111111
}
112112

113-
#[cfg(feature = "tests")]
113+
#[cfg(test)]
114114
#[no_mangle]
115115
pub extern "C" fn lib_ruby_parser__test__some_always_ok_decoder(
116116
output: *mut u8,
117117
) -> MaybeDecoderBlob {
118118
MaybeDecoderBlob::from(Some(lib_ruby_parser__test__always_ok_decoder(output)))
119119
}
120120

121-
#[cfg(feature = "tests")]
121+
#[cfg(test)]
122122
#[no_mangle]
123123
pub extern "C" fn lib_ruby_parser__test__none_decoder() -> MaybeDecoderBlob {
124124
MaybeDecoderBlob::from(None)

ruby-parser-cpp/src/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use lib_ruby_parser::{Diagnostic, DiagnosticMessage, ErrorLevel, Loc};
88
blob_type!(DiagnosticBlob, Diagnostic);
99
blob_type!(DiagnosticListBlob, Vec<Diagnostic>);
1010

11-
#[cfg(feature = "tests")]
11+
#[cfg(test)]
1212
#[no_mangle]
1313
pub extern "C" fn lib_ruby_parser__test__make_diagnostic() -> DiagnosticBlob {
1414
DiagnosticBlob::from(Diagnostic {
@@ -25,7 +25,7 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_diagnostic(diagnostic: *mut Diagnostic) {
2525
unsafe { std::ptr::drop_in_place(diagnostic) }
2626
}
2727

28-
#[cfg(feature = "tests")]
28+
#[cfg(test)]
2929
#[no_mangle]
3030
pub extern "C" fn lib_ruby_parser__test__make_diagnostic_list() -> DiagnosticListBlob {
3131
let mut v = vec![Diagnostic::from(lib_ruby_parser__test__make_diagnostic())];

ruby-parser-cpp/src/loc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ use lib_ruby_parser::Loc;
55

66
blob_type!(MaybeLocBlob, Option<Loc>);
77

8-
#[cfg(feature = "tests")]
8+
#[cfg(test)]
99
#[no_mangle]
1010
pub extern "C" fn lib_ruby_parser__test__make_loc(begin: usize, end: usize) -> Loc {
1111
Loc { begin, end }
1212
}
1313

14-
#[cfg(feature = "tests")]
14+
#[cfg(test)]
1515
#[no_mangle]
1616
pub extern "C" fn lib_ruby_parser__test__make_none_loc() -> MaybeLocBlob {
1717
MaybeLocBlob::from(None)
1818
}
1919

20-
#[cfg(feature = "tests")]
20+
#[cfg(test)]
2121
#[no_mangle]
2222
pub extern "C" fn lib_ruby_parser__test__make_some_loc(begin: usize, end: usize) -> MaybeLocBlob {
2323
MaybeLocBlob::from(Some(Loc { begin, end }))

ruby-parser-cpp/src/magic_comment.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@ use lib_ruby_parser::{
77

88
blob_type!(MagicCommentListBlob, Vec<MagicComment>);
99

10-
#[cfg(feature = "tests")]
10+
#[cfg(test)]
1111
#[no_mangle]
1212
pub extern "C" fn lib_ruby_parser__test__make_magic_comment_kind_encoding() -> MagicCommentKind {
1313
MagicCommentKind::Encoding
1414
}
1515

16-
#[cfg(feature = "tests")]
16+
#[cfg(test)]
1717
#[no_mangle]
1818
pub extern "C" fn lib_ruby_parser__test__make_magic_comment_kind_frozen_string_literal(
1919
) -> MagicCommentKind {
2020
MagicCommentKind::FrozenStringLiteral
2121
}
2222

23-
#[cfg(feature = "tests")]
23+
#[cfg(test)]
2424
#[no_mangle]
2525
pub extern "C" fn lib_ruby_parser__test__make_magic_comment_kind_shareable_constant_value(
2626
) -> MagicCommentKind {
2727
MagicCommentKind::ShareableConstantValue
2828
}
2929

30-
#[cfg(feature = "tests")]
30+
#[cfg(test)]
3131
#[no_mangle]
3232
pub extern "C" fn lib_ruby_parser__test__make_magic_comment_kind_warn_indent() -> MagicCommentKind {
3333
MagicCommentKind::WarnIndent
3434
}
3535

36-
#[cfg(feature = "tests")]
36+
#[cfg(test)]
3737
#[no_mangle]
3838
pub extern "C" fn lib_ruby_parser__test__make_magic_comment(
3939
kind: MagicCommentKind,
@@ -47,7 +47,7 @@ pub extern "C" fn lib_ruby_parser__test__make_magic_comment(
4747
}
4848
}
4949

50-
#[cfg(feature = "tests")]
50+
#[cfg(test)]
5151
#[no_mangle]
5252
pub extern "C" fn lib_ruby_parser__test__make_magic_comment_list(
5353
magic_comment: MagicComment,

ruby-parser-cpp/src/parser_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl From<CParserOptions> for lib_ruby_parser::ParserOptions {
4545
}
4646
}
4747

48-
#[cfg(feature = "tests")]
48+
#[cfg(test)]
4949
#[no_mangle]
5050
pub extern "C" fn lib_ruby_parser__test__make_parser_options() -> ParserOptionsBlob {
5151
ParserOptionsBlob::from(CParserOptions {

0 commit comments

Comments
 (0)