edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | |
| 2 | //! Test-only access to a crate module's SOURCE TEXT. |
| 3 | //! |
| 4 | //! The source-scanning gates used to `include_str!("decode.rs")`, which names |
| 5 | //! one file. Once a module is split into a directory (`decode/mod.rs` plus its |
| 6 | //! children) that include stops compiling, and every gate pinning it goes stale |
| 7 | //! on the next move. These helpers read the module's files at test run time |
| 8 | //! instead: `src/<name>.rs` when it exists, then every `*.rs` under |
| 9 | //! `src/<name>/` recursively, concatenated in sorted path order. A file added to |
| 10 | //! that directory is therefore scanned without touching any gate. |
| 11 | //! |
| 12 | //! [`module_production_source`] is the same text minus the test-only files |
| 13 | //! (`tests.rs` and `*_tests.rs`), for gates that must not count their own test |
| 14 | //! fixtures. An inline `mod tests { .. }` in a single file is not removed by |
| 15 | //! that function; a gate that needs the production prefix cuts it itself. |
| 16 | |
| 17 | use BTreeMap; |
| 18 | use ; |
| 19 | use ; |
| 20 | |
| 21 | type Cache = ; |
| 22 | static CACHE: = new; |
| 23 | |
| 24 | /// The whole source text of module `name`: `src/<name>.rs` and every `*.rs` |
| 25 | /// under `src/<name>/`, in sorted path order. |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | /// [`module_source`] without the test-only files (`tests.rs`, `*_tests.rs`). |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | /// Each module is read once per test process. The text is leaked, which is |
| 36 | /// bounded by the handful of modules the gates name and is test-only. |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 |