diff options
author | Aleksey Kladov <[email protected]> | 2019-01-14 13:27:08 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-15 11:18:24 +0000 |
commit | d79a9b17dc4fb132443aa4ec1ca0ab278d2a217c (patch) | |
tree | 525b697381048b2f6d615a9c66c92485db8511ec | |
parent | 8caff4e03475c20392f13e8c6ad469bd01a4b4ce (diff) |
switch to insta for testing
20 files changed, 495 insertions, 195 deletions
diff --git a/Cargo.lock b/Cargo.lock index 504a5633f..2c4337a70 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -118,7 +118,7 @@ dependencies = [ | |||
118 | "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", | 118 | "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", |
119 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", | 119 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", |
120 | "serde_derive 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", | 120 | "serde_derive 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", |
121 | "serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", | 121 | "serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", |
122 | ] | 122 | ] |
123 | 123 | ||
124 | [[package]] | 124 | [[package]] |
@@ -156,6 +156,17 @@ dependencies = [ | |||
156 | ] | 156 | ] |
157 | 157 | ||
158 | [[package]] | 158 | [[package]] |
159 | name = "clicolors-control" | ||
160 | version = "1.0.0" | ||
161 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
162 | dependencies = [ | ||
163 | "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", | ||
164 | "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
165 | "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", | ||
166 | "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
167 | ] | ||
168 | |||
169 | [[package]] | ||
159 | name = "cloudabi" | 170 | name = "cloudabi" |
160 | version = "0.0.3" | 171 | version = "0.0.3" |
161 | source = "registry+https://github.com/rust-lang/crates.io-index" | 172 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -164,6 +175,23 @@ dependencies = [ | |||
164 | ] | 175 | ] |
165 | 176 | ||
166 | [[package]] | 177 | [[package]] |
178 | name = "console" | ||
179 | version = "0.7.3" | ||
180 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
181 | dependencies = [ | ||
182 | "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", | ||
183 | "clicolors-control 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
184 | "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
185 | "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
186 | "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", | ||
187 | "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
188 | "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
189 | "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
190 | "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
191 | "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
192 | ] | ||
193 | |||
194 | [[package]] | ||
167 | name = "crossbeam-channel" | 195 | name = "crossbeam-channel" |
168 | version = "0.3.6" | 196 | version = "0.3.6" |
169 | source = "registry+https://github.com/rust-lang/crates.io-index" | 197 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -260,6 +288,11 @@ dependencies = [ | |||
260 | ] | 288 | ] |
261 | 289 | ||
262 | [[package]] | 290 | [[package]] |
291 | name = "encode_unicode" | ||
292 | version = "0.3.5" | ||
293 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
294 | |||
295 | [[package]] | ||
263 | name = "error-chain" | 296 | name = "error-chain" |
264 | version = "0.12.0" | 297 | version = "0.12.0" |
265 | source = "registry+https://github.com/rust-lang/crates.io-index" | 298 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -340,7 +373,7 @@ dependencies = [ | |||
340 | "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", | 373 | "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", |
341 | "lsp-types 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)", | 374 | "lsp-types 0.54.0 (registry+https://github.com/rust-lang/crates.io-index)", |
342 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", | 375 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", |
343 | "serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", | 376 | "serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", |
344 | ] | 377 | ] |
345 | 378 | ||
346 | [[package]] | 379 | [[package]] |
@@ -394,6 +427,20 @@ version = "1.0.2" | |||
394 | source = "registry+https://github.com/rust-lang/crates.io-index" | 427 | source = "registry+https://github.com/rust-lang/crates.io-index" |
395 | 428 | ||
396 | [[package]] | 429 | [[package]] |
430 | name = "insta" | ||
431 | version = "0.1.4" | ||
432 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
433 | dependencies = [ | ||
434 | "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
435 | "console 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
436 | "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
437 | "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
438 | "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
439 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", | ||
440 | "serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", | ||
441 | ] | ||
442 | |||
443 | [[package]] | ||
397 | name = "itertools" | 444 | name = "itertools" |
398 | version = "0.8.0" | 445 | version = "0.8.0" |
399 | source = "registry+https://github.com/rust-lang/crates.io-index" | 446 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -448,7 +495,7 @@ dependencies = [ | |||
448 | "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", | 495 | "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", |
449 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", | 496 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", |
450 | "serde_derive 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", | 497 | "serde_derive 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", |
451 | "serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", | 498 | "serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", |
452 | "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", | 499 | "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", |
453 | "url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 500 | "url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", |
454 | ] | 501 | ] |
@@ -688,6 +735,7 @@ name = "ra_ide_api" | |||
688 | version = "0.1.0" | 735 | version = "0.1.0" |
689 | dependencies = [ | 736 | dependencies = [ |
690 | "fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", | 737 | "fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", |
738 | "insta 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", | ||
691 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 739 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
692 | "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", | 740 | "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", |
693 | "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", | 741 | "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -708,6 +756,7 @@ dependencies = [ | |||
708 | name = "ra_ide_api_light" | 756 | name = "ra_ide_api_light" |
709 | version = "0.1.0" | 757 | version = "0.1.0" |
710 | dependencies = [ | 758 | dependencies = [ |
759 | "insta 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", | ||
711 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 760 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
712 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | 761 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
713 | "proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", | 762 | "proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -742,7 +791,7 @@ dependencies = [ | |||
742 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 791 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
743 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 792 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
744 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", | 793 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", |
745 | "serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", | 794 | "serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", |
746 | "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", | 795 | "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", |
747 | "test_utils 0.1.0", | 796 | "test_utils 0.1.0", |
748 | "thread_worker 0.1.0", | 797 | "thread_worker 0.1.0", |
@@ -1081,7 +1130,7 @@ dependencies = [ | |||
1081 | 1130 | ||
1082 | [[package]] | 1131 | [[package]] |
1083 | name = "serde_json" | 1132 | name = "serde_json" |
1084 | version = "1.0.34" | 1133 | version = "1.0.35" |
1085 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1134 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1086 | dependencies = [ | 1135 | dependencies = [ |
1087 | "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1136 | "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1187,7 +1236,7 @@ dependencies = [ | |||
1187 | "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1236 | "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1188 | "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1237 | "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1189 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", | 1238 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", |
1190 | "serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", | 1239 | "serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", |
1191 | "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", | 1240 | "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", |
1192 | "unic-segment 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1241 | "unic-segment 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1193 | "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1242 | "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1215,12 +1264,20 @@ dependencies = [ | |||
1215 | ] | 1264 | ] |
1216 | 1265 | ||
1217 | [[package]] | 1266 | [[package]] |
1267 | name = "termios" | ||
1268 | version = "0.3.1" | ||
1269 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1270 | dependencies = [ | ||
1271 | "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1272 | ] | ||
1273 | |||
1274 | [[package]] | ||
1218 | name = "test_utils" | 1275 | name = "test_utils" |
1219 | version = "0.1.0" | 1276 | version = "0.1.0" |
1220 | dependencies = [ | 1277 | dependencies = [ |
1221 | "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1278 | "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1222 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1279 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1223 | "serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", | 1280 | "serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", |
1224 | "text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", | 1281 | "text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", |
1225 | ] | 1282 | ] |
1226 | 1283 | ||
@@ -1494,7 +1551,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1494 | "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" | 1551 | "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" |
1495 | "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" | 1552 | "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" |
1496 | "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" | 1553 | "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" |
1554 | "checksum clicolors-control 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "73abfd4c73d003a674ce5d2933fca6ce6c42480ea84a5ffe0a2dc39ed56300f9" | ||
1497 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" | 1555 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" |
1556 | "checksum console 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ecc3753530b959618f617b0cd6494526008d98687f1af5d8f9fa83fa9cdbb594" | ||
1498 | "checksum crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "137bc235f622ffaa0428e3854e24acb53291fc0b3ff6fb2cb75a8be6fb02f06b" | 1557 | "checksum crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "137bc235f622ffaa0428e3854e24acb53291fc0b3ff6fb2cb75a8be6fb02f06b" |
1499 | "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" | 1558 | "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" |
1500 | "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" | 1559 | "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" |
@@ -1507,6 +1566,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1507 | "checksum drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "69b26e475fd29098530e709294e94e661974c851aed42512793f120fed4e199f" | 1566 | "checksum drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "69b26e475fd29098530e709294e94e661974c851aed42512793f120fed4e199f" |
1508 | "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" | 1567 | "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" |
1509 | "checksum ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00" | 1568 | "checksum ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00" |
1569 | "checksum encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" | ||
1510 | "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" | 1570 | "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" |
1511 | "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" | 1571 | "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" |
1512 | "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" | 1572 | "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" |
@@ -1523,6 +1583,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1523 | "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" | 1583 | "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" |
1524 | "checksum im 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9c7f9bb8aee47fc16d535a705f7867a9fc83bb822e5e1043bb98e77ffeed3c" | 1584 | "checksum im 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9c7f9bb8aee47fc16d535a705f7867a9fc83bb822e5e1043bb98e77ffeed3c" |
1525 | "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" | 1585 | "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" |
1586 | "checksum insta 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "60e94ba6dd3521d953caeed96f6ba06f4cdc9e30e398b3ee7acdd680294f87dc" | ||
1526 | "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" | 1587 | "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" |
1527 | "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" | 1588 | "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" |
1528 | "checksum join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc7a5290e8c2606ce2be49f456d50f69173cb96d1541e4f66e34ac8b331a98f" | 1589 | "checksum join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc7a5290e8c2606ce2be49f456d50f69173cb96d1541e4f66e34ac8b331a98f" |
@@ -1586,7 +1647,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1586 | "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" | 1647 | "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" |
1587 | "checksum serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "0e732ed5a5592c17d961555e3b552985baf98d50ce418b7b655f31f6ba7eb1b7" | 1648 | "checksum serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "0e732ed5a5592c17d961555e3b552985baf98d50ce418b7b655f31f6ba7eb1b7" |
1588 | "checksum serde_derive 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d6115a3ca25c224e409185325afc16a0d5aaaabc15c42b09587d6f1ba39a5b" | 1649 | "checksum serde_derive 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d6115a3ca25c224e409185325afc16a0d5aaaabc15c42b09587d6f1ba39a5b" |
1589 | "checksum serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "bdf540260cfee6da923831f4776ddc495ada940c30117977c70f1313a6130545" | 1650 | "checksum serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "dfb1277d4d0563e4593e0b8b5d23d744d277b55d2bc0bf1c38d0d8a6589d38aa" |
1590 | "checksum sha-1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9d1f3b5de8a167ab06834a7c883bd197f2191e1dda1a22d9ccfeedbf9aded" | 1651 | "checksum sha-1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9d1f3b5de8a167ab06834a7c883bd197f2191e1dda1a22d9ccfeedbf9aded" |
1591 | "checksum slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" | 1652 | "checksum slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" |
1592 | "checksum smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b73ea3738b47563803ef814925e69be00799a8c07420be8b996f8e98fb2336db" | 1653 | "checksum smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b73ea3738b47563803ef814925e69be00799a8c07420be8b996f8e98fb2336db" |
@@ -1600,6 +1661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1600 | "checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3" | 1661 | "checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3" |
1601 | "checksum teraron 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d89ad4617d1dec55331067fadaa041e813479e1779616f3d3ce9308bf46184e" | 1662 | "checksum teraron 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d89ad4617d1dec55331067fadaa041e813479e1779616f3d3ce9308bf46184e" |
1602 | "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" | 1663 | "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" |
1664 | "checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" | ||
1603 | "checksum text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "158bb1c22b638b1da3c95a8ad9f061ea40d4d39fd0301be3a520f92efeeb189e" | 1665 | "checksum text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "158bb1c22b638b1da3c95a8ad9f061ea40d4d39fd0301be3a520f92efeeb189e" |
1604 | "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" | 1666 | "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" |
1605 | "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" | 1667 | "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" |
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml index d42a664b6..f7013c3c1 100644 --- a/crates/ra_ide_api/Cargo.toml +++ b/crates/ra_ide_api/Cargo.toml | |||
@@ -21,3 +21,6 @@ ra_text_edit = { path = "../ra_text_edit" } | |||
21 | ra_db = { path = "../ra_db" } | 21 | ra_db = { path = "../ra_db" } |
22 | hir = { path = "../ra_hir", package = "ra_hir" } | 22 | hir = { path = "../ra_hir", package = "ra_hir" } |
23 | test_utils = { path = "../test_utils" } | 23 | test_utils = { path = "../test_utils" } |
24 | |||
25 | [dev-dependencies] | ||
26 | insta = "0.1.4" | ||
diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs index c3c809c9f..9f0ab2f1c 100644 --- a/crates/ra_ide_api/src/extend_selection.rs +++ b/crates/ra_ide_api/src/extend_selection.rs | |||
@@ -38,8 +38,9 @@ fn find_macro_call(node: &SyntaxNode, range: TextRange) -> Option<&ast::MacroCal | |||
38 | 38 | ||
39 | #[cfg(test)] | 39 | #[cfg(test)] |
40 | mod tests { | 40 | mod tests { |
41 | use ra_syntax::TextRange; | ||
42 | |||
41 | use crate::mock_analysis::single_file_with_range; | 43 | use crate::mock_analysis::single_file_with_range; |
42 | use test_utils::assert_eq_dbg; | ||
43 | 44 | ||
44 | #[test] | 45 | #[test] |
45 | fn extend_selection_inside_macros() { | 46 | fn extend_selection_inside_macros() { |
@@ -51,6 +52,6 @@ mod tests { | |||
51 | ", | 52 | ", |
52 | ); | 53 | ); |
53 | let r = analysis.extend_selection(frange); | 54 | let r = analysis.extend_selection(frange); |
54 | assert_eq_dbg("[51; 56)", &r); | 55 | assert_eq!(r, TextRange::from_to(51.into(), 56.into())); |
55 | } | 56 | } |
56 | } | 57 | } |
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index 53e49da5b..f1de28094 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs | |||
@@ -92,3 +92,100 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: &ast::Module) -> Opt | |||
92 | kind: RunnableKind::TestMod { path }, | 92 | kind: RunnableKind::TestMod { path }, |
93 | }) | 93 | }) |
94 | } | 94 | } |
95 | |||
96 | #[cfg(test)] | ||
97 | mod tests { | ||
98 | use insta::assert_debug_snapshot_matches; | ||
99 | |||
100 | use crate::mock_analysis::analysis_and_position; | ||
101 | |||
102 | #[test] | ||
103 | fn test_runnables() { | ||
104 | let (analysis, pos) = analysis_and_position( | ||
105 | r#" | ||
106 | //- /lib.rs | ||
107 | <|> //empty | ||
108 | fn main() {} | ||
109 | |||
110 | #[test] | ||
111 | fn test_foo() {} | ||
112 | |||
113 | #[test] | ||
114 | #[ignore] | ||
115 | fn test_foo() {} | ||
116 | "#, | ||
117 | ); | ||
118 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
119 | assert_debug_snapshot_matches!("runnables", &runnables) | ||
120 | } | ||
121 | |||
122 | #[test] | ||
123 | fn test_runnables_module() { | ||
124 | let (analysis, pos) = analysis_and_position( | ||
125 | r#" | ||
126 | //- /lib.rs | ||
127 | <|> //empty | ||
128 | mod test_mod { | ||
129 | #[test] | ||
130 | fn test_foo1() {} | ||
131 | } | ||
132 | "#, | ||
133 | ); | ||
134 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
135 | assert_debug_snapshot_matches!("runnables_module", &runnables) | ||
136 | } | ||
137 | |||
138 | #[test] | ||
139 | fn test_runnables_one_depth_layer_module() { | ||
140 | let (analysis, pos) = analysis_and_position( | ||
141 | r#" | ||
142 | //- /lib.rs | ||
143 | <|> //empty | ||
144 | mod foo { | ||
145 | mod test_mod { | ||
146 | #[test] | ||
147 | fn test_foo1() {} | ||
148 | } | ||
149 | } | ||
150 | "#, | ||
151 | ); | ||
152 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
153 | assert_debug_snapshot_matches!("runnables_one_depth_layer_module", &runnables) | ||
154 | } | ||
155 | |||
156 | #[test] | ||
157 | fn test_runnables_multiple_depth_module() { | ||
158 | let (analysis, pos) = analysis_and_position( | ||
159 | r#" | ||
160 | //- /lib.rs | ||
161 | <|> //empty | ||
162 | mod foo { | ||
163 | mod bar { | ||
164 | mod test_mod { | ||
165 | #[test] | ||
166 | fn test_foo1() {} | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | "#, | ||
171 | ); | ||
172 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
173 | assert_debug_snapshot_matches!("runnables_multiple_depth_module", &runnables) | ||
174 | } | ||
175 | |||
176 | #[test] | ||
177 | fn test_runnables_no_test_function_in_module() { | ||
178 | let (analysis, pos) = analysis_and_position( | ||
179 | r#" | ||
180 | //- /lib.rs | ||
181 | <|> //empty | ||
182 | mod test_mod { | ||
183 | fn foo1() {} | ||
184 | } | ||
185 | "#, | ||
186 | ); | ||
187 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
188 | assert!(runnables.is_empty()) | ||
189 | } | ||
190 | |||
191 | } | ||
diff --git a/crates/ra_ide_api/src/snapshots/tests__highlight_query_group_macro.snap b/crates/ra_ide_api/src/snapshots/tests__highlight_query_group_macro.snap new file mode 100644 index 000000000..b84aa9c78 --- /dev/null +++ b/crates/ra_ide_api/src/snapshots/tests__highlight_query_group_macro.snap | |||
@@ -0,0 +1,26 @@ | |||
1 | Created: 2019-01-15T11:15:20.732493641+00:00 | ||
2 | Creator: [email protected] | ||
3 | Source: crates/ra_ide_api/src/syntax_highlighting.rs | ||
4 | |||
5 | [ | ||
6 | HighlightedRange { | ||
7 | range: [20; 32), | ||
8 | tag: "macro" | ||
9 | }, | ||
10 | HighlightedRange { | ||
11 | range: [13; 18), | ||
12 | tag: "text" | ||
13 | }, | ||
14 | HighlightedRange { | ||
15 | range: [51; 54), | ||
16 | tag: "keyword" | ||
17 | }, | ||
18 | HighlightedRange { | ||
19 | range: [55; 60), | ||
20 | tag: "keyword" | ||
21 | }, | ||
22 | HighlightedRange { | ||
23 | range: [61; 72), | ||
24 | tag: "function" | ||
25 | } | ||
26 | ] | ||
diff --git a/crates/ra_ide_api/src/snapshots/tests__highlights_code_inside_macros.snap b/crates/ra_ide_api/src/snapshots/tests__highlights_code_inside_macros.snap new file mode 100644 index 000000000..14c6e5a4e --- /dev/null +++ b/crates/ra_ide_api/src/snapshots/tests__highlights_code_inside_macros.snap | |||
@@ -0,0 +1,70 @@ | |||
1 | Created: 2019-01-15T11:15:20.732523231+00:00 | ||
2 | Creator: [email protected] | ||
3 | Source: crates/ra_ide_api/src/syntax_highlighting.rs | ||
4 | |||
5 | [ | ||
6 | HighlightedRange { | ||
7 | range: [13; 15), | ||
8 | tag: "keyword" | ||
9 | }, | ||
10 | HighlightedRange { | ||
11 | range: [16; 20), | ||
12 | tag: "function" | ||
13 | }, | ||
14 | HighlightedRange { | ||
15 | range: [41; 46), | ||
16 | tag: "macro" | ||
17 | }, | ||
18 | HighlightedRange { | ||
19 | range: [49; 52), | ||
20 | tag: "keyword" | ||
21 | }, | ||
22 | HighlightedRange { | ||
23 | range: [57; 59), | ||
24 | tag: "literal" | ||
25 | }, | ||
26 | HighlightedRange { | ||
27 | range: [82; 86), | ||
28 | tag: "macro" | ||
29 | }, | ||
30 | HighlightedRange { | ||
31 | range: [89; 92), | ||
32 | tag: "keyword" | ||
33 | }, | ||
34 | HighlightedRange { | ||
35 | range: [97; 99), | ||
36 | tag: "literal" | ||
37 | }, | ||
38 | HighlightedRange { | ||
39 | range: [49; 52), | ||
40 | tag: "keyword" | ||
41 | }, | ||
42 | HighlightedRange { | ||
43 | range: [53; 54), | ||
44 | tag: "function" | ||
45 | }, | ||
46 | HighlightedRange { | ||
47 | range: [57; 59), | ||
48 | tag: "literal" | ||
49 | }, | ||
50 | HighlightedRange { | ||
51 | range: [61; 62), | ||
52 | tag: "text" | ||
53 | }, | ||
54 | HighlightedRange { | ||
55 | range: [89; 92), | ||
56 | tag: "keyword" | ||
57 | }, | ||
58 | HighlightedRange { | ||
59 | range: [93; 94), | ||
60 | tag: "function" | ||
61 | }, | ||
62 | HighlightedRange { | ||
63 | range: [97; 99), | ||
64 | tag: "literal" | ||
65 | }, | ||
66 | HighlightedRange { | ||
67 | range: [101; 102), | ||
68 | tag: "text" | ||
69 | } | ||
70 | ] | ||
diff --git a/crates/ra_ide_api/src/snapshots/tests__runnables.snap b/crates/ra_ide_api/src/snapshots/tests__runnables.snap new file mode 100644 index 000000000..ba6cba0ab --- /dev/null +++ b/crates/ra_ide_api/src/snapshots/tests__runnables.snap | |||
@@ -0,0 +1,22 @@ | |||
1 | Created: 2019-01-15T11:15:20.732460119+00:00 | ||
2 | Creator: [email protected] | ||
3 | Source: crates/ra_ide_api/src/runnables.rs | ||
4 | |||
5 | [ | ||
6 | Runnable { | ||
7 | range: [1; 21), | ||
8 | kind: Bin | ||
9 | }, | ||
10 | Runnable { | ||
11 | range: [22; 46), | ||
12 | kind: Test { | ||
13 | name: "test_foo" | ||
14 | } | ||
15 | }, | ||
16 | Runnable { | ||
17 | range: [47; 81), | ||
18 | kind: Test { | ||
19 | name: "test_foo" | ||
20 | } | ||
21 | } | ||
22 | ] | ||
diff --git a/crates/ra_ide_api/src/snapshots/tests__runnables_module.snap b/crates/ra_ide_api/src/snapshots/tests__runnables_module.snap new file mode 100644 index 000000000..b3f2d4d6e --- /dev/null +++ b/crates/ra_ide_api/src/snapshots/tests__runnables_module.snap | |||
@@ -0,0 +1,18 @@ | |||
1 | Created: 2019-01-15T11:15:20.732460109+00:00 | ||
2 | Creator: [email protected] | ||
3 | Source: crates/ra_ide_api/src/runnables.rs | ||
4 | |||
5 | [ | ||
6 | Runnable { | ||
7 | range: [1; 59), | ||
8 | kind: TestMod { | ||
9 | path: "test_mod" | ||
10 | } | ||
11 | }, | ||
12 | Runnable { | ||
13 | range: [28; 57), | ||
14 | kind: Test { | ||
15 | name: "test_foo1" | ||
16 | } | ||
17 | } | ||
18 | ] | ||
diff --git a/crates/ra_ide_api/src/snapshots/tests__runnables_multiple_depth_module.snap b/crates/ra_ide_api/src/snapshots/tests__runnables_multiple_depth_module.snap new file mode 100644 index 000000000..6eba482e7 --- /dev/null +++ b/crates/ra_ide_api/src/snapshots/tests__runnables_multiple_depth_module.snap | |||
@@ -0,0 +1,18 @@ | |||
1 | Created: 2019-01-15T11:15:20.732522773+00:00 | ||
2 | Creator: [email protected] | ||
3 | Source: crates/ra_ide_api/src/runnables.rs | ||
4 | |||
5 | [ | ||
6 | Runnable { | ||
7 | range: [41; 115), | ||
8 | kind: TestMod { | ||
9 | path: "foo::bar::test_mod" | ||
10 | } | ||
11 | }, | ||
12 | Runnable { | ||
13 | range: [68; 105), | ||
14 | kind: Test { | ||
15 | name: "test_foo1" | ||
16 | } | ||
17 | } | ||
18 | ] | ||
diff --git a/crates/ra_ide_api/src/snapshots/tests__runnables_one_depth_layer_module.snap b/crates/ra_ide_api/src/snapshots/tests__runnables_one_depth_layer_module.snap new file mode 100644 index 000000000..f40c762f3 --- /dev/null +++ b/crates/ra_ide_api/src/snapshots/tests__runnables_one_depth_layer_module.snap | |||
@@ -0,0 +1,18 @@ | |||
1 | Created: 2019-01-15T11:15:20.732480089+00:00 | ||
2 | Creator: [email protected] | ||
3 | Source: crates/ra_ide_api/src/runnables.rs | ||
4 | |||
5 | [ | ||
6 | Runnable { | ||
7 | range: [23; 85), | ||
8 | kind: TestMod { | ||
9 | path: "foo::test_mod" | ||
10 | } | ||
11 | }, | ||
12 | Runnable { | ||
13 | range: [46; 79), | ||
14 | kind: Test { | ||
15 | name: "test_foo1" | ||
16 | } | ||
17 | } | ||
18 | ] | ||
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index cb19e9515..480b78dce 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs | |||
@@ -34,7 +34,8 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Cancelable<Vec<Hi | |||
34 | #[cfg(test)] | 34 | #[cfg(test)] |
35 | mod tests { | 35 | mod tests { |
36 | use crate::mock_analysis::single_file; | 36 | use crate::mock_analysis::single_file; |
37 | use test_utils::assert_eq_dbg; | 37 | |
38 | use insta::assert_debug_snapshot_matches; | ||
38 | 39 | ||
39 | #[test] | 40 | #[test] |
40 | fn highlights_code_inside_macros() { | 41 | fn highlights_code_inside_macros() { |
@@ -47,25 +48,7 @@ mod tests { | |||
47 | ", | 48 | ", |
48 | ); | 49 | ); |
49 | let highlights = analysis.highlight(file_id).unwrap(); | 50 | let highlights = analysis.highlight(file_id).unwrap(); |
50 | assert_eq_dbg( | 51 | assert_debug_snapshot_matches!("highlights_code_inside_macros", &highlights); |
51 | r#"[HighlightedRange { range: [13; 15), tag: "keyword" }, | ||
52 | HighlightedRange { range: [16; 20), tag: "function" }, | ||
53 | HighlightedRange { range: [41; 46), tag: "macro" }, | ||
54 | HighlightedRange { range: [49; 52), tag: "keyword" }, | ||
55 | HighlightedRange { range: [57; 59), tag: "literal" }, | ||
56 | HighlightedRange { range: [82; 86), tag: "macro" }, | ||
57 | HighlightedRange { range: [89; 92), tag: "keyword" }, | ||
58 | HighlightedRange { range: [97; 99), tag: "literal" }, | ||
59 | HighlightedRange { range: [49; 52), tag: "keyword" }, | ||
60 | HighlightedRange { range: [53; 54), tag: "function" }, | ||
61 | HighlightedRange { range: [57; 59), tag: "literal" }, | ||
62 | HighlightedRange { range: [61; 62), tag: "text" }, | ||
63 | HighlightedRange { range: [89; 92), tag: "keyword" }, | ||
64 | HighlightedRange { range: [93; 94), tag: "function" }, | ||
65 | HighlightedRange { range: [97; 99), tag: "literal" }, | ||
66 | HighlightedRange { range: [101; 102), tag: "text" }]"#, | ||
67 | &highlights, | ||
68 | ) | ||
69 | } | 52 | } |
70 | 53 | ||
71 | // FIXME: this test is not really necessary: artifact of the inital hacky | 54 | // FIXME: this test is not really necessary: artifact of the inital hacky |
@@ -80,13 +63,6 @@ mod tests { | |||
80 | ", | 63 | ", |
81 | ); | 64 | ); |
82 | let highlights = analysis.highlight(file_id).unwrap(); | 65 | let highlights = analysis.highlight(file_id).unwrap(); |
83 | assert_eq_dbg( | 66 | assert_debug_snapshot_matches!("highlight_query_group_macro", &highlights); |
84 | r#"[HighlightedRange { range: [20; 32), tag: "macro" }, | ||
85 | HighlightedRange { range: [13; 18), tag: "text" }, | ||
86 | HighlightedRange { range: [51; 54), tag: "keyword" }, | ||
87 | HighlightedRange { range: [55; 60), tag: "keyword" }, | ||
88 | HighlightedRange { range: [61; 72), tag: "function" }]"#, | ||
89 | &highlights, | ||
90 | ) | ||
91 | } | 67 | } |
92 | } | 68 | } |
diff --git a/crates/ra_ide_api/tests/test/main.rs b/crates/ra_ide_api/tests/test/main.rs index 7dc1dba73..2b863aedf 100644 --- a/crates/ra_ide_api/tests/test/main.rs +++ b/crates/ra_ide_api/tests/test/main.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | mod runnables; | ||
2 | |||
3 | use ra_syntax::TextRange; | 1 | use ra_syntax::TextRange; |
4 | use test_utils::{assert_eq_dbg, assert_eq_text}; | 2 | use test_utils::assert_eq_text; |
3 | use insta::assert_debug_snapshot_matches; | ||
5 | 4 | ||
6 | use ra_ide_api::{ | 5 | use ra_ide_api::{ |
7 | mock_analysis::{single_file, single_file_with_position, MockAnalysis}, | 6 | mock_analysis::{single_file, single_file_with_position, MockAnalysis}, |
@@ -12,18 +11,7 @@ use ra_ide_api::{ | |||
12 | fn test_unresolved_module_diagnostic() { | 11 | fn test_unresolved_module_diagnostic() { |
13 | let (analysis, file_id) = single_file("mod foo;"); | 12 | let (analysis, file_id) = single_file("mod foo;"); |
14 | let diagnostics = analysis.diagnostics(file_id).unwrap(); | 13 | let diagnostics = analysis.diagnostics(file_id).unwrap(); |
15 | assert_eq_dbg( | 14 | assert_debug_snapshot_matches!("unresolved_module_diagnostic", &diagnostics); |
16 | r#"[Diagnostic { | ||
17 | message: "unresolved module", | ||
18 | range: [4; 7), | ||
19 | fix: Some(SourceChange { | ||
20 | label: "create module", | ||
21 | source_file_edits: [], | ||
22 | file_system_edits: [CreateFile { source_root: SourceRootId(0), path: "foo.rs" }], | ||
23 | cursor_position: None }), | ||
24 | severity: Error }]"#, | ||
25 | &diagnostics, | ||
26 | ); | ||
27 | } | 15 | } |
28 | 16 | ||
29 | // FIXME: move this test to hir | 17 | // FIXME: move this test to hir |
@@ -31,7 +19,7 @@ fn test_unresolved_module_diagnostic() { | |||
31 | fn test_unresolved_module_diagnostic_no_diag_for_inline_mode() { | 19 | fn test_unresolved_module_diagnostic_no_diag_for_inline_mode() { |
32 | let (analysis, file_id) = single_file("mod foo {}"); | 20 | let (analysis, file_id) = single_file("mod foo {}"); |
33 | let diagnostics = analysis.diagnostics(file_id).unwrap(); | 21 | let diagnostics = analysis.diagnostics(file_id).unwrap(); |
34 | assert_eq_dbg(r#"[]"#, &diagnostics); | 22 | assert!(diagnostics.is_empty()); |
35 | } | 23 | } |
36 | 24 | ||
37 | #[test] | 25 | #[test] |
diff --git a/crates/ra_ide_api/tests/test/runnables.rs b/crates/ra_ide_api/tests/test/runnables.rs deleted file mode 100644 index da8d5e0d5..000000000 --- a/crates/ra_ide_api/tests/test/runnables.rs +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | use test_utils::assert_eq_dbg; | ||
2 | |||
3 | use ra_ide_api::mock_analysis::analysis_and_position; | ||
4 | |||
5 | #[test] | ||
6 | fn test_runnables() { | ||
7 | let (analysis, pos) = analysis_and_position( | ||
8 | r#" | ||
9 | //- /lib.rs | ||
10 | <|> //empty | ||
11 | fn main() {} | ||
12 | |||
13 | #[test] | ||
14 | fn test_foo() {} | ||
15 | |||
16 | #[test] | ||
17 | #[ignore] | ||
18 | fn test_foo() {} | ||
19 | "#, | ||
20 | ); | ||
21 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
22 | assert_eq_dbg( | ||
23 | r#"[Runnable { range: [1; 21), kind: Bin }, | ||
24 | Runnable { range: [22; 46), kind: Test { name: "test_foo" } }, | ||
25 | Runnable { range: [47; 81), kind: Test { name: "test_foo" } }]"#, | ||
26 | &runnables, | ||
27 | ) | ||
28 | } | ||
29 | |||
30 | #[test] | ||
31 | fn test_runnables_module() { | ||
32 | let (analysis, pos) = analysis_and_position( | ||
33 | r#" | ||
34 | //- /lib.rs | ||
35 | <|> //empty | ||
36 | mod test_mod { | ||
37 | #[test] | ||
38 | fn test_foo1() {} | ||
39 | } | ||
40 | "#, | ||
41 | ); | ||
42 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
43 | assert_eq_dbg( | ||
44 | r#"[Runnable { range: [1; 59), kind: TestMod { path: "test_mod" } }, | ||
45 | Runnable { range: [28; 57), kind: Test { name: "test_foo1" } }]"#, | ||
46 | &runnables, | ||
47 | ) | ||
48 | } | ||
49 | |||
50 | #[test] | ||
51 | fn test_runnables_one_depth_layer_module() { | ||
52 | let (analysis, pos) = analysis_and_position( | ||
53 | r#" | ||
54 | //- /lib.rs | ||
55 | <|> //empty | ||
56 | mod foo { | ||
57 | mod test_mod { | ||
58 | #[test] | ||
59 | fn test_foo1() {} | ||
60 | } | ||
61 | } | ||
62 | "#, | ||
63 | ); | ||
64 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
65 | assert_eq_dbg( | ||
66 | r#"[Runnable { range: [23; 85), kind: TestMod { path: "foo::test_mod" } }, | ||
67 | Runnable { range: [46; 79), kind: Test { name: "test_foo1" } }]"#, | ||
68 | &runnables, | ||
69 | ) | ||
70 | } | ||
71 | |||
72 | #[test] | ||
73 | fn test_runnables_multiple_depth_module() { | ||
74 | let (analysis, pos) = analysis_and_position( | ||
75 | r#" | ||
76 | //- /lib.rs | ||
77 | <|> //empty | ||
78 | mod foo { | ||
79 | mod bar { | ||
80 | mod test_mod { | ||
81 | #[test] | ||
82 | fn test_foo1() {} | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | "#, | ||
87 | ); | ||
88 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
89 | assert_eq_dbg( | ||
90 | r#"[Runnable { range: [41; 115), kind: TestMod { path: "foo::bar::test_mod" } }, | ||
91 | Runnable { range: [68; 105), kind: Test { name: "test_foo1" } }]"#, | ||
92 | &runnables, | ||
93 | ) | ||
94 | } | ||
95 | |||
96 | #[test] | ||
97 | fn test_runnables_no_test_function_in_module() { | ||
98 | let (analysis, pos) = analysis_and_position( | ||
99 | r#" | ||
100 | //- /lib.rs | ||
101 | <|> //empty | ||
102 | mod test_mod { | ||
103 | fn foo1() {} | ||
104 | } | ||
105 | "#, | ||
106 | ); | ||
107 | let runnables = analysis.runnables(pos.file_id).unwrap(); | ||
108 | assert_eq_dbg(r#"[]"#, &runnables) | ||
109 | } | ||
diff --git a/crates/ra_ide_api/tests/test/snapshots/test__unresolved_module_diagnostic.snap b/crates/ra_ide_api/tests/test/snapshots/test__unresolved_module_diagnostic.snap new file mode 100644 index 000000000..1b41e2b00 --- /dev/null +++ b/crates/ra_ide_api/tests/test/snapshots/test__unresolved_module_diagnostic.snap | |||
@@ -0,0 +1,26 @@ | |||
1 | Created: 2019-01-15T11:15:20.891129945+00:00 | ||
2 | Creator: [email protected] | ||
3 | Source: crates/ra_ide_api/tests/test/main.rs | ||
4 | |||
5 | [ | ||
6 | Diagnostic { | ||
7 | message: "unresolved module", | ||
8 | range: [4; 7), | ||
9 | fix: Some( | ||
10 | SourceChange { | ||
11 | label: "create module", | ||
12 | source_file_edits: [], | ||
13 | file_system_edits: [ | ||
14 | CreateFile { | ||
15 | source_root: SourceRootId( | ||
16 | 0 | ||
17 | ), | ||
18 | path: "foo.rs" | ||
19 | } | ||
20 | ], | ||
21 | cursor_position: None | ||
22 | } | ||
23 | ), | ||
24 | severity: Error | ||
25 | } | ||
26 | ] | ||
diff --git a/crates/ra_ide_api_light/Cargo.toml b/crates/ra_ide_api_light/Cargo.toml index 8c192fca6..16cf228e7 100644 --- a/crates/ra_ide_api_light/Cargo.toml +++ b/crates/ra_ide_api_light/Cargo.toml | |||
@@ -17,3 +17,4 @@ ra_text_edit = { path = "../ra_text_edit" } | |||
17 | [dev-dependencies] | 17 | [dev-dependencies] |
18 | test_utils = { path = "../test_utils" } | 18 | test_utils = { path = "../test_utils" } |
19 | proptest = "0.8.7" | 19 | proptest = "0.8.7" |
20 | insta = "0.1.4" | ||
diff --git a/crates/ra_ide_api_light/src/lib.rs b/crates/ra_ide_api_light/src/lib.rs index 72fba9402..9dd72701d 100644 --- a/crates/ra_ide_api_light/src/lib.rs +++ b/crates/ra_ide_api_light/src/lib.rs | |||
@@ -132,8 +132,9 @@ pub fn syntax_tree(file: &SourceFile) -> String { | |||
132 | #[cfg(test)] | 132 | #[cfg(test)] |
133 | mod tests { | 133 | mod tests { |
134 | use ra_syntax::AstNode; | 134 | use ra_syntax::AstNode; |
135 | use insta::assert_debug_snapshot_matches; | ||
135 | 136 | ||
136 | use crate::test_utils::{add_cursor, assert_eq_dbg, assert_eq_text, extract_offset}; | 137 | use crate::test_utils::{add_cursor, assert_eq_text, extract_offset}; |
137 | 138 | ||
138 | use super::*; | 139 | use super::*; |
139 | 140 | ||
@@ -147,15 +148,7 @@ fn main() {} | |||
147 | "#, | 148 | "#, |
148 | ); | 149 | ); |
149 | let hls = highlight(file.syntax()); | 150 | let hls = highlight(file.syntax()); |
150 | assert_eq_dbg( | 151 | assert_debug_snapshot_matches!("highlighting", hls); |
151 | r#"[HighlightedRange { range: [1; 11), tag: "comment" }, | ||
152 | HighlightedRange { range: [12; 14), tag: "keyword" }, | ||
153 | HighlightedRange { range: [15; 19), tag: "function" }, | ||
154 | HighlightedRange { range: [29; 37), tag: "macro" }, | ||
155 | HighlightedRange { range: [38; 50), tag: "string" }, | ||
156 | HighlightedRange { range: [52; 54), tag: "literal" }]"#, | ||
157 | &hls, | ||
158 | ); | ||
159 | } | 152 | } |
160 | 153 | ||
161 | #[test] | 154 | #[test] |
diff --git a/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap b/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap new file mode 100644 index 000000000..10eb5c724 --- /dev/null +++ b/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap | |||
@@ -0,0 +1,80 @@ | |||
1 | Created: 2019-01-15T11:15:21.073862814+00:00 | ||
2 | Creator: [email protected] | ||
3 | Source: crates/ra_ide_api_light/src/structure.rs | ||
4 | |||
5 | [ | ||
6 | StructureNode { | ||
7 | parent: None, | ||
8 | label: "Foo", | ||
9 | navigation_range: [8; 11), | ||
10 | node_range: [1; 26), | ||
11 | kind: STRUCT_DEF | ||
12 | }, | ||
13 | StructureNode { | ||
14 | parent: Some( | ||
15 | 0 | ||
16 | ), | ||
17 | label: "x", | ||
18 | navigation_range: [18; 19), | ||
19 | node_range: [18; 24), | ||
20 | kind: NAMED_FIELD_DEF | ||
21 | }, | ||
22 | StructureNode { | ||
23 | parent: None, | ||
24 | label: "m", | ||
25 | navigation_range: [32; 33), | ||
26 | node_range: [28; 53), | ||
27 | kind: MODULE | ||
28 | }, | ||
29 | StructureNode { | ||
30 | parent: Some( | ||
31 | 2 | ||
32 | ), | ||
33 | label: "bar", | ||
34 | navigation_range: [43; 46), | ||
35 | node_range: [40; 51), | ||
36 | kind: FN_DEF | ||
37 | }, | ||
38 | StructureNode { | ||
39 | parent: None, | ||
40 | label: "E", | ||
41 | navigation_range: [60; 61), | ||
42 | node_range: [55; 75), | ||
43 | kind: ENUM_DEF | ||
44 | }, | ||
45 | StructureNode { | ||
46 | parent: None, | ||
47 | label: "T", | ||
48 | navigation_range: [81; 82), | ||
49 | node_range: [76; 88), | ||
50 | kind: TYPE_DEF | ||
51 | }, | ||
52 | StructureNode { | ||
53 | parent: None, | ||
54 | label: "S", | ||
55 | navigation_range: [96; 97), | ||
56 | node_range: [89; 108), | ||
57 | kind: STATIC_DEF | ||
58 | }, | ||
59 | StructureNode { | ||
60 | parent: None, | ||
61 | label: "C", | ||
62 | navigation_range: [115; 116), | ||
63 | node_range: [109; 127), | ||
64 | kind: CONST_DEF | ||
65 | }, | ||
66 | StructureNode { | ||
67 | parent: None, | ||
68 | label: "impl E", | ||
69 | navigation_range: [134; 135), | ||
70 | node_range: [129; 138), | ||
71 | kind: IMPL_BLOCK | ||
72 | }, | ||
73 | StructureNode { | ||
74 | parent: None, | ||
75 | label: "impl fmt::Debug for E", | ||
76 | navigation_range: [160; 161), | ||
77 | node_range: [140; 164), | ||
78 | kind: IMPL_BLOCK | ||
79 | } | ||
80 | ] | ||
diff --git a/crates/ra_ide_api_light/src/snapshots/tests__highlighting.snap b/crates/ra_ide_api_light/src/snapshots/tests__highlighting.snap new file mode 100644 index 000000000..d8f44a713 --- /dev/null +++ b/crates/ra_ide_api_light/src/snapshots/tests__highlighting.snap | |||
@@ -0,0 +1,30 @@ | |||
1 | Created: 2019-01-15T11:15:21.073858657+00:00 | ||
2 | Creator: [email protected] | ||
3 | Source: crates/ra_ide_api_light/src/lib.rs | ||
4 | |||
5 | [ | ||
6 | HighlightedRange { | ||
7 | range: [1; 11), | ||
8 | tag: "comment" | ||
9 | }, | ||
10 | HighlightedRange { | ||
11 | range: [12; 14), | ||
12 | tag: "keyword" | ||
13 | }, | ||
14 | HighlightedRange { | ||
15 | range: [15; 19), | ||
16 | tag: "function" | ||
17 | }, | ||
18 | HighlightedRange { | ||
19 | range: [29; 37), | ||
20 | tag: "macro" | ||
21 | }, | ||
22 | HighlightedRange { | ||
23 | range: [38; 50), | ||
24 | tag: "string" | ||
25 | }, | ||
26 | HighlightedRange { | ||
27 | range: [52; 54), | ||
28 | tag: "literal" | ||
29 | } | ||
30 | ] | ||
diff --git a/crates/ra_ide_api_light/src/structure.rs b/crates/ra_ide_api_light/src/structure.rs index 8bd57555f..3c6f39e16 100644 --- a/crates/ra_ide_api_light/src/structure.rs +++ b/crates/ra_ide_api_light/src/structure.rs | |||
@@ -87,7 +87,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
87 | #[cfg(test)] | 87 | #[cfg(test)] |
88 | mod tests { | 88 | mod tests { |
89 | use super::*; | 89 | use super::*; |
90 | use test_utils::assert_eq_dbg; | 90 | use insta::assert_debug_snapshot_matches; |
91 | 91 | ||
92 | #[test] | 92 | #[test] |
93 | fn test_file_structure() { | 93 | fn test_file_structure() { |
@@ -112,18 +112,6 @@ impl fmt::Debug for E {} | |||
112 | "#, | 112 | "#, |
113 | ); | 113 | ); |
114 | let structure = file_structure(&file); | 114 | let structure = file_structure(&file); |
115 | assert_eq_dbg( | 115 | assert_debug_snapshot_matches!("file_structure", structure); |
116 | r#"[StructureNode { parent: None, label: "Foo", navigation_range: [8; 11), node_range: [1; 26), kind: STRUCT_DEF }, | ||
117 | StructureNode { parent: Some(0), label: "x", navigation_range: [18; 19), node_range: [18; 24), kind: NAMED_FIELD_DEF }, | ||
118 | StructureNode { parent: None, label: "m", navigation_range: [32; 33), node_range: [28; 53), kind: MODULE }, | ||
119 | StructureNode { parent: Some(2), label: "bar", navigation_range: [43; 46), node_range: [40; 51), kind: FN_DEF }, | ||
120 | StructureNode { parent: None, label: "E", navigation_range: [60; 61), node_range: [55; 75), kind: ENUM_DEF }, | ||
121 | StructureNode { parent: None, label: "T", navigation_range: [81; 82), node_range: [76; 88), kind: TYPE_DEF }, | ||
122 | StructureNode { parent: None, label: "S", navigation_range: [96; 97), node_range: [89; 108), kind: STATIC_DEF }, | ||
123 | StructureNode { parent: None, label: "C", navigation_range: [115; 116), node_range: [109; 127), kind: CONST_DEF }, | ||
124 | StructureNode { parent: None, label: "impl E", navigation_range: [134; 135), node_range: [129; 138), kind: IMPL_BLOCK }, | ||
125 | StructureNode { parent: None, label: "impl fmt::Debug for E", navigation_range: [160; 161), node_range: [140; 164), kind: IMPL_BLOCK }]"#, | ||
126 | &structure, | ||
127 | ) | ||
128 | } | 116 | } |
129 | } | 117 | } |
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 9b1c9c9a0..6489033dd 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs | |||
@@ -1,8 +1,6 @@ | |||
1 | use std::fmt; | ||
2 | use std::fs; | 1 | use std::fs; |
3 | use std::path::{Path, PathBuf}; | 2 | use std::path::{Path, PathBuf}; |
4 | 3 | ||
5 | use itertools::Itertools; | ||
6 | use text_unit::{TextRange, TextUnit}; | 4 | use text_unit::{TextRange, TextUnit}; |
7 | use serde_json::Value; | 5 | use serde_json::Value; |
8 | 6 | ||
@@ -31,12 +29,6 @@ macro_rules! assert_eq_text { | |||
31 | }}; | 29 | }}; |
32 | } | 30 | } |
33 | 31 | ||
34 | pub fn assert_eq_dbg(expected: &str, actual: &impl fmt::Debug) { | ||
35 | let actual = format!("{:?}", actual); | ||
36 | let expected = expected.lines().map(|l| l.trim()).join(" "); | ||
37 | assert_eq!(expected, actual); | ||
38 | } | ||
39 | |||
40 | pub fn extract_offset(text: &str) -> (TextUnit, String) { | 32 | pub fn extract_offset(text: &str) -> (TextUnit, String) { |
41 | match try_extract_offset(text) { | 33 | match try_extract_offset(text) { |
42 | None => panic!("text should contain cursor marker"), | 34 | None => panic!("text should contain cursor marker"), |