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

Commit ac5b4dd

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

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(
@@ -53,7 +53,7 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_message(message: *mut DiagnosticMessage)
5353
unsafe { std::ptr::drop_in_place(message) }
5454
}
5555

56-
#[cfg(feature = "tests")]
56+
#[cfg(test)]
5757
#[no_mangle]
5858
pub extern "C" fn lib_ruby_parser__test__make_message_list() -> DiagnosticMessageListBlob {
5959
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(
@@ -89,7 +89,7 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_node(node: *mut Node) {
8989
unsafe { std::ptr::drop_in_place(node) }
9090
}
9191

92-
#[cfg(feature = "tests")]
92+
#[cfg(test)]
9393
#[no_mangle]
9494
pub extern "C" fn lib_ruby_parser__test__make_node_list() -> NodeListBlob {
9595
let mut v = helpers::make_nodes();

ruby-parser-c/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
# Use external allocator (compatible with C, needed for mingw target)
1815
use_external_allocator = []
1916

ruby-parser-c/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
BytesBlob::from(Bytes::new(vec![i1, i2, i3]))

ruby-parser-c/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-c/src/decoder.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ 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,
1313
) -> InputErrorBlob {
1414
InputErrorBlob::from(InputError::UnsupportedEncoding(String::from(s)))
1515
}
1616

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

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

38-
#[cfg(feature = "tests")]
38+
#[cfg(test)]
3939
#[no_mangle]
4040
pub extern "C" fn lib_ruby_parser__test__make_decoder_result__err(
4141
err: InputErrorBlob,
@@ -58,7 +58,7 @@ pub struct Decoder {
5858
pub state: *mut std::ffi::c_void,
5959
}
6060

61-
#[cfg(feature = "tests")]
61+
#[cfg(test)]
6262
#[no_mangle]
6363
pub extern "C" fn lib_ruby_parser__test__always_ok_decoder() -> Decoder {
6464
#[no_mangle]
@@ -79,7 +79,7 @@ pub extern "C" fn lib_ruby_parser__test__always_ok_decoder() -> Decoder {
7979
}
8080
}
8181

82-
#[cfg(feature = "tests")]
82+
#[cfg(test)]
8383
#[no_mangle]
8484
pub extern "C" fn lib_ruby_parser__test__always_err_decoder() -> Decoder {
8585
#[no_mangle]
@@ -102,13 +102,13 @@ pub extern "C" fn lib_ruby_parser__test__always_err_decoder() -> Decoder {
102102
}
103103
}
104104

105-
#[cfg(feature = "tests")]
105+
#[cfg(test)]
106106
#[no_mangle]
107107
pub extern "C" fn lib_ruby_parser__test__some_always_ok_decoder() -> MaybeDecoderBlob {
108108
MaybeDecoderBlob::from(Some(lib_ruby_parser__test__always_ok_decoder()))
109109
}
110110

111-
#[cfg(feature = "tests")]
111+
#[cfg(test)]
112112
#[no_mangle]
113113
pub extern "C" fn lib_ruby_parser__test__none_decoder() -> MaybeDecoderBlob {
114114
MaybeDecoderBlob::from(None)

ruby-parser-c/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(
1414
level: ErrorLevel,
@@ -27,7 +27,7 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_diagnostic(diagnostic: *mut Diagnostic) {
2727
unsafe { std::ptr::drop_in_place(diagnostic) }
2828
}
2929

30-
#[cfg(feature = "tests")]
30+
#[cfg(test)]
3131
#[no_mangle]
3232
pub extern "C" fn lib_ruby_parser__test__make_diagnostic_list(
3333
diagnostic: DiagnosticBlob,

ruby-parser-c/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-c/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-c/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)