|
38 | 38 | (defun crate-file (file-name)
|
39 | 39 | (expand-file-name file-name "tests/test-crate"))
|
40 | 40 |
|
| 41 | +(defun crate-with-features-file (file-name) |
| 42 | + (expand-file-name file-name "tests/crate-with-features")) |
| 43 | + |
41 | 44 | (defun lib-crate-file (file-name)
|
42 | 45 | (expand-file-name file-name "tests/custom-lib-target"))
|
43 | 46 |
|
44 | 47 | (defun build-script-crate-file (file-name)
|
45 | 48 | (expand-file-name file-name "tests/build-script-test"))
|
46 | 49 |
|
| 50 | +(defun cdrassoc (sym alist) (cdr (assoc sym alist))) |
| 51 | + |
47 | 52 | (describe
|
48 | 53 | "`flycheck-rust-find-cargo-target' associates"
|
49 | 54 |
|
50 | 55 | (it "'src/lib.rs' to the library target"
|
51 | 56 | (expect
|
52 |
| - (car (flycheck-rust-find-cargo-target (crate-file "src/lib.rs"))) |
| 57 | + (cdrassoc 'kind (flycheck-rust-find-cargo-target (crate-file "src/lib.rs"))) |
53 | 58 | :to-equal "lib"))
|
54 | 59 |
|
55 | 60 | (it "'src/a.rs' to the library target"
|
56 | 61 | (expect
|
57 |
| - (car (flycheck-rust-find-cargo-target (crate-file "src/a.rs"))) |
| 62 | + (cdrassoc 'kind (flycheck-rust-find-cargo-target (crate-file "src/a.rs"))) |
58 | 63 | :to-equal "lib"))
|
59 | 64 |
|
60 | 65 | (it "'src/main.rs' to the main binary target"
|
61 | 66 | (expect
|
62 | 67 | (flycheck-rust-find-cargo-target (crate-file "src/main.rs"))
|
63 |
| - :to-equal '("bin" . "test-crate"))) |
| 68 | + :to-equal '((kind . "bin") (name . "test-crate")))) |
64 | 69 |
|
65 | 70 | (it "'src/bin/a.rs' to the 'a' binary target"
|
66 | 71 | (expect
|
67 | 72 | (flycheck-rust-find-cargo-target (crate-file "src/bin/a.rs"))
|
68 |
| - :to-equal '("bin" . "a"))) |
| 73 | + :to-equal '((kind . "bin") (name . "a")))) |
69 | 74 |
|
70 | 75 | (it "'src/bin/b.rs' to the 'b' binary target"
|
71 | 76 | (expect
|
72 | 77 | (flycheck-rust-find-cargo-target (crate-file "src/bin/b.rs"))
|
73 |
| - :to-equal '("bin" . "b"))) |
| 78 | + :to-equal '((kind . "bin") (name . "b")))) |
74 | 79 |
|
75 | 80 | (it "'src/bin/support/mod.rs' to any binary target"
|
76 | 81 | (expect
|
77 | 82 | (flycheck-rust-find-cargo-target (crate-file "src/bin/support/mod.rs"))
|
78 |
| - :to-equal-one-of '("bin". "a") '("bin". "b"))) |
| 83 | + :to-equal-one-of |
| 84 | + '((kind . "bin") (name . "a")) |
| 85 | + '((kind . "bin") (name . "b")))) |
79 | 86 |
|
80 | 87 | (it "'tests/a.rs' to the 'a' test target"
|
81 | 88 | (expect
|
82 | 89 | (flycheck-rust-find-cargo-target (crate-file "tests/a.rs"))
|
83 |
| - :to-equal '("test" . "a"))) |
| 90 | + :to-equal '((kind . "test") (name . "a")))) |
84 | 91 |
|
85 | 92 | (it "'tests/support/mod.rs' to any test target"
|
86 | 93 | (expect
|
87 | 94 | (flycheck-rust-find-cargo-target (crate-file "tests/support/mod.rs"))
|
88 |
| - :to-equal-one-of '("test". "a") '("test". "b"))) |
| 95 | + :to-equal-one-of |
| 96 | + '((kind . "test") (name . "a")) |
| 97 | + '((kind . "test") (name . "b")))) |
89 | 98 |
|
90 | 99 | (it "'examples/a.rs' to the 'a' example target"
|
91 | 100 | (expect
|
92 | 101 | (flycheck-rust-find-cargo-target (crate-file "examples/a.rs"))
|
93 |
| - :to-equal '("example" . "a"))) |
| 102 | + :to-equal '((kind . "example") (name . "a")))) |
94 | 103 |
|
95 | 104 | (it "'examples/b.rs' to the 'b' example target"
|
96 | 105 | (expect
|
97 | 106 | (flycheck-rust-find-cargo-target (crate-file "examples/b.rs"))
|
98 |
| - :to-equal '("example" . "b"))) |
| 107 | + :to-equal '((kind . "example") (name . "b")))) |
99 | 108 |
|
100 | 109 | (it "'examples/support/mod.rs' to any example target"
|
101 | 110 | (expect
|
102 | 111 | (flycheck-rust-find-cargo-target (crate-file "examples/support/mod.rs"))
|
103 |
| - :to-equal-one-of '("example" . "a") '("example" . "b"))) |
| 112 | + :to-equal-one-of |
| 113 | + '((kind . "example") (name . "a")) |
| 114 | + '((kind . "example") (name . "b")))) |
104 | 115 |
|
105 | 116 | (it "'benches/a.rs' to the 'a' bench target"
|
106 | 117 | (expect
|
107 | 118 | (flycheck-rust-find-cargo-target (crate-file "benches/a.rs"))
|
108 |
| - :to-equal '("bench" . "a"))) |
| 119 | + :to-equal '((kind . "bench") (name . "a")))) |
109 | 120 |
|
110 | 121 | (it "'benches/b.rs' to the 'b' bench target"
|
111 | 122 | (expect
|
112 | 123 | (flycheck-rust-find-cargo-target (crate-file "benches/b.rs"))
|
113 |
| - :to-equal '("bench" . "b"))) |
| 124 | + :to-equal '((kind . "bench") (name . "b")))) |
114 | 125 |
|
115 | 126 | (it "'benches/support/mod.rs' to any bench target"
|
116 | 127 | (expect
|
117 | 128 | (flycheck-rust-find-cargo-target (crate-file "benches/support/mod.rs"))
|
118 |
| - :to-equal-one-of '("bench" . "a") '("bench" . "b"))) |
| 129 | + :to-equal-one-of |
| 130 | + '((kind . "bench") (name . "a")) |
| 131 | + '((kind . "bench") (name . "b")))) |
119 | 132 |
|
120 | 133 | (it "'src/lib.rs' to the library target (custom-lib-target)"
|
121 | 134 | (expect
|
122 | 135 | (car (flycheck-rust-find-cargo-target (lib-crate-file "src/lib.rs")))
|
123 |
| - :to-equal "lib")) |
| 136 | + :to-equal '(kind . "lib"))) |
124 | 137 |
|
125 | 138 | (it "'build.rs' to any target in the same workspace member (parent)"
|
126 | 139 | (expect
|
127 | 140 | (flycheck-rust-find-cargo-target (build-script-crate-file "build.rs"))
|
128 |
| - :to-equal (cons "bin" "build-script-test"))) |
| 141 | + :to-equal '((kind . "bin") (name . "build-script-test")))) |
129 | 142 |
|
130 | 143 | (it "'build.rs' to any target in the same workspace member (child)"
|
131 | 144 | (expect
|
132 | 145 | (flycheck-rust-find-cargo-target (build-script-crate-file "lib-test/build.rs"))
|
133 |
| - :to-equal (cons "lib" "lib-test"))) |
| 146 | + :to-equal '((kind . "lib") (name . "lib-test")))) |
| 147 | + |
| 148 | + (it "'src/main.rs' to the bin target with required-features (fea1)" |
| 149 | + (expect |
| 150 | + (flycheck-rust-find-cargo-target (crate-with-features-file "src/main.rs")) |
| 151 | + :to-equal '((kind . "bin") (name . "main") (required-features . ("fea1"))))) |
| 152 | + |
| 153 | + (it "'example/example.rs' to the example target with required-features (fea1 fea2)" |
| 154 | + (expect |
| 155 | + (flycheck-rust-find-cargo-target (crate-with-features-file "example/example.rs")) |
| 156 | + :to-equal '((kind . "example") |
| 157 | + (name . "example") |
| 158 | + (required-features . ("fea1" "fea2"))))) |
134 | 159 | )
|
0 commit comments