|
341 | 341 | :class "clojure.lang.AFn"
|
342 | 342 | :method "applyToHelper"
|
343 | 343 | :type :java
|
344 |
| - :flags #{:java}} |
| 344 | + :flags #{:java :tooling}} |
345 | 345 | (dissoc (first stacktrace) :file-url))))
|
346 | 346 | (testing "last frame"
|
347 | 347 | (is (= {:name "java.lang.Thread/run"
|
|
350 | 350 | :class "java.lang.Thread"
|
351 | 351 | :method "run"
|
352 | 352 | :type :java
|
353 |
| - :flags #{:java}} |
| 353 | + :flags #{:java :tooling}} |
354 | 354 | (dissoc (last stacktrace) :file-url)))))))
|
355 | 355 | (testing "second cause"
|
356 | 356 | (let [{:keys [class data message stacktrace]} (second causes)]
|
|
369 | 369 | :class "clojure.lang.AFn"
|
370 | 370 | :method "applyToHelper"
|
371 | 371 | :type :java
|
372 |
| - :flags #{:java}} |
| 372 | + :flags #{:java :tooling}} |
373 | 373 | (dissoc (first stacktrace) :file-url)))))))
|
374 | 374 | (testing "third cause"
|
375 | 375 | (let [{:keys [class data message stacktrace]} (nth causes 2)]
|
|
388 | 388 | :class "clojure.lang.AFn"
|
389 | 389 | :method "applyToHelper"
|
390 | 390 | :type :java
|
391 |
| - :flags #{:java}} |
| 391 | + :flags #{:java :tooling}} |
392 | 392 | (dissoc (first stacktrace) :file-url)))))))))
|
393 | 393 |
|
394 | 394 | (deftest test-analyze-short-clojure-tagged-literal-println
|
|
411 | 411 | :class "java.lang.Thread"
|
412 | 412 | :method "run"
|
413 | 413 | :type :java
|
414 |
| - :flags #{:java}} |
| 414 | + :flags #{:java :tooling}} |
415 | 415 | (dissoc (first stacktrace) :file-url)))))))))
|
416 | 416 |
|
417 | 417 | (deftest test-analyze-java
|
|
434 | 434 | :class "clojure.lang.AFn"
|
435 | 435 | :method "applyToHelper"
|
436 | 436 | :type :java
|
437 |
| - :flags #{:java}} |
| 437 | + :flags #{:java :tooling}} |
438 | 438 | (dissoc (first stacktrace) :file-url))))
|
439 | 439 | (testing "last frame"
|
440 | 440 | (is (= {:name "java.lang.Thread/run"
|
|
443 | 443 | :class "java.lang.Thread"
|
444 | 444 | :method "run"
|
445 | 445 | :type :java
|
446 |
| - :flags #{:java}} |
| 446 | + :flags #{:java :tooling}} |
447 | 447 | (dissoc (last stacktrace) :file-url)))))))
|
448 | 448 | (testing "second cause"
|
449 | 449 | (let [{:keys [class data message stacktrace]} (second causes)]
|
|
462 | 462 | :class "clojure.lang.AFn"
|
463 | 463 | :method "applyToHelper"
|
464 | 464 | :type :java
|
465 |
| - :flags #{:java}} |
| 465 | + :flags #{:java :tooling}} |
466 | 466 | (dissoc (first stacktrace) :file-url))))
|
467 | 467 | (testing "last frame"
|
468 | 468 | (is (= {:name "clojure.lang.Compiler$InvokeExpr/eval"
|
|
490 | 490 | :class "clojure.lang.AFn"
|
491 | 491 | :method "applyToHelper"
|
492 | 492 | :type :java
|
493 |
| - :flags #{:java}} |
| 493 | + :flags #{:java :tooling}} |
494 | 494 | (dissoc (first stacktrace) :file-url))))
|
495 | 495 | (testing "last frame"
|
496 | 496 | (is (= {:name "clojure.lang.Compiler$InvokeExpr/eval"
|
|
544 | 544 | :class "clojure.lang.AFn"
|
545 | 545 | :method "applyToHelper"
|
546 | 546 | :type :java
|
547 |
| - :flags #{:java}} |
| 547 | + :flags #{:java :tooling}} |
548 | 548 | (dissoc (nth stacktrace 0) :file-url))))
|
549 | 549 | (testing "2nd frame"
|
550 | 550 | (is (= {:class "clojure.lang.AFn"
|
551 | 551 | :file "AFn.java"
|
552 |
| - :flags #{:java} |
| 552 | + :flags #{:java :tooling} |
553 | 553 | :line 144
|
554 | 554 | :method "applyTo"
|
555 | 555 | :name "clojure.lang.AFn/applyTo"
|
|
572 | 572 | :line 160
|
573 | 573 | :method "applyToHelper"
|
574 | 574 | :type :java
|
575 |
| - :flags #{:java}} |
| 575 | + :flags #{:java :tooling}} |
576 | 576 | (dissoc (nth stacktrace 0) :file-url)))))))
|
577 | 577 | (testing "third cause"
|
578 | 578 | (let [{:keys [class data message stacktrace]} (nth causes 2 nil)]
|
|
591 | 591 | :line 156
|
592 | 592 | :method "applyToHelper"
|
593 | 593 | :type :java
|
594 |
| - :flags #{:java}} |
| 594 | + :flags #{:java :tooling}} |
595 | 595 | (dissoc (nth stacktrace 0) :file-url))))))))
|
596 | 596 |
|
597 | 597 | (let [{:keys [major minor]} *clojure-version*]
|
|
604 | 604 | (catch Throwable e
|
605 | 605 | (sut/analyze e)))
|
606 | 606 | (map :phase))))))))
|
| 607 | + |
| 608 | +(deftest tooling-frame-name? |
| 609 | + (are [frame-name expected] (testing frame-name |
| 610 | + (is (= expected |
| 611 | + (#'sut/tooling-frame-name? frame-name false))) |
| 612 | + true) |
| 613 | + "cider.foo" true |
| 614 | + "acider.foo" false |
| 615 | + ;; `+` is "application" level, should not be hidden: |
| 616 | + "clojure.core/+" false |
| 617 | + ;; `apply` typically is internal, should be hidden: |
| 618 | + "clojure.core/apply" true |
| 619 | + "clojure.core/binding-conveyor-fn/fn" true |
| 620 | + "clojure.core/eval" true |
| 621 | + "clojure.core/with-bindings*" true |
| 622 | + "clojure.lang.AFn/applyTo" true |
| 623 | + "clojure.lang.AFn/applyToHelper" true |
| 624 | + "clojure.lang.RestFn/invoke" true |
| 625 | + "clojure.main/repl" true |
| 626 | + "clojure.main$repl$read_eval_print__9234$fn__9235/invoke" true |
| 627 | + "nrepl.foo" true |
| 628 | + "nrepl.middleware.interruptible_eval$evaluate/invokeStatic" true |
| 629 | + "anrepl.foo" false |
| 630 | + ;; important case - `Numbers` is relevant, should not be hidden: |
| 631 | + "clojure.lang.Numbers/divide" false) |
| 632 | + |
| 633 | + (is (not (#'sut/tooling-frame-name? "java.lang.Thread/run" false))) |
| 634 | + (is (#'sut/tooling-frame-name? "java.lang.Thread/run" true))) |
| 635 | + |
| 636 | +(deftest flag-tooling |
| 637 | + (is (= [{:name "cider.foo", :flags #{:tooling}} |
| 638 | + {:name "java.lang.Thread/run"} ;; does not get the flag because it's not the root frame |
| 639 | + {:name "don't touch me 1"} |
| 640 | + {:name "nrepl.foo", :flags #{:tooling}} |
| 641 | + {:name "clojure.lang.RestFn/invoke", :flags #{:tooling}} |
| 642 | + {:name "don't touch me 2"} |
| 643 | + ;; gets the flag because it's not the root frame: |
| 644 | + {:name "java.lang.Thread/run", :flags #{:tooling}}] |
| 645 | + (#'sut/flag-tooling [{:name "cider.foo"} |
| 646 | + {:name "java.lang.Thread/run"} |
| 647 | + {:name "don't touch me 1"} |
| 648 | + {:name "nrepl.foo"} |
| 649 | + {:name "clojure.lang.RestFn/invoke"} |
| 650 | + {:name "don't touch me 2"} |
| 651 | + {:name "java.lang.Thread/run"}])) |
| 652 | + "Adds the flag when appropiate, leaving other entries untouched")) |
0 commit comments