mkrf 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/MIT-LICENSE +7 -0
- data/README +54 -0
- data/Rakefile +107 -0
- data/lib/mkrf.rb +4 -0
- data/lib/mkrf/availability.rb +219 -0
- data/lib/mkrf/generator.rb +146 -0
- data/test/abstract_unit.rb +4 -0
- data/test/fixtures/down_a_directory/header_down_a_directory.h +1 -0
- data/test/fixtures/stdmkrf.h +1 -0
- data/test/sample_files/libtrivial/Rakefile +31 -0
- data/test/sample_files/libtrivial/extconf.rb +3 -0
- data/test/sample_files/libtrivial/lib/libtrivial.c +5 -0
- data/test/sample_files/libtrivial/lib/libtrivial.o +0 -0
- data/test/sample_files/libtrivial/libtrivial_so.bundle +0 -0
- data/test/sample_files/libtrivial/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/CHANGELOG +74 -0
- data/test/sample_files/libxml-ruby-0.3.8/LICENSE +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/README +144 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c +76 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb +49 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c +86 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h +82 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb +107 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb +95 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c +372 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c +224 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c +1159 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c +168 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h +17 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c +167 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c +2139 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h +28 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c +248 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h +26 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c +153 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c +1417 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h +31 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c +715 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c +426 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h +52 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c +142 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h +16 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c +43 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h +12 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c +20 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h +13 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c +363 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c +125 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c +100 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h +18 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc +202 -0
- data/test/sample_files/syck-0.55/CHANGELOG +186 -0
- data/test/sample_files/syck-0.55/COPYING +54 -0
- data/test/sample_files/syck-0.55/Makefile +582 -0
- data/test/sample_files/syck-0.55/Makefile.am +5 -0
- data/test/sample_files/syck-0.55/Makefile.in +582 -0
- data/test/sample_files/syck-0.55/README +105 -0
- data/test/sample_files/syck-0.55/README.BYTECODE +484 -0
- data/test/sample_files/syck-0.55/README.EXT +444 -0
- data/test/sample_files/syck-0.55/RELEASE +123 -0
- data/test/sample_files/syck-0.55/TODO +25 -0
- data/test/sample_files/syck-0.55/aclocal.m4 +883 -0
- data/test/sample_files/syck-0.55/bootstrap +7 -0
- data/test/sample_files/syck-0.55/config.h +79 -0
- data/test/sample_files/syck-0.55/config.h.in +78 -0
- data/test/sample_files/syck-0.55/config.status +1197 -0
- data/test/sample_files/syck-0.55/config/README +14 -0
- data/test/sample_files/syck-0.55/config/depcomp +529 -0
- data/test/sample_files/syck-0.55/config/install-sh +323 -0
- data/test/sample_files/syck-0.55/config/missing +357 -0
- data/test/sample_files/syck-0.55/configure +6728 -0
- data/test/sample_files/syck-0.55/configure.in +36 -0
- data/test/sample_files/syck-0.55/ext/ruby/CHANGELOG +303 -0
- data/test/sample_files/syck-0.55/ext/ruby/README +400 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c +1894 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h +79 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c +174 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c +407 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c +2385 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c +504 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h +458 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c +2707 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/ext/ruby/install.rb +1022 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay.rb +161 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/news.rb +69 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb +434 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb +436 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/baseemitter.rb +247 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/basenode.rb +216 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/compat.rb +26 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/constants.rb +45 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/dbm.rb +111 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/emitter.rb +107 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/encoding.rb +33 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/error.rb +34 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/rubytypes.rb +438 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/store.rb +29 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stream.rb +40 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stringio.rb +83 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/syck.rb +19 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/tag.rb +86 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/types.rb +188 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb +54 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/ypath.rb +52 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yod.rb +1168 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb +27 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-sample.rb +336 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-validate.rb +341 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb +85 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/yaml-sortHashKeys.rb +128 -0
- data/test/sample_files/syck-0.55/ext/ruby/tests/basic.rb +1653 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsAnchorAlias.yml +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBasicTests.yml +282 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockMapping.yml +78 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockSequence.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsDocumentSeparator.yml +102 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsErrorTests.yml +23 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFlowCollections.yml +73 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFoldedScalars.yml +215 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsMapInSeq.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsNullsAndEmpties.yml +66 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsRubyTests.yml +182 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsSpecificationExamples.yml +2699 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsTypeTransfers.yml +265 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsYpath.yml +221 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/cookbook.rb +159 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/index.yml +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/yts.rb +193 -0
- data/test/sample_files/syck-0.55/lib/Makefile +497 -0
- data/test/sample_files/syck-0.55/lib/Makefile.am +27 -0
- data/test/sample_files/syck-0.55/lib/Makefile.in +497 -0
- data/test/sample_files/syck-0.55/lib/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/lib/bytecode.re +525 -0
- data/test/sample_files/syck-0.55/lib/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/lib/gram.c +1894 -0
- data/test/sample_files/syck-0.55/lib/gram.h +79 -0
- data/test/sample_files/syck-0.55/lib/gram.output +2005 -0
- data/test/sample_files/syck-0.55/lib/gram.y +481 -0
- data/test/sample_files/syck-0.55/lib/handler.c +174 -0
- data/test/sample_files/syck-0.55/lib/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/lib/implicit.re +206 -0
- data/test/sample_files/syck-0.55/lib/node.c +407 -0
- data/test/sample_files/syck-0.55/lib/syck.c +504 -0
- data/test/sample_files/syck-0.55/lib/syck.h +458 -0
- data/test/sample_files/syck-0.55/lib/syck_st.c +577 -0
- data/test/sample_files/syck-0.55/lib/syck_st.h +46 -0
- data/test/sample_files/syck-0.55/lib/token.c +2707 -0
- data/test/sample_files/syck-0.55/lib/token.re +1139 -0
- data/test/sample_files/syck-0.55/lib/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/lib/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/stamp-h1 +1 -0
- data/test/sample_files/syck-0.55/tests/Basic.c +141 -0
- data/test/sample_files/syck-0.55/tests/CuTest.c +294 -0
- data/test/sample_files/syck-0.55/tests/CuTest.h +84 -0
- data/test/sample_files/syck-0.55/tests/Emit.c +87 -0
- data/test/sample_files/syck-0.55/tests/Makefile +480 -0
- data/test/sample_files/syck-0.55/tests/Makefile.am +13 -0
- data/test/sample_files/syck-0.55/tests/Makefile.in +480 -0
- data/test/sample_files/syck-0.55/tests/Parse.c +208 -0
- data/test/sample_files/syck-0.55/tests/YTS.c +2310 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.erb +326 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.rb +44 -0
- data/test/test_availability.rb +68 -0
- data/test/test_generator.rb +74 -0
- metadata +252 -0
@@ -0,0 +1,326 @@
|
|
1
|
+
//
|
2
|
+
// YTS.c
|
3
|
+
//
|
4
|
+
// $Author: why $
|
5
|
+
// $Date: 2005/04/13 06:27:54 $
|
6
|
+
//
|
7
|
+
// Copyright (C) 2004 why the lucky stiff
|
8
|
+
//
|
9
|
+
// Well, this is the Yaml Testing Suite in the form of a plain C
|
10
|
+
// API. Basically, this is as good as C integration gets for Syck.
|
11
|
+
// You've got to have a symbol table around. From there, you can
|
12
|
+
// query your data.
|
13
|
+
//
|
14
|
+
|
15
|
+
#include <string.h>
|
16
|
+
#include "syck.h"
|
17
|
+
#include "CuTest.h"
|
18
|
+
|
19
|
+
/* YAML test node structures */
|
20
|
+
#define T_STR 10
|
21
|
+
#define T_SEQ 20
|
22
|
+
#define T_MAP 30
|
23
|
+
#define T_END 40
|
24
|
+
#define ILEN 2
|
25
|
+
|
26
|
+
struct test_node {
|
27
|
+
int type;
|
28
|
+
char *tag;
|
29
|
+
char *key;
|
30
|
+
struct test_node *value;
|
31
|
+
};
|
32
|
+
struct test_node end_node = { T_END };
|
33
|
+
|
34
|
+
/*
|
35
|
+
* Assertion which compares a YAML document with an
|
36
|
+
* equivalent set of test_node structs.
|
37
|
+
*/
|
38
|
+
SYMID
|
39
|
+
syck_copy_handler(p, n)
|
40
|
+
SyckParser *p;
|
41
|
+
SyckNode *n;
|
42
|
+
{
|
43
|
+
int i = 0;
|
44
|
+
struct test_node *tn = S_ALLOC_N( struct test_node, 1 );
|
45
|
+
|
46
|
+
switch ( n->kind )
|
47
|
+
{
|
48
|
+
case syck_str_kind:
|
49
|
+
tn->type = T_STR;
|
50
|
+
tn->key = syck_strndup( n->data.str->ptr, n->data.str->len );
|
51
|
+
tn->value = 0;
|
52
|
+
break;
|
53
|
+
|
54
|
+
case syck_seq_kind:
|
55
|
+
{
|
56
|
+
struct test_node *val;
|
57
|
+
struct test_node *seq = S_ALLOC_N( struct test_node, n->data.list->idx + 1 );
|
58
|
+
tn->type = T_SEQ;
|
59
|
+
tn->key = 0;
|
60
|
+
for ( i = 0; i < n->data.list->idx; i++ )
|
61
|
+
{
|
62
|
+
SYMID oid = syck_seq_read( n, i );
|
63
|
+
syck_lookup_sym( p, oid, (char **)&val );
|
64
|
+
seq[i] = val[0];
|
65
|
+
}
|
66
|
+
seq[n->data.list->idx] = end_node;
|
67
|
+
tn->value = seq;
|
68
|
+
}
|
69
|
+
break;
|
70
|
+
|
71
|
+
case syck_map_kind:
|
72
|
+
{
|
73
|
+
struct test_node *val;
|
74
|
+
struct test_node *map = S_ALLOC_N( struct test_node, ( n->data.pairs->idx * 2 ) + 1 );
|
75
|
+
tn->type = T_MAP;
|
76
|
+
tn->key = 0;
|
77
|
+
for ( i = 0; i < n->data.pairs->idx; i++ )
|
78
|
+
{
|
79
|
+
SYMID oid = syck_map_read( n, map_key, i );
|
80
|
+
syck_lookup_sym( p, oid, (char **)&val );
|
81
|
+
map[i * 2] = val[0];
|
82
|
+
|
83
|
+
oid = syck_map_read( n, map_value, i );
|
84
|
+
syck_lookup_sym( p, oid, (char **)&val );
|
85
|
+
map[(i * 2) + 1] = val[0];
|
86
|
+
}
|
87
|
+
map[n->data.pairs->idx * 2] = end_node;
|
88
|
+
tn->value = map;
|
89
|
+
}
|
90
|
+
break;
|
91
|
+
}
|
92
|
+
|
93
|
+
tn->tag = 0;
|
94
|
+
if ( n->type_id != NULL ) {
|
95
|
+
tn->tag = syck_strndup( n->type_id, strlen( n->type_id ) );
|
96
|
+
}
|
97
|
+
|
98
|
+
return syck_add_sym( p, (char *) tn );
|
99
|
+
}
|
100
|
+
|
101
|
+
int
|
102
|
+
syck_free_copies( char *key, struct test_node *tn, char *arg )
|
103
|
+
{
|
104
|
+
if ( tn != NULL ) {
|
105
|
+
switch ( tn->type ) {
|
106
|
+
case T_STR:
|
107
|
+
S_FREE( tn->key );
|
108
|
+
break;
|
109
|
+
|
110
|
+
case T_SEQ:
|
111
|
+
case T_MAP:
|
112
|
+
S_FREE( tn->value );
|
113
|
+
break;
|
114
|
+
}
|
115
|
+
if ( tn->tag != NULL ) S_FREE( tn->tag );
|
116
|
+
S_FREE( tn );
|
117
|
+
}
|
118
|
+
tn = NULL;
|
119
|
+
return ST_CONTINUE;
|
120
|
+
}
|
121
|
+
|
122
|
+
void CuStreamCompareX( CuTest* tc, struct test_node *s1, struct test_node *s2 ) {
|
123
|
+
int i = 0;
|
124
|
+
while ( 1 ) {
|
125
|
+
CuAssertIntEquals( tc, s1[i].type, s2[i].type );
|
126
|
+
if ( s1[i].type == T_END ) return;
|
127
|
+
if ( s1[i].tag != 0 && s2[i].tag != 0 ) CuAssertStrEquals( tc, s1[i].tag, s2[i].tag );
|
128
|
+
switch ( s1[i].type ) {
|
129
|
+
case T_STR:
|
130
|
+
CuAssertStrEquals( tc, s1[i].key, s2[i].key );
|
131
|
+
break;
|
132
|
+
case T_SEQ:
|
133
|
+
case T_MAP:
|
134
|
+
CuStreamCompareX( tc, s1[i].value, s2[i].value );
|
135
|
+
break;
|
136
|
+
}
|
137
|
+
i++;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
void CuStreamCompare( CuTest* tc, char *yaml, struct test_node *stream ) {
|
142
|
+
int doc_ct = 0;
|
143
|
+
struct test_node *ystream = S_ALLOC_N( struct test_node, doc_ct + 1 );
|
144
|
+
CuString *msg;
|
145
|
+
|
146
|
+
/* Set up parser */
|
147
|
+
SyckParser *parser = syck_new_parser();
|
148
|
+
syck_parser_str_auto( parser, yaml, NULL );
|
149
|
+
syck_parser_handler( parser, syck_copy_handler );
|
150
|
+
syck_parser_error_handler( parser, NULL );
|
151
|
+
syck_parser_implicit_typing( parser, 1 );
|
152
|
+
syck_parser_taguri_expansion( parser, 1 );
|
153
|
+
|
154
|
+
/* Parse all streams */
|
155
|
+
while ( 1 )
|
156
|
+
{
|
157
|
+
struct test_node *ydoc;
|
158
|
+
SYMID oid = syck_parse( parser );
|
159
|
+
if ( parser->eof == 1 ) break;
|
160
|
+
|
161
|
+
/* Add document to stream */
|
162
|
+
syck_lookup_sym( parser, oid, (char **)&ydoc );
|
163
|
+
ystream[doc_ct] = ydoc[0];
|
164
|
+
doc_ct++;
|
165
|
+
S_REALLOC_N( ystream, struct test_node, doc_ct + 1 );
|
166
|
+
}
|
167
|
+
ystream[doc_ct] = end_node;
|
168
|
+
|
169
|
+
/* Traverse the struct and the symbol table side-by-side */
|
170
|
+
/* DEBUG: y( stream, 0 ); y( ystream, 0 ); */
|
171
|
+
CuStreamCompareX( tc, stream, ystream );
|
172
|
+
|
173
|
+
/* Free the node tables and the parser */
|
174
|
+
S_FREE( ystream );
|
175
|
+
if ( parser->syms != NULL )
|
176
|
+
st_foreach( parser->syms, syck_free_copies, 0 );
|
177
|
+
syck_free_parser( parser );
|
178
|
+
}
|
179
|
+
|
180
|
+
/*
|
181
|
+
* Setup for testing N->Y->N.
|
182
|
+
*/
|
183
|
+
void
|
184
|
+
test_output_handler( emitter, str, len )
|
185
|
+
SyckEmitter *emitter;
|
186
|
+
char *str;
|
187
|
+
long len;
|
188
|
+
{
|
189
|
+
CuString *dest = (CuString *)emitter->bonus;
|
190
|
+
CuStringAppendLen( dest, str, len );
|
191
|
+
}
|
192
|
+
|
193
|
+
SYMID
|
194
|
+
build_symbol_table( SyckEmitter *emitter, struct test_node *node ) {
|
195
|
+
switch ( node->type ) {
|
196
|
+
case T_SEQ:
|
197
|
+
case T_MAP:
|
198
|
+
{
|
199
|
+
int i = 0;
|
200
|
+
while ( node->value[i].type != T_END ) {
|
201
|
+
SYMID id = build_symbol_table( emitter, &node->value[i] );
|
202
|
+
i++;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
return syck_emitter_mark_node( emitter, (st_data_t)node );
|
206
|
+
|
207
|
+
case T_STR:
|
208
|
+
return 0;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
void
|
213
|
+
test_emitter_handler( SyckEmitter *emitter, st_data_t data ) {
|
214
|
+
struct test_node *node = (struct test_node *)data;
|
215
|
+
switch ( node->type ) {
|
216
|
+
case T_STR:
|
217
|
+
syck_emit_scalar( emitter, node->tag, scalar_none, 0, 0, 0, node->key, strlen( node->key ) );
|
218
|
+
break;
|
219
|
+
case T_SEQ:
|
220
|
+
{
|
221
|
+
int i = 0;
|
222
|
+
syck_emit_seq( emitter, node->tag, seq_none );
|
223
|
+
while ( node->value[i].type != T_END ) {
|
224
|
+
syck_emit_item( emitter, (st_data_t)&node->value[i] );
|
225
|
+
i++;
|
226
|
+
}
|
227
|
+
syck_emit_end( emitter );
|
228
|
+
}
|
229
|
+
break;
|
230
|
+
case T_MAP:
|
231
|
+
{
|
232
|
+
int i = 0;
|
233
|
+
syck_emit_map( emitter, node->tag, map_none );
|
234
|
+
while ( node->value[i].type != T_END ) {
|
235
|
+
syck_emit_item( emitter, (st_data_t)&node->value[i] );
|
236
|
+
i++;
|
237
|
+
}
|
238
|
+
syck_emit_end( emitter );
|
239
|
+
}
|
240
|
+
break;
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
void CuRoundTrip( CuTest* tc, struct test_node *stream ) {
|
245
|
+
int i = 0;
|
246
|
+
CuString *cs = CuStringNew();
|
247
|
+
SyckEmitter *emitter = syck_new_emitter();
|
248
|
+
|
249
|
+
/* Calculate anchors and tags */
|
250
|
+
build_symbol_table( emitter, stream );
|
251
|
+
|
252
|
+
/* Build the stream */
|
253
|
+
syck_output_handler( emitter, test_output_handler );
|
254
|
+
syck_emitter_handler( emitter, test_emitter_handler );
|
255
|
+
emitter->bonus = cs;
|
256
|
+
while ( stream[i].type != T_END )
|
257
|
+
{
|
258
|
+
syck_emit( emitter, (st_data_t)&stream[i] );
|
259
|
+
syck_emitter_flush( emitter, 0 );
|
260
|
+
i++;
|
261
|
+
}
|
262
|
+
|
263
|
+
/* Reload the stream and compare */
|
264
|
+
/* printf( "-- output for %s --\n%s\n--- end of output --\n", tc->name, cs->buffer ); */
|
265
|
+
CuStreamCompare( tc, cs->buffer, stream );
|
266
|
+
CuStringFree( cs );
|
267
|
+
|
268
|
+
syck_free_emitter( emitter );
|
269
|
+
}
|
270
|
+
|
271
|
+
/*
|
272
|
+
* ACTUAL TESTS FOR THE YAML TESTING SUITE BEGIN HERE
|
273
|
+
* (EVERYTHING PREVIOUS WAS SET UP FOR THE TESTS)
|
274
|
+
*/
|
275
|
+
|
276
|
+
% syck_tests.each do |yt|
|
277
|
+
/*
|
278
|
+
* Example <%= yt['spec'] %>: <%= yt['test'] %>
|
279
|
+
*/
|
280
|
+
void
|
281
|
+
<%= yt['func'] %>( CuTest *tc )
|
282
|
+
{
|
283
|
+
<%= yt['syck'] %>
|
284
|
+
|
285
|
+
CuStreamCompare( tc,
|
286
|
+
|
287
|
+
/* YAML document */
|
288
|
+
<%= yt['yaml'].gsub( /\\/, '\\\\\\\\' ).gsub( '"', '\"' ).gsub( /^(.*)$/, '"\1\n"' ) %>
|
289
|
+
,
|
290
|
+
|
291
|
+
/* C structure of validations */
|
292
|
+
stream
|
293
|
+
);
|
294
|
+
|
295
|
+
CuRoundTrip( tc, stream );
|
296
|
+
}
|
297
|
+
% end
|
298
|
+
|
299
|
+
CuSuite *
|
300
|
+
SyckGetSuite()
|
301
|
+
{
|
302
|
+
CuSuite *suite = CuSuiteNew();
|
303
|
+
% syck_tests.each do |yt|
|
304
|
+
SUITE_ADD_TEST( suite, <%= yt['func'] %> );
|
305
|
+
% end
|
306
|
+
return suite;
|
307
|
+
}
|
308
|
+
|
309
|
+
int main(void)
|
310
|
+
{
|
311
|
+
CuString *output = CuStringNew();
|
312
|
+
CuSuite* suite = SyckGetSuite();
|
313
|
+
int count;
|
314
|
+
|
315
|
+
CuSuiteRun(suite);
|
316
|
+
CuSuiteSummary(suite, output);
|
317
|
+
CuSuiteDetails(suite, output);
|
318
|
+
|
319
|
+
printf("%s\n", output->buffer);
|
320
|
+
count = suite->failCount;
|
321
|
+
|
322
|
+
CuStringFree( output );
|
323
|
+
CuSuiteFree( suite );
|
324
|
+
|
325
|
+
return count;
|
326
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# YTS.c.rb
|
3
|
+
#
|
4
|
+
# $Author: why $
|
5
|
+
# $Date: 2005/01/02 04:33:40 $
|
6
|
+
#
|
7
|
+
# Copyright (C) 2004 why the lucky stiff
|
8
|
+
#
|
9
|
+
# This Ruby script generates the YTS suite for the
|
10
|
+
# Syck base lib. Basically, it searches ext/ruby/yts/ for
|
11
|
+
# tests with a 'syck' entry.
|
12
|
+
#
|
13
|
+
# To regenerate things yourself:
|
14
|
+
#
|
15
|
+
# ruby YTS.c.rb > YTS.c
|
16
|
+
#
|
17
|
+
# Oh and your Ruby must have YAML installed.
|
18
|
+
#
|
19
|
+
require 'erb'
|
20
|
+
require 'yaml'
|
21
|
+
|
22
|
+
# Find the Syck directory.
|
23
|
+
yts_dir = "ext/ruby/yts/"
|
24
|
+
syck_dir = ""
|
25
|
+
while File.expand_path( syck_dir ) != "/"
|
26
|
+
break if File.directory?( syck_dir + yts_dir )
|
27
|
+
syck_dir << "../"
|
28
|
+
end
|
29
|
+
yts_dir = syck_dir + yts_dir
|
30
|
+
abort "No YTS directory found" unless File.directory?( yts_dir )
|
31
|
+
|
32
|
+
# Load the YTS
|
33
|
+
syck_tests = []
|
34
|
+
YAML::load( File.open( yts_dir + "index.yml" ) ).each do |yst|
|
35
|
+
ct = 0
|
36
|
+
YAML.each_document( File.open( yts_dir + yst + ".yml" ) ) do |ydoc|
|
37
|
+
ydoc['group'] = yst
|
38
|
+
ydoc['func'] = "#{ ydoc['group'] }_#{ ct }"
|
39
|
+
syck_tests << ydoc if ydoc['syck']
|
40
|
+
ct += 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
puts ERB.new( File.read( syck_dir + "tests/YTS.c.erb" ), 0, "%<>" ).result
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/abstract_unit'
|
2
|
+
|
3
|
+
class TestAvailability < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@avail = Mkrf::Availability.new(:includes => File.join(File.dirname(__FILE__), 'fixtures'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_has_library_should_return_true_when_lib_already_loaded
|
9
|
+
@avail = Mkrf::Availability.new(:loaded_libs => ['sample_library'])
|
10
|
+
assert @avail.has_library?('sample_library')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_has_library_should_fail_on_bogus_lib
|
14
|
+
assert !@avail.has_library?('bogus_library')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_can_link
|
18
|
+
@avail.send(:with_headers, 'stdio.h') do
|
19
|
+
assert @avail.can_link?(@avail.send(:simple_reference, "printf"))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_create_source
|
24
|
+
assert !File.exist?(Mkrf::Availability::TEMP_SOURCE_FILE)
|
25
|
+
|
26
|
+
@avail.send(:create_source, "puts 'Hello World!'")
|
27
|
+
|
28
|
+
assert File.exist?(Mkrf::Availability::TEMP_SOURCE_FILE)
|
29
|
+
|
30
|
+
source = File.open(Mkrf::Availability::TEMP_SOURCE_FILE).read
|
31
|
+
assert_equal "puts 'Hello World!'", source
|
32
|
+
ensure
|
33
|
+
FileUtils.rm_f Mkrf::Availability::TEMP_SOURCE_FILE
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_has_header_should_fail_on_bogus_header
|
37
|
+
assert !@avail.has_header?('some_fake_header.h')
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_has_header_should_work_with_basic_headers
|
41
|
+
assert @avail.has_header?('stdmkrf.h')
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_has_header_should_check_many_paths
|
45
|
+
assert !@avail.has_header?('header_down_a_directory.h')
|
46
|
+
assert @avail.has_header?('header_down_a_directory.h', File.join(File.dirname(__FILE__), 'fixtures', 'down_a_directory'))
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_include_header
|
50
|
+
assert @avail.has_header?('stdmkrf.h')
|
51
|
+
assert !@avail.headers.include?('stdmkrf.h')
|
52
|
+
@avail.include_header('stdmkrf.h')
|
53
|
+
assert @avail.headers.include?('stdmkrf.h')
|
54
|
+
end
|
55
|
+
|
56
|
+
# This should really use a trivial lib compiled in fixtures..
|
57
|
+
def test_include_library
|
58
|
+
assert @avail.has_library?('z')
|
59
|
+
assert !@avail.loaded_libs.include?('z')
|
60
|
+
@avail.include_library('z')
|
61
|
+
assert @avail.loaded_libs.include?('z')
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_method_missing_should_go_down_chain_when_not_catching_stackable_attributes
|
65
|
+
assert_raises(NoMethodError) { @avail.not_a_stackable_attribute }
|
66
|
+
assert_raises(NoMethodError) { @avail.with_not_a_stackable_attribute }
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/abstract_unit'
|
2
|
+
|
3
|
+
class TestGenerator < Test::Unit::TestCase
|
4
|
+
SAMPLES_DIR = File.dirname(__FILE__) + '/sample_files'
|
5
|
+
|
6
|
+
SAMPLE_LIBS = {
|
7
|
+
:libtrivial => '/libtrivial/libtrivial_so.bundle',
|
8
|
+
:syck => '/syck-0.55/ext/ruby/ext/syck/syck.bundle',
|
9
|
+
:libxml => '/libxml-ruby-0.3.8/ext/xml/libxml_so.bundle'
|
10
|
+
}
|
11
|
+
|
12
|
+
# Set to true for full command line output
|
13
|
+
@@debug = false
|
14
|
+
|
15
|
+
def setup
|
16
|
+
silence_command_line do
|
17
|
+
system('rake test:samples:clean')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_that_trivial_lib_compiles
|
22
|
+
assert !File.exist?(SAMPLES_DIR + SAMPLE_LIBS[:libtrivial])
|
23
|
+
silence_command_line do
|
24
|
+
system('rake test:samples:trivial')
|
25
|
+
end
|
26
|
+
assert File.exist?(SAMPLES_DIR + SAMPLE_LIBS[:libtrivial])
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_that_syck_compiles
|
30
|
+
assert !File.exist?(SAMPLES_DIR + SAMPLE_LIBS[:syck])
|
31
|
+
silence_command_line do
|
32
|
+
system('rake test:samples:syck')
|
33
|
+
end
|
34
|
+
assert File.exist?(SAMPLES_DIR + SAMPLE_LIBS[:syck])
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_that_libxml_compiles
|
38
|
+
assert !File.exist?(SAMPLES_DIR + SAMPLE_LIBS[:libxml])
|
39
|
+
silence_command_line do
|
40
|
+
system('rake test:samples:libxml')
|
41
|
+
end
|
42
|
+
assert File.exist?(SAMPLES_DIR + SAMPLE_LIBS[:libxml])
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def silence_command_line
|
48
|
+
yield and return if @@debug
|
49
|
+
silence_stream(STDERR) do
|
50
|
+
silence_stream(STDOUT) do
|
51
|
+
yield
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# silence_stream taken from Rails ActiveSupport reporting.rb
|
57
|
+
|
58
|
+
# Silences any stream for the duration of the block.
|
59
|
+
#
|
60
|
+
# silence_stream(STDOUT) do
|
61
|
+
# puts 'This will never be seen'
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# puts 'But this will'
|
65
|
+
def silence_stream(stream)
|
66
|
+
old_stream = stream.dup
|
67
|
+
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
68
|
+
stream.sync = true
|
69
|
+
yield
|
70
|
+
ensure
|
71
|
+
stream.reopen(old_stream)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|