forked from ethereum/emacs-solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d14acf9
commit 9b1b709
Showing
3 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
solidity-mode.elc | ||
solidity-mode.elc | ||
test/elpa | ||
test/straight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
;;; solidity-flycheck-tests.el --- Setup and execute all tests | ||
|
||
;;; Commentary: | ||
|
||
;; This package contains tests for the solidity-flycheck package. | ||
|
||
;;; Code: | ||
|
||
(require 'solidity-flycheck) | ||
|
||
(ert-deftest test-solidity-flycheck--solc-allow-paths () | ||
"Test that `solidity-flycheck--solc-allow-paths' contains `solidity-flycheck-solc-additional-allow-paths'." | ||
(let ((solidity-flycheck-solc-additional-allow-paths '("/tmp/test1" "/tmp/test2"))) | ||
(should (equal | ||
(solidity-flycheck--solc-allow-paths) | ||
'("/tmp/test1" "/tmp/test2" "."))))) | ||
|
||
(defmacro with-temp-dirs (temp-dirs &rest body) | ||
(let ((bindings (mapcar (lambda (d) `(,d (make-temp-file "" t))) | ||
temp-dirs))) | ||
`(let ,bindings | ||
(unwind-protect | ||
(progn | ||
,@body) | ||
(progn | ||
(dolist (d (list ,@temp-dirs)) | ||
(delete-directory d t))))))) | ||
|
||
(ert-deftest test-solidity-flycheck--solc-remappings () | ||
"Test that `solidity-flycheck--solc-remappings' creates remappings for path in `solidity-flycheck--solc-allow-paths'" | ||
(with-temp-dirs | ||
(test-dir-1 test-dir-2 test-dir-3) | ||
(let* ((default-directory test-dir-1) | ||
(solidity-flycheck-solc-additional-allow-paths (list test-dir-2 test-dir-3))) | ||
(make-directory (concat (file-name-as-directory test-dir-2) "subdir1")) | ||
(make-directory (concat (file-name-as-directory test-dir-3) "@subdir2")) | ||
(should (equal | ||
(solidity-flycheck--solc-remappings) | ||
(list (concat "subdir1=" (concat (file-name-as-directory test-dir-2) "subdir1")) | ||
(concat "@subdir2=" (concat (file-name-as-directory test-dir-3) "@subdir2"))))))) | ||
) | ||
|
||
(provide 'solidity-flycheck-tests) | ||
;;; solidity-flycheck-tests.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
;;; solidity-mode-test-setup.el --- Setup and execute all tests | ||
|
||
;;; Commentary: | ||
|
||
;; This package sets up a suitable enviroment for testing | ||
;; solidity-mode, and executes the tests. | ||
;; | ||
;; Usage: | ||
;; | ||
;; emacs -q -l test/solidity-mode-test-setup.el | ||
;; | ||
;; Note that this package assumes that some packages are located in | ||
;; specific locations. | ||
|
||
;;; Code: | ||
|
||
(setq user-init-file (or load-file-name (buffer-file-name))) | ||
(setq user-emacs-directory (file-name-directory user-init-file)) | ||
|
||
(require 'package) | ||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) | ||
(setq package-enable-at-startup nil) | ||
(package-initialize) | ||
(when (not package-archive-contents) | ||
(package-refresh-contents)) | ||
|
||
(defvar bootstrap-version) | ||
(let ((bootstrap-file | ||
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) | ||
(bootstrap-version 5)) | ||
(unless (file-exists-p bootstrap-file) | ||
(with-current-buffer | ||
(url-retrieve-synchronously | ||
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" | ||
'silent 'inhibit-cookies) | ||
(goto-char (point-max)) | ||
(eval-print-last-sexp))) | ||
(load bootstrap-file nil 'nomessage)) | ||
|
||
(straight-use-package 'use-package) | ||
|
||
(add-to-list 'load-path (expand-file-name "./")) | ||
(add-to-list 'load-path (expand-file-name "./test")) | ||
(package-install-file "solidity-mode.el") | ||
(package-install-file "solidity-flycheck.el") | ||
(global-flycheck-mode 1) | ||
|
||
(use-package solidity-mode | ||
:mode ("\\.sol\\'" . solidity-mode)) | ||
|
||
(use-package solidity-flycheck | ||
:defer t | ||
:init | ||
(setq solidity-flycheck-solium-checker-active t) | ||
(setq solidity-flycheck-solc-checker-active t) | ||
(setq solidity-flycheck-chaining-error-level t) | ||
(setq solidity-flycheck-use-project t) | ||
(setq solidity-flycheck-solc-additional-allow-paths '("~/.brownie/packages")) | ||
(add-hook | ||
'solidity-mode-hook | ||
(lambda () | ||
(require 'solidity-flycheck)))) | ||
|
||
(require 'ert) | ||
|
||
(require 'solidity-flycheck-tests) | ||
|
||
(ert t) |