<commit_before>;;;; SPDX-FileCopyrightText: Atlas Engineer LLC
;;;; SPDX-License-Identifier: BSD-3-Clause

(in-package :nyxt-asdf)

(export-always 'nyxt-test-system)
(defclass nyxt-test-system (asdf:system)
  ((targets
    :initform '()  ;; (error "Targets required")
    :initarg :targets
    :reader targets
    :documentation "Arguments passed to `lisp-unit2:run-tests'.
Example:

  :targets '(:package my-app/tests :exclude-tags (:foo my-app/tests::bar))"))
  (:documentation "Specialized systems for Nyxt tests.
It automatically depends on Lisp-Unit2 and calls the appropriate invocation for tests.
You must list what to test, see the `targets' slot.

If the NYXT_TESTS_ERROR_ON_FAIL environment variable is set, quit Lisp on failure.
This is useful for some continuous integration systems.

If the NYXT_TESTS_NO_NETWORK environment variable is set, tests with the `:online' tags are excluded."))
(import 'nyxt-test-system  :asdf-user)

(defmethod asdf:component-depends-on ((op asdf:prepare-op) (c nyxt-test-system))
  `((asdf:load-op "lisp-unit2")
    ,@(call-next-method)))

(defmethod asdf:perform ((op asdf:test-op) (c nyxt-test-system))
  (destructuring-bind (&key package tags exclude-tags &allow-other-keys)
      (targets c)
    (let ((exclude-tags (append (when (getenv "NYXT_TESTS_NO_NETWORK")
                                  '(:online))
                                exclude-tags)))
      (when (and
             (uiop:symbol-call :lisp-unit2 :failed
                               (uiop:symbol-call :lisp-unit2 :run-tests
                                                 :package package
                                                 :tags tags
                                                 :exclude-tags exclude-tags
                                                 :run-contexts (find-symbol "WITH-SUMMARY-CONTEXT" :lisp-unit2)))
             (getenv "NYXT_TESTS_ERROR_ON_FAIL"))
        ;; Arbitrary but hopefully recognizable exit code.
        (quit 18)))))<commit_msg>nyxt-asdf: Report undefined test packages.<commit_after>;;;; SPDX-FileCopyrightText: Atlas Engineer LLC
;;;; SPDX-License-Identifier: BSD-3-Clause

(in-package :nyxt-asdf)

(export-always 'nyxt-test-system)
(defclass nyxt-test-system (asdf:system)
  ((targets
    :initform '()  ;; (error "Targets required")
    :initarg :targets
    :reader targets
    :documentation "Arguments passed to `lisp-unit2:run-tests'.
Example:

  :targets '(:package my-app/tests :exclude-tags (:foo my-app/tests::bar))"))
  (:documentation "Specialized systems for Nyxt tests.
It automatically depends on Lisp-Unit2 and calls the appropriate invocation for tests.
You must list what to test, see the `targets' slot.

If the NYXT_TESTS_ERROR_ON_FAIL environment variable is set, quit Lisp on failure.
This is useful for some continuous integration systems.

If the NYXT_TESTS_NO_NETWORK environment variable is set, tests with the `:online' tags are excluded."))
(import 'nyxt-test-system  :asdf-user)

(defmethod asdf:component-depends-on ((op asdf:prepare-op) (c nyxt-test-system))
  `((asdf:load-op "lisp-unit2")
    ,@(call-next-method)))

(defmethod asdf:perform ((op asdf:test-op) (c nyxt-test-system))
  (destructuring-bind (&key package tags exclude-tags &allow-other-keys)
      (targets c)
    (let ((exclude-tags (append (when (getenv "NYXT_TESTS_NO_NETWORK")
                                  '(:online))
                                exclude-tags)))
      (let ((missing-packages (remove-if  #'find-package (uiop:ensure-list package))))
        (when missing-packages
          (logger "Undefined test packages: ~s" missing-packages)))
      (when (and
             (uiop:symbol-call :lisp-unit2 :failed
                               (uiop:symbol-call :lisp-unit2 :run-tests
                                                 :package package
                                                 :tags tags
                                                 :exclude-tags exclude-tags
                                                 :run-contexts (find-symbol "WITH-SUMMARY-CONTEXT" :lisp-unit2)))
             (getenv "NYXT_TESTS_ERROR_ON_FAIL"))
        ;; Arbitrary but hopefully recognizable exit code.
        (quit 18)))))
{'fraction_non_alphanumeric': 0.11424508177293198, 'fraction_numerical': 0.004266413842142688, 'mean_word_length': 2.3072100313479624, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5300110', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1187, 'n_words': 333}