Skip to content

Commit 1a177e9

Browse files
committed
Add Bats test suite, assertions and fixtures, along with CircleCI hookup
1 parent 7e6af18 commit 1a177e9

File tree

13 files changed

+685
-1
lines changed

13 files changed

+685
-1
lines changed

.gitmodules

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

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: bash
2+
before_install:
3+
- git clone --depth 1 https://github.com/sstephenson/bats.git
4+
- sudo apt-get update -qq
5+
- sudo apt-get install -y coreutils
6+
script:
7+
- ./bats/bin/bats test/*.bats

circle.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
machine:
2+
environment:
3+
4+
5+
dependencies:
6+
post:
7+
- git clone --depth 1 https://github.com/sstephenson/bats.git
8+
9+
checkout:
10+
post:
11+
- git submodule sync
12+
- git submodule update --init
13+
14+
test:
15+
override:
16+
- bats/bin/bats test/*.bats

diff-so-fancy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ hash gsed 2> /dev/null && SED=gsed || SED=sed
99
if hash diff-highlight 2> /dev/null; then
1010
diff_highlight=diff-highlight
1111
else
12-
diff_highlight="$( cd "$( dirname $(realpath "${BASH_SOURCE[0]}") )" && pwd )/third_party/diff-highlight/diff-highlight"
12+
SCRIPT_PATH=$( cd $(dirname $0) ; pwd -P )
13+
diff_highlight="$SCRIPT_PATH/third_party/diff-highlight/diff-highlight"
1314
fi
1415

1516
color_code_regex="(\x1B\[([0-9]{1,3}(;[0-9]{1,3}){0,3})[m|K])?"

readme.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ git --no-pager diff # will avoid core.pager hook
7979

8080
Originated from https://github.com/paulirish/dotfiles/blob/master/bin/diff-so-fancy
8181

82+
## Contributing
83+
84+
Pull requests quite welcome.
85+
86+
## Hacking and Testing
87+
88+
```sh
89+
# fork and clone the repo. then…
90+
91+
git submodule update --init
92+
brew install entr coreutils
93+
# install bats: github.com/sstephenson/bats#installing-bats-from-source
94+
```
95+
96+
```sh
97+
# Run the test suite once:
98+
bats test/diff-so-fancy.bats
99+
100+
# Run it on every change with `entr`
101+
ls --color=never diff-so-fancy test/*.bats | entr bats test/*.bats
102+
```
82103

83104
## License
84105

test/bugs.bats

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bats
2+
3+
load 'test_helper/bats-core/load'
4+
load 'test_helper/bats-assert/load'
5+
load 'test_helper/util'
6+
7+
8+
output=$( load_fixture "chromium-modaltoelement" | $diff_so_fancy )
9+
10+
11+
empty_remove_highlight=""
12+
13+
# https://github.com/paulirish/dotfiles/commit/6743b907ff586c28cd36e08d1e1c634e2968893e#commitcomment-13459061
14+
@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)"
18+
}

test/diff-so-fancy.bats

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bats
2+
3+
load 'test_helper/bats-core/load'
4+
load 'test_helper/bats-assert/load'
5+
load 'test_helper/util'
6+
7+
8+
# bats fails to handle our multiline result, so we save to $output ourselves
9+
output=$( load_fixture "ls-function" | $diff_so_fancy )
10+
11+
@test "diff-so-fancy runs exits without error" {
12+
load_fixture "ls-function" | $diff_so_fancy
13+
assert_success
14+
}
15+
16+
@test "original source is indented by a single space" {
17+
assert_output --partial "
18+
if begin"
19+
}
20+
21+
@test "index line is removed entirely" {
22+
refute_output --partial "index 33c3d8b..fd54db2 100644"
23+
}
24+
25+
@test "+/- line stars are stripped" {
26+
refute_output --partial "
27+
-"
28+
refute_output --partial "
29+
+"
30+
}
31+
32+
@test "empty lines added/removed are marked" {
33+
assert_output --partial " 
34+
  set -x CLICOLOR_FORCE 1"
35+
assert_output --partial " 
36+
if not set -q LS_COLORS"
37+
}
38+
39+
@test "diff-highlight is highlighting changes within lines" {
40+
assert_output --partial 'eval "env CLICOLOR_FORCE=1 command $ls $param $argv"'
41+
assert_output --partial 'eval $ls $param "$argv"'
42+
}
43+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js b/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
2+
index 4f9adf8..8c13743 100644
3+
--- a/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
4+
+++ b/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
5+
@@ -32,7 +32,7 @@
6+
* @constructor
7+
* @extends {WebInspector.Widget}
8+
*/
9+
-WebInspector.Dialog = function()
10+
+WebInspector.Dialog = function(isModalToElement)
11+
{
12+
WebInspector.Widget.call(this, true);
13+
this.markAsRoot();
14+
@@ -45,6 +45,9 @@ WebInspector.Dialog = function()
15+

16+
this._wrapsContent = false;
17+
this._dimmed = false;
18+
+ this._isModalToElement = isModalToElement;
19+
+
20+
+ this._glassPane = new WebInspector.GlassPane(relativeToElement, isModalToElement);
21+
/** @type {!Map<!HTMLElement, number>} */
22+
this._tabIndexMap = new Map();
23+
}
24+
@@ -62,16 +65,16 @@ WebInspector.Dialog.prototype = {
25+
/**
26+
* @override
27+
*/
28+
- show: function()
29+
+ show: function(isModalToElement)
30+
{
31+
if (WebInspector.Dialog._instance)
32+
WebInspector.Dialog._instance.detach();
33+
WebInspector.Dialog._instance = this;
34+

35+
- var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostView.element.ownerDocument);
36+
+ var document = /** @type {!Document} */ (WebInspector.Dialog._modalHostView.element.ownerDocument, isModalToElement);
37+
this._disableTabIndexOnElements(document);
38+

39+
- this._glassPane = new WebInspector.GlassPane(document, this._dimmed);
40+
+ this._glassPane = new WebInspector.GlassPane(document, isModalToElement);
41+
this._glassPane.element.addEventListener("click", this._onGlassPaneClick.bind(this), false);
42+
WebInspector.GlassPane.DefaultFocusedViewStack.push(this);
43+


0 commit comments

Comments
 (0)