Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add test suite #53

Merged
merged 1 commit into from
Feb 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "test/test_helper/bats-core"]
path = test/test_helper/bats-core
url = https://github.com/ztombol/bats-core
[submodule "test/test_helper/bats-assert"]
path = test/test_helper/bats-assert
url = https://github.com/ztombol/bats-assert
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: bash
before_install:
- git clone --depth 1 https://github.com/sstephenson/bats.git
- sudo apt-get update -qq
- sudo apt-get install -y coreutils
script:
- ./bats/bin/bats test/*.bats
16 changes: 16 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
machine:
environment:


dependencies:
post:
- git clone --depth 1 https://github.com/sstephenson/bats.git

checkout:
post:
- git submodule sync
- git submodule update --init

test:
override:
- bats/bin/bats test/*.bats
3 changes: 2 additions & 1 deletion diff-so-fancy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ hash gsed 2> /dev/null && SED=gsed || SED=sed
if hash diff-highlight 2> /dev/null; then
diff_highlight=diff-highlight
else
diff_highlight="$( cd "$( dirname $(realpath "${BASH_SOURCE[0]}") )" && pwd )/third_party/diff-highlight/diff-highlight"
SCRIPT_PATH=$( cd $(dirname $0) ; pwd -P )
diff_highlight="$SCRIPT_PATH/third_party/diff-highlight/diff-highlight"
fi

color_code_regex="(\x1B\[([0-9]{1,3}(;[0-9]{1,3}){0,3})[m|K])?"
Expand Down
21 changes: 21 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ git --no-pager diff # will avoid core.pager hook

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

## Contributing

Pull requests quite welcome.

## Hacking and Testing

```sh
# fork and clone the repo. then…

git submodule update --init
brew install entr coreutils
# install bats: github.com/sstephenson/bats#installing-bats-from-source
```

```sh
# Run the test suite once:
bats test/diff-so-fancy.bats

# Run it on every change with `entr`
ls --color=never diff-so-fancy test/*.bats | entr bats test/*.bats
```

## License

Expand Down
18 changes: 18 additions & 0 deletions test/bugs.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bats

load 'test_helper/bats-core/load'
load 'test_helper/bats-assert/load'
load 'test_helper/util'


output=$( load_fixture "chromium-modaltoelement" | $diff_so_fancy )


empty_remove_highlight=""

# https://github.com/paulirish/dotfiles/commit/6743b907ff586c28cd36e08d1e1c634e2968893e#commitcomment-13459061
@test "All removed lines are present in diff" {
assert_output --partial "WebInspector.Dialog = function($empty_remove_highlight)"
assert_output --partial "show: function($empty_remove_highlight)"
assert_output --partial "{!Document} */ (WebInspector.Dialog._modalHostView.element.ownerDocument$empty_remove_highlight)"
}
43 changes: 43 additions & 0 deletions test/diff-so-fancy.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bats

load 'test_helper/bats-core/load'
load 'test_helper/bats-assert/load'
load 'test_helper/util'


# bats fails to handle our multiline result, so we save to $output ourselves
output=$( load_fixture "ls-function" | $diff_so_fancy )

@test "diff-so-fancy runs exits without error" {
load_fixture "ls-function" | $diff_so_fancy
assert_success
}

@test "original source is indented by a single space" {
assert_output --partial "
if begin"
}

@test "index line is removed entirely" {
refute_output --partial "index 33c3d8b..fd54db2 100644"
}

@test "+/- line stars are stripped" {
refute_output --partial "
-"
refute_output --partial "
+"
}

@test "empty lines added/removed are marked" {
assert_output --partial " 
  set -x CLICOLOR_FORCE 1"
assert_output --partial " 
if not set -q LS_COLORS"
}

@test "diff-highlight is highlighting changes within lines" {
assert_output --partial 'eval "env CLICOLOR_FORCE=1 command $ls $param $argv"'
assert_output --partial 'eval $ls $param "$argv"'
}

43 changes: 43 additions & 0 deletions test/fixtures/chromium-modaltoelement.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js b/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
index 4f9adf8..8c13743 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
@@ -32,7 +32,7 @@
* @constructor
* @extends {WebInspector.Widget}
*/
-WebInspector.Dialog = function()
+WebInspector.Dialog = function(isModalToElement)
{
WebInspector.Widget.call(this, true);
this.markAsRoot();
@@ -45,6 +45,9 @@ WebInspector.Dialog = function()

this._wrapsContent = false;
this._dimmed = false;
+ this._isModalToElement = isModalToElement;
+
+ this._glassPane = new WebInspector.GlassPane(relativeToElement, isModalToElement);
/** @type {!Map<!HTMLElement, number>} */
this._tabIndexMap = new Map();
}
@@ -62,16 +65,16 @@ WebInspector.Dialog.prototype = {
/**
* @override
*/
- show: function()
+ show: function(isModalToElement)
{
if (WebInspector.Dialog._instance)
WebInspector.Dialog._instance.detach();
WebInspector.Dialog._instance = this;

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

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

Loading