Skip to content

Commit 3100a88

Browse files
committed
rustic-babel: Fixes src blocks with local crate paths.
Adds new justfile target: test-one Run the test via: just test-one rustic-test-babel-block-with-paths
1 parent 9fdf5c7 commit 3100a88

File tree

7 files changed

+35
-1
lines changed

7 files changed

+35
-1
lines changed

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ build:
1212
test:
1313
eask compile
1414
eask emacs --batch -L . -L test -l test/all-tests.el -f ert-run-tests-batch-and-exit
15+
16+
test-one TEST_NAME:
17+
eask compile
18+
eask emacs --batch -L . -L test -l test/rustic-babel-test.el -eval '(ert-run-tests-batch-and-exit "{{TEST_NAME}}")'

rustic-babel.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ Use VERSION, FEATURES and PATH."
287287
(cdr crate-and-version)
288288
"*"))
289289
(features (cdr (assoc name crate-features)))
290-
(path (cdr (assoc name crate-paths))))
290+
(path (cadr (assoc name crate-paths))))
291291

292292
;; make sure it works with symbols and strings
293293
(when (symbolp name)

test/rustic-babel-test.el

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,22 @@
295295
(rustic-test-babel-execute-block buf)
296296
(should (string-equal (rustic-test-babel-check-results buf) "[[\"A\", \"B\"], [\"C\", \"D\"]]\n")))))
297297

298+
(ert-deftest rustic-test-babel-block-with-paths ()
299+
(let* ((current-test-dir (or (and load-file-name (file-name-directory load-file-name))
300+
(and buffer-file-name (file-name-directory buffer-file-name))
301+
default-directory)) ; Fallback to `default-directory`
302+
(string "use foo;
303+
use bar;
304+
fn main() {
305+
foo::foo();
306+
bar::bar();
307+
}")
308+
(params (format ":paths '((foo \"%s/test-project/crates/foo\") (bar \"%s/test-project/crates/bar\")) :crates '((foo . 0.0.1) (bar . 0.0.1))"
309+
(expand-file-name "test" current-test-dir) (expand-file-name "test" current-test-dir)))
310+
(buf (rustic-test-get-babel-block string params)))
311+
(with-current-buffer buf
312+
(rustic-test-babel-execute-block buf)
313+
(should (eq (rustic-test-babel-check-results buf) nil)))))
314+
315+
298316
(provide 'rustic-babel-test)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[package]
2+
name = "bar"
3+
version = "0.0.1"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn bar() {
2+
()
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[package]
2+
name = "foo"
3+
version = "0.0.1"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn foo() {
2+
()
3+
}

0 commit comments

Comments
 (0)