aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2025-02-26 20:41:02 +0800
committerPo Lu2025-02-26 20:58:01 +0800
commit67b444e2907da1a27fc2db64aae9b4dcf299f2d9 (patch)
treeba6e7f872f1f653f7fa23826507ce7b64b43efdd
parent3e496fc31746517440285c2cd9f2b4a09c227d7b (diff)
downloademacs-67b444e2907da1a27fc2db64aae9b4dcf299f2d9.tar.gz
emacs-67b444e2907da1a27fc2db64aae9b4dcf299f2d9.zip
; New function for executing Android tests in batch mode
* test/infra/android/test-controller.el (ats-execute-tests-batch): New function.
-rw-r--r--test/infra/android/test-controller.el67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/infra/android/test-controller.el b/test/infra/android/test-controller.el
index d318c9a0d4b..f17d58e415e 100644
--- a/test/infra/android/test-controller.el
+++ b/test/infra/android/test-controller.el
@@ -2482,6 +2482,73 @@ subject to SELECTOR, as in `ert-run-tests'."
2482 "Running tests..." 2482 "Running tests..."
2483 (ats-run-test process test selector)))) 2483 (ats-run-test process test selector))))
2484 2484
2485
2486
2487;; Batch mode text execution.
2488(defun ats-execute-tests-batch ()
2489 "Execute tests in batch mode, in the manner of `test/Makefile'.
2490Prompt for a device and execute tests on the same. Save log
2491files to a directory specified by the user.
2492Call this function from the command line, with, for example:
2493
2494 $ emacs --batch -l test-controller.el -f ats-execute-tests-batch"
2495 (let* ((ats-adb-host (getenv "ATS_ADB_HOST"))
2496 (devices (ats-enumerate-devices
2497 (lambda (name state _)
2498 (and (equal state "device")
2499 (ignore-errors
2500 (ats-get-package-aid name "org.gnu.emacs")))))))
2501 (message "These devices are presently available for test execution:")
2502 (let ((nth 0))
2503 (dolist (device devices)
2504 (message "%2d. %-24s(API level %d, %s)"
2505 (incf nth) (car device)
2506 (ats-get-sdk-version (car device))
2507 (ats-getprop (car device) "ro.product.cpu.abi"))))
2508 (let* ((number (string-to-number
2509 (read-string
2510 "Select a device by typing its number, and Return: ")))
2511 (device (if (or (< number 1) (> number (length devices)))
2512 (user-error "Invalid selection: %s" number)
2513 (car (nth (1- number) devices))))
2514 (users (ats-list-users device)))
2515 (setq nth 0)
2516 (dolist (user users)
2517 (message "%2d. %s (id=%d)" (incf nth)
2518 (cadr user) (car user)))
2519 (setq number (string-to-number
2520 (read-string
2521 "As which user should tests be executed? ")))
2522 (when (or (< number 1) (> number (length users)))
2523 (user-error "Invalid selection: %s" number))
2524 (let* ((user (car (nth (1- number) users)))
2525 (connection (ats-connect device user)))
2526 (ats-upload-all-tests
2527 connection
2528 (or ats-emacs-test-directory
2529 (read-directory-name "Test base directory: "
2530 nil nil t)))
2531 (let ((output-directory
2532 (read-directory-name
2533 "Where to save test log files? ")))
2534 (mkdir output-directory t)
2535 (let ((tests (ats-list-tests connection)))
2536 (dolist (test tests)
2537 (message "Generating `%s/%s-test.log'"
2538 output-directory test)
2539 (ats-run-test connection test)
2540 (let ((output-file
2541 (concat (file-name-as-directory
2542 output-directory)
2543 test "-test.log")))
2544 (mkdir (file-name-directory output-file) t)
2545 (with-current-buffer "*Test Output*"
2546 (write-region (point-min) (point-max)
2547 (concat (file-name-as-directory
2548 output-directory)
2549 test "-test.log"))
2550 (erase-buffer))))))))))
2551
2485(provide 'test-controller) 2552(provide 'test-controller)
2486 2553
2487;;; test-controller.el ends here 2554;;; test-controller.el ends here