Skip to content

Commit

Permalink
Fix test coverage reporting in Travis CI. (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
belambert committed Dec 30, 2017
1 parent 620cd5c commit 05e0164
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Expand Up @@ -19,14 +19,10 @@ env:
- LISP=clisp32
# - LISP=ecl -- This hangs for some reason

matrix:
allow_failures:
- env: "LISP=sbcl COVERALLS=true"

install:
- curl -L https://github.com/luismbo/cl-travis/raw/master/install.sh | sh

script:
- if [[ "$COVERALLS" == "true" ]]; then git clone https://github.com/fukamachi/cl-coveralls ~/lisp/cl-coveralls; fi
- if [[ "$COVERALLS" == "true" ]]; then cl -l edit-distance-test -l edit-distance -l cl-coveralls -e "(coveralls:with-coveralls (:exclude (list \"t\")) $TEST_FORM )"; fi
- if [[ "$COVERALLS" == "true" ]]; then cl -l edit-distance-test -e "(coveralls:with-coveralls (:exclude (list \"t\")) $TEST_FORM )"; fi
- if [[ "$COVERALLS" -ne "true" ]]; then cl -l edit-distance-test -l edit-distance -e "$TEST_FORM"; fi
3 changes: 2 additions & 1 deletion README.md
@@ -1,8 +1,9 @@
edit-distance
=================

[![Build Status](https://travis-ci.org/belambert/cl-edit-distance.svg?branch=master)
](https://travis-ci.org/belambert/cl-edit-distance)
[![Coverage Status](https://coveralls.io/repos/github/belambert/cl-edit-distance/badge.svg?branch=coverage)
](https://coveralls.io/github/belambert/cl-edit-distance?branch=coverage)

Using
-----
Expand Down
11 changes: 8 additions & 3 deletions edit-distance-test.asd
@@ -1,8 +1,8 @@
;;-*- Mode: Lisp -*-
;; -*- Mode: Lisp -*-

(asdf:defsystem "edit-distance-test"
:name "edit-distance-test"
:description "Computing edit distance"
:description "Computing edit distance between sequences."
:version "1.0.0"
:author "Ben Lambert <belambert@mac.com>"
:license "CC-BY-4.0"
Expand All @@ -12,4 +12,9 @@
:serial t
:components
((:file "test"))))
:depends-on ("edit-distance" "lisp-unit"))
:depends-on ("edit-distance"
"lisp-unit"
;; cl-coverage is failing without these
"trivial-features"
"babel"
"cl-coveralls"))
25 changes: 11 additions & 14 deletions src/test.lisp
Expand Up @@ -17,34 +17,31 @@
(in-package :edit-distance-tests)

(define-test test-distance-fast
(let ((result (compute-edit-distance '(1 2 3) '(1 2 4))))
(assert-equal (distance-errors result) 1)
(assert-equal (distance-matches result) 2)))
(let ((result (distance '(1 2 3) '(1 2 4))))
(assert-equal 1 result)))

(define-test test-distance-slow
(multiple-value-bind (path distance)
(levenshtein-distance '("1" "2" "3") '("1" "2" "4") :return-path t)
(diff '("1" "2" "3") '("1" "2" "4"))
(assert-equal path '((:MATCH "1" "1") (:MATCH "2" "2") (:SUBSTITUTION "3" "4")))
(assert-equal distance 1)))

(define-test test-printing
(multiple-value-bind (path distance)
(levenshtein-distance '(0 1 2 3) '(1 2 4 5) :return-path t)
(diff '(0 1 2 3) '(1 2 4 5))
(assert-equal distance 3)
(print-differences path)))
(format-diff path)))

(define-test test-arrays
(let ((result (compute-edit-distance #(1 2 3) #(1 2 4))))
(assert-equal (distance-errors result) 1)
(assert-equal (distance-matches result) 2)))
(let ((result (distance #(1 2 3) #(1 2 4))))
(assert-equal 1 result)))

(define-test test-strings
(let ((result (compute-edit-distance "123" "124")))
(assert-equal (distance-errors result) 1)
(assert-equal (distance-matches result) 2)))
(let ((result (distance "123" "124")))
(assert-equal 1 result)))

(define-test test-string-printing
(multiple-value-bind (path distance)
(levenshtein-distance "0123" "1245" :return-path t)
(diff "0123" "1245")
(assert-equal distance 3)
(print-differences path)))
(format-diff path)))

0 comments on commit 05e0164

Please sign in to comment.