|  | 
|  | 1 | +;;; solidity-mode-test-setup.el --- Setup and execute all tests | 
|  | 2 | + | 
|  | 3 | +;;; Commentary: | 
|  | 4 | + | 
|  | 5 | +;; This package sets up a suitable enviroment for testing | 
|  | 6 | +;; solidity-mode, and executes the tests. | 
|  | 7 | +;; | 
|  | 8 | +;; Usage: | 
|  | 9 | +;; | 
|  | 10 | +;; emacs -q -l test/solidity-mode-test-setup.el | 
|  | 11 | +;; | 
|  | 12 | +;; Note that this package assumes that some packages are located in | 
|  | 13 | +;; specific locations. | 
|  | 14 | + | 
|  | 15 | +;;; Code: | 
|  | 16 | + | 
|  | 17 | +(setq user-init-file (or load-file-name (buffer-file-name))) | 
|  | 18 | +(setq user-emacs-directory (file-name-directory user-init-file)) | 
|  | 19 | + | 
|  | 20 | +(require 'package) | 
|  | 21 | +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) | 
|  | 22 | +(setq package-enable-at-startup nil) | 
|  | 23 | +(package-initialize) | 
|  | 24 | +(when (not package-archive-contents) | 
|  | 25 | + (package-refresh-contents)) | 
|  | 26 | + | 
|  | 27 | +(defvar bootstrap-version) | 
|  | 28 | +(let ((bootstrap-file | 
|  | 29 | + (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) | 
|  | 30 | + (bootstrap-version 5)) | 
|  | 31 | + (unless (file-exists-p bootstrap-file) | 
|  | 32 | + (with-current-buffer | 
|  | 33 | + (url-retrieve-synchronously | 
|  | 34 | + "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" | 
|  | 35 | + 'silent 'inhibit-cookies) | 
|  | 36 | + (goto-char (point-max)) | 
|  | 37 | + (eval-print-last-sexp))) | 
|  | 38 | + (load bootstrap-file nil 'nomessage)) | 
|  | 39 | + | 
|  | 40 | +(straight-use-package 'use-package) | 
|  | 41 | + | 
|  | 42 | +(add-to-list 'load-path (expand-file-name "./")) | 
|  | 43 | +(add-to-list 'load-path (expand-file-name "./test")) | 
|  | 44 | +(package-install-file "solidity-mode.el") | 
|  | 45 | +(package-install-file "solidity-flycheck.el") | 
|  | 46 | +(global-flycheck-mode 1) | 
|  | 47 | + | 
|  | 48 | +(use-package solidity-mode | 
|  | 49 | + :mode ("\\.sol\\'" . solidity-mode)) | 
|  | 50 | + | 
|  | 51 | +(use-package solidity-flycheck | 
|  | 52 | + :defer t | 
|  | 53 | + :init | 
|  | 54 | + (setq solidity-flycheck-solium-checker-active t) | 
|  | 55 | + (setq solidity-flycheck-solc-checker-active t) | 
|  | 56 | + (setq solidity-flycheck-chaining-error-level t) | 
|  | 57 | + (setq solidity-flycheck-use-project t) | 
|  | 58 | + (setq solidity-flycheck-solc-additional-allow-paths '("~/.brownie/packages")) | 
|  | 59 | + (add-hook | 
|  | 60 | + 'solidity-mode-hook | 
|  | 61 | + (lambda () | 
|  | 62 | + (require 'solidity-flycheck)))) | 
|  | 63 | + | 
|  | 64 | +(require 'ert) | 
|  | 65 | + | 
|  | 66 | +(require 'solidity-flycheck-tests) | 
|  | 67 | + | 
|  | 68 | +(ert t) | 
0 commit comments