nanoc-tidy.rb 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nanoc/tidy/spawn.rb +8 -2
- data/lib/nanoc/tidy/version.rb +1 -1
- data/test/tidy_filter_test.rb +14 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a795c8b72d5a01390d1fc1207f591907122770a381b87ce678e07536176e1b84
|
4
|
+
data.tar.gz: 334ae45c5f9d92401b5277a72eab418cd520b7b9cc0f867a6f22b944221ccefb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9dcc2d5a72046d5250db9483057e6b64e2ead1ea5ceaea0a4e262cd54612698cd2314a19a5bd1ca52c8c1a22c947f1feddef9fe9fb5aa654b32d56ba169610e
|
7
|
+
data.tar.gz: b4d645c500657c30390a4c7cca1f75c73642cc45ef2e0bc88dc05a65bb7b2de58cdca362b848036b959c040a8f5d464638adcbcd3de0b5ff5d1802a6744be6f8
|
data/lib/nanoc/tidy/spawn.rb
CHANGED
@@ -19,11 +19,17 @@ module Nanoc::Tidy
|
|
19
19
|
def spawn(exe, argv)
|
20
20
|
r = cmd(exe, *argv)
|
21
21
|
##
|
22
|
-
# exit codes
|
22
|
+
# tidy-html5 exit codes
|
23
23
|
# * 0: no warnings, no errors
|
24
24
|
# * 1: has warnings
|
25
25
|
# * 2: has errors
|
26
|
-
if
|
26
|
+
if r.exit_status == 1
|
27
|
+
if r.stderr =~ /No such file or directory/
|
28
|
+
raise Nanoc::Tidy::Error, "The #{exe} executable was not found"
|
29
|
+
else
|
30
|
+
r.exit_status
|
31
|
+
end
|
32
|
+
elsif r.exit_status == 0
|
27
33
|
r.exit_status
|
28
34
|
else
|
29
35
|
raise Nanoc::Tidy::Error,
|
data/lib/nanoc/tidy/version.rb
CHANGED
data/test/tidy_filter_test.rb
CHANGED
@@ -4,17 +4,25 @@ require_relative "setup"
|
|
4
4
|
|
5
5
|
class FilterTest < Test::Unit::TestCase
|
6
6
|
def test_default_options
|
7
|
-
options = {argv: ["--tidy-mark", "false"]}
|
7
|
+
options = {exe:, argv: ["--tidy-mark", "false"]}
|
8
8
|
assert_equal read_result("default_options.html"),
|
9
9
|
filter_for("fixture.html").run(html, options)
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_upper_option
|
13
|
-
options = {argv: ["-upper", "--tidy-mark", "false"]}
|
13
|
+
options = {exe:, argv: ["-upper", "--tidy-mark", "false"]}
|
14
14
|
assert_equal read_result("upper_option.html"),
|
15
15
|
filter_for("fixture.html").run(html, options)
|
16
16
|
end
|
17
17
|
|
18
|
+
def test_exe_not_found
|
19
|
+
options = {exe: "/path/not/found", argv: ["-upper", "--tidy-mark", "false"]}
|
20
|
+
assert_raises(
|
21
|
+
Nanoc::Tidy::Error,
|
22
|
+
"The /path/not/found executable was not found"
|
23
|
+
) { filter_for("fixture.html").run(html, options) }
|
24
|
+
end
|
25
|
+
|
18
26
|
private
|
19
27
|
|
20
28
|
def filter_for(basename)
|
@@ -39,4 +47,8 @@ class FilterTest < Test::Unit::TestCase
|
|
39
47
|
def html
|
40
48
|
File.binread "./test/fixtures/fixture.html"
|
41
49
|
end
|
50
|
+
|
51
|
+
def exe
|
52
|
+
`which tidy || which tidy5`.chomp
|
53
|
+
end
|
42
54
|
end
|