Skip to content

Commit

Permalink
Merge 6a79a70 into 7b7c2d0
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Dec 29, 2016
2 parents 7b7c2d0 + 6a79a70 commit d0681a0
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 9 deletions.
22 changes: 22 additions & 0 deletions .travis.yml
@@ -0,0 +1,22 @@
language: generic
sudo: false
before_install:
- curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
- evm install $EVM_EMACS --use --skip
- cask
env:
- EVM_EMACS=emacs-24.4-travis
- EVM_EMACS=emacs-24.5-travis
- EVM_EMACS=emacs-25.1-travis
- EVM_EMACS=emacs-git-snapshot-travis
script:
- emacs --version
- make test

notifications:
email: false

matrix:
fast_finish: true
allow_failures:
- env: EVM_EMACS=emacs-git-snapshot-travis
6 changes: 4 additions & 2 deletions Cask
Expand Up @@ -3,5 +3,7 @@

(package-file "ag.el")

(depends-on "dash")
(depends-on "s")
(development
(depends-on "ert-runner")
(depends-on "undercover")
(depends-on "f"))
15 changes: 15 additions & 0 deletions Makefile
@@ -0,0 +1,15 @@
CASK ?= cask
EMACS ?= emacs

all: test

test: unit

unit:
${CASK} exec ert-runner

install:
${CASK} install

bench:
./bench.sh
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -2,6 +2,8 @@

[![MELPA](http://melpa.org/packages/ag-badge.svg)](http://melpa.org/#/ag)
[![MELPA Stable](http://stable.melpa.org/packages/ag-badge.svg)](http://stable.melpa.org/#/ag)
[![Build Status](https://travis-ci.org/Wilfred/ag.el.svg)](https://travis-ci.org/Wilfred/ag.el)
[![Coverage Status](https://coveralls.io/repos/github/Wilfred/ag.el/badge.svg)](https://coveralls.io/github/Wilfred/ag.el)
[![Documentation Status](https://readthedocs.org/projects/agel/badge/?version=latest)](http://agel.readthedocs.io/en/latest/?badge=latest)

Ag.el allows you to search using `ag` from inside Emacs. You can
Expand Down
11 changes: 4 additions & 7 deletions ag.el
Expand Up @@ -281,13 +281,10 @@ Returns an empty string otherwise."
(defun ag/longest-string (&rest strings)
"Given a list of strings and nils, return the longest string."
(let ((longest-string nil))
(dolist (string strings)
(cond ((null longest-string)
(setq longest-string string))
((stringp string)
(when (< (length longest-string)
(length string))
(setq longest-string string)))))
(dolist (string (-non-nil strings))
(when (< (length longest-string)
(length string))
(setq longest-string string)))
longest-string))

(defun ag/replace-first (string before after)
Expand Down
21 changes: 21 additions & 0 deletions test/test-helper.el
@@ -0,0 +1,21 @@
;;; test-helper.el --- Helper for tests -*- lexical-binding: t; -*-

;; Copyright (C) 2016 Wilfred Hughes

;; Author: Wilfred Hughes <me@wilfred.me.uk>

;;; Code:

(require 'ert)
(require 'f)

(let ((ag-el-dir (f-parent (f-dirname (f-this-file)))))
(add-to-list 'load-path ag-el-dir))

(require 'undercover)
(undercover "ag.el"
(:exclude "*-test.el")
(:report-file "/tmp/undercover-report.json"))

(provide 'test-helper)
;;; test-helper.el ends here
17 changes: 17 additions & 0 deletions test/unit-test.el
@@ -0,0 +1,17 @@
(require 'ert)
(require 'ag)

(ert-deftest ag--escape-pcre ()
(should (equal (ag--escape-pcre "ab.*(") "ab\\.\\*\\(")))

(ert-deftest ag--longest-string ()
(should
(equal (ag--longest-string nil "foo" nil "f" "foobarbaz" "z")
"foobarbaz")))

(ert-deftest ag-project ()
"Smoke test for what is probably the most useful command in ag.el"
(ag-project "defun")
(should
(equal (buffer-name)
(format "*ag search text:defun dir:%s*" default-directory))))

0 comments on commit d0681a0

Please sign in to comment.