Skip to content

Commit deb2780

Browse files
Merge branch 'next' of github.com:so-fancy/diff-so-fancy into next
2 parents b08ea1d + 9f12df5 commit deb2780

File tree

13 files changed

+43
-44
lines changed

13 files changed

+43
-44
lines changed

.circleci/config.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ jobs:
55
steps:
66
- checkout
77
- run:
8-
name:
8+
name:
99
command: |
1010
sudo apt-get -y update
1111
sudo apt-get -y install shellcheck git
12-
13-
- run: git clone --depth 1 https://github.com/sstephenson/bats.git
12+
13+
- run: git submodule sync
1414
- run: git submodule update --init
1515
- run:
1616
name: tests
1717
command: |
18-
export TERM=dumb && bats/bin/bats test/*.bats
18+
export TERM=dumb && ./test/bats/bin/bats test
1919
shellcheck *.sh
20-

.gitmodules

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
[submodule "test/test_helper/bats-core"]
1+
[submodule "test/bats"]
2+
path = test/bats
3+
url = https://github.com/bats-core/bats-core.git
4+
[submodule "test/test_helper/bats-support"]
25
path = test/test_helper/bats-support
3-
url = https://github.com/ztombol/bats-core
6+
url = https://github.com/bats-core/bats-support.git
47
[submodule "test/test_helper/bats-assert"]
58
path = test/test_helper/bats-assert
6-
url = https://github.com/ztombol/bats-assert
9+
url = https://github.com/bats-core/bats-assert.git

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ addons:
2929
update: true
3030

3131
before_install:
32-
- git clone --depth 1 https://github.com/sstephenson/bats.git
32+
- git submodule sync
33+
- git submodule update --init
3334
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
3435
mkdir -p ~/perl5;
3536
fi
@@ -44,4 +45,4 @@ install:
4445
- cpanm --quiet --notest Test::Perl::Critic Perl::Critic::Freenode
4546
script:
4647
- perlcritic -1 -q --theme freenode diff-so-fancy
47-
- ./bats/bin/bats test/*.bats
48+
- ./test/bats/bin/bats test

appveyor.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
install:
2-
- git clone --depth 1 https://github.com/sstephenson/bats.git
3-
41
build: false
52

63
before_test:
4+
- git submodule sync
75
- git submodule update --init
86

97
test_script:
10-
- C:\cygwin\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER; bats/libexec/bats test/*.bats"
8+
- C:\cygwin\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER; ./test/bats/bin/bats test"

diff-so-fancy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,11 +1043,11 @@ sub yes_no {
10431043
}
10441044

10451045
sub init_diff_highlight_colors {
1046-
$DiffHighlight::NEW_HIGHLIGHT[0] = git_ansi_color(git_config('color.diff-highlight.newnormal')) || "\e[1;32m";
1047-
$DiffHighlight::NEW_HIGHLIGHT[1] = git_ansi_color(git_config('color.diff-highlight.newhighlight')) || "\e[1;32;48;5;22m";
1046+
$DiffHighlight::NEW_HIGHLIGHT[0] = git_ansi_color(git_config('color.diff-highlight.newnormal')) || color("2_bold");
1047+
$DiffHighlight::NEW_HIGHLIGHT[1] = git_ansi_color(git_config('color.diff-highlight.newhighlight')) || color("2_bold") . color("on_22");
10481048

1049-
$DiffHighlight::OLD_HIGHLIGHT[0] = git_ansi_color(git_config('color.diff-highlight.oldnormal')) || "\e[1;31m";
1050-
$DiffHighlight::OLD_HIGHLIGHT[1] = git_ansi_color(git_config('color.diff-highlight.oldhighlight')) || "\e[1;31;48;5;52m";
1049+
$DiffHighlight::OLD_HIGHLIGHT[0] = git_ansi_color(git_config('color.diff-highlight.oldnormal')) || color("1_bold");
1050+
$DiffHighlight::OLD_HIGHLIGHT[1] = git_ansi_color(git_config('color.diff-highlight.oldhighlight')) || color("1_bold") . color("on_52");
10511051
}
10521052

10531053
# vim: tabstop=4 shiftwidth=4 noexpandtab autoindent softtabstop=4

hacking-and-testing.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,18 @@ cd ~/projects/catfabulator && git diff
1414

1515
### Running tests
1616

17-
You'll need to install [bats](https://github.com/sstephenson/bats#installing-bats-from-source), the Bash automated testing system. It's also available as `brew install bats`
17+
The tests use [bats-core](https://bats-core.readthedocs.io/en/latest/index.html), the Bash automated testing system.
1818

1919
```sh
20-
git submodule sync
21-
git submodule update --init # pull in the assertion library, bats-assert
20+
# initalize the bats components
21+
git submodule sync && git submodule update --init
2222

2323
# run the test suite once:
24-
bats test
24+
./test/bats/bin/bats test
2525

2626
# run it on every change with `entr`
2727
brew install entr
28-
ls --color=never diff-so-fancy test/*.bats | entr bats test
28+
find ./* test/* test/fixtures/* -maxdepth 0 | entr ./test/bats/bin/bats test
2929
```
30-
When writing assertions, you'll likely want to compare to expected output. To grab that reliably, you can use something like `git --no-pager diff | diff-so-fancy > output.txt`
3130

32-
You can lint your scripts via shellcheck, our CI bots will also check.
33-
34-
```sh
35-
brew install shellcheck
36-
shellcheck *.sh
31+
When writing assertions, you'll likely want to compare to expected output. To grab that reliably, you can use something like `git --no-pager diff | ./diff-so-fancy > output.txt`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"diff-so-fancy": "diff-so-fancy"
77
},
88
"scripts": {
9-
"test": "bats test"
9+
"test": "./test/bats/bin/bats test"
1010
},
1111
"repository": {
1212
"type": "git",

test/bats

Submodule bats added at 49b377a

test/bugs.bats

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ load 'test_helper/bats-support/load'
44
load 'test_helper/bats-assert/load'
55
load 'test_helper/util'
66

7-
8-
output=$( load_fixture "chromium-modaltoelement" | $diff_so_fancy )
9-
10-
11-
empty_remove_highlight=""
12-
137
# https://github.com/paulirish/dotfiles/commit/6743b907ff586c28cd36e08d1e1c634e2968893e#commitcomment-13459061
148
@test "All removed lines are present in diff" {
15-
assert_output --partial "WebInspector.Dialog = function($empty_remove_highlight)"
16-
assert_output --partial "show: function($empty_remove_highlight)"
17-
assert_output --partial "{!Document} */ (WebInspector.Dialog._modalHostView.element.ownerDocument$empty_remove_highlight)"
9+
output=$( load_fixture "chromium-modaltoelement" | $diff_so_fancy )
10+
run printf "%s" "$output"
11+
12+
assert_line --index 7 --partial "WebInspector.Dialog"
13+
assert_line --index 7 --partial "5;52m" # red oldhighlight
14+
assert_line --index 8 --partial "WebInspector.Dialog"
15+
assert_line --index 8 --partial "5;22m" # green newhighlight
1816
}
1917

2018
@test "File with space in the name (#360)" {
@@ -28,6 +26,6 @@ empty_remove_highlight=""
2826
output=$( load_fixture "add_remove_empty_lines" | $diff_so_fancy )
2927
run printf "%s" "$output"
3028

31-
assert_line --index 5 --partial "[7m[1;32"
32-
assert_line --index 8 --partial "[7m[1;31"
29+
assert_line --index 5 --partial "5;22m" # green added line
30+
assert_line --index 8 --partial "5;52m" # red removed line
3331
}

test/diff-so-fancy.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ output=$( load_fixture "ls-function" | $diff_so_fancy )
1111

1212
@test "diff-so-fancy runs exits without error" {
1313
load_fixture "ls-function" | $diff_so_fancy
14-
assert_success
14+
run assert_success
1515
}
1616

1717
@test "index line is removed entirely" {

0 commit comments

Comments
 (0)