@@ -36,10 +36,15 @@ name = "<test target name>"
36
36
harness = false
37
37
````
38
38
39
- 2 . Call the ` datatest_stable::harness!(testfn, root, pattern) ` macro with the following
40
- parameters:
39
+ 2 . Call the ` datatest_stable::harness! ` macro as:
41
40
42
- * ` testfn ` - The test function to be executed on each matching input. This function can be one
41
+ ```` rust,ignore
42
+ datatest_stable::harness! {
43
+ { test = my_test, root = "path/to/fixtures", pattern = r"^.*/*" },
44
+ }
45
+ ````
46
+
47
+ * ` test ` - The test function to be executed on each matching input. This function can be one
43
48
of:
44
49
45
50
* ` fn(&Path) -> datatest_stable::Result<()> `
@@ -67,7 +72,13 @@ harness = false
67
72
` &str ` , or a function call that returns a ` String ` .
68
73
69
74
The three parameters can be repeated if you have multiple sets of data-driven tests to be run:
70
- ` datatest_stable::harness!(testfn1, root1, pattern1, testfn2, root2, pattern2) ` .
75
+
76
+ ```` rust,ignore
77
+ datatest_stable::harness! {
78
+ { test = testfn1, root = root1, pattern = pattern1 },
79
+ { test = testfn2, root = root2, pattern = pattern2 },
80
+ }
81
+ ````
71
82
72
83
### Relative paths
73
84
@@ -101,10 +112,10 @@ fn my_test_utf8(path: &Utf8Path, contents: String) -> datatest_stable::Result<()
101
112
Ok (())
102
113
}
103
114
104
- datatest_stable :: harness! (
105
- my_test , " path/to/fixtures" , r " ^.*/*" ,
106
- my_test_utf8 , " path/to/fixtures" , r " ^.*/*" ,
107
- );
115
+ datatest_stable :: harness! {
116
+ { test = my_test , root = " path/to/fixtures" , pattern = r " ^.*/*" } ,
117
+ { test = my_test_utf8 , root = " path/to/fixtures" , pattern = r " ^.*/*" } ,
118
+ }
108
119
````
109
120
110
121
If ` path/to/fixtures ` contains a file ` foo/bar.txt ` , then:
@@ -134,9 +145,9 @@ fn my_test(path: &Path, contents: Vec<u8>) -> datatest_stable::Result<()> {
134
145
Ok (())
135
146
}
136
147
137
- datatest_stable :: harness! (
138
- my_test , include_dir! (" tests/files" ), r " ^.*/*" ,
139
- );
148
+ datatest_stable :: harness! {
149
+ { test = my_test , root = include_dir! (" tests/files" ), pattern = r " ^.*/*" } ,
150
+ }
140
151
````
141
152
142
153
You can also use directories published as ` static ` items in upstream crates:
@@ -153,9 +164,9 @@ fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> {
153
164
Ok (())
154
165
}
155
166
156
- datatest_stable :: harness! (
157
- my_test , & FIXTURES , r " ^.*/*" ,
158
- );
167
+ datatest_stable :: harness! {
168
+ { test = my_test , root = & FIXTURES , pattern = r " ^.*/*" } ,
169
+ }
159
170
````
160
171
161
172
In this case, the passed-in ` Path ` and ` Utf8Path ` are ** relative** to the
@@ -186,9 +197,9 @@ fn my_test(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> {
186
197
Ok (())
187
198
}
188
199
189
- datatest_stable :: harness! (
190
- my_test , & FIXTURES , r " ^.*/*" ,
191
- );
200
+ datatest_stable :: harness! {
201
+ { test = my_test , root = & FIXTURES , pattern = r " ^.*/*" } ,
202
+ }
192
203
````
193
204
194
205
In this case, note that ` path ` will be relative to the ** crate directory**
0 commit comments