jstdutil 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +5 -0
- data/VERSION +1 -1
- data/bin/jstestdriver +3 -2
- data/lib/jstdutil/cli.rb +3 -1
- data/lib/jstdutil/test_runner.rb +6 -11
- data/lib/jstdutil.rb +1 -1
- data/test/jstestdriver_test.rb +1 -1
- metadata +4 -5
- data/lib/jstdutil/jstestdriver/server.rb +0 -62
data/Changelog
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/bin/jstestdriver
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
begin
|
3
3
|
require "jstdutil"
|
4
|
-
require "jstdutil/
|
4
|
+
require "jstdutil/test_runner"
|
5
5
|
rescue LoadError => err
|
6
6
|
exit
|
7
7
|
end
|
8
8
|
|
9
9
|
begin
|
10
|
-
$stdout.puts Jstdutil::
|
10
|
+
$stdout.puts Jstdutil::TestRunner.new($*).run()
|
11
11
|
rescue StandardError => err
|
12
|
+
puts err.message
|
12
13
|
# Swallow...
|
13
14
|
end
|
data/lib/jstdutil/cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "jstdutil"
|
2
|
+
|
1
3
|
module Jstdutil
|
2
4
|
#
|
3
5
|
# <tt>Jstdutil::Cli</tt> is a tiny wrapper to the JsTestDriver
|
@@ -15,7 +17,7 @@ module Jstdutil
|
|
15
17
|
def self.run(args = [])
|
16
18
|
args = args.join(" ")
|
17
19
|
jar = (args.match(/--jar\s+([^\s]+)/) || [])[1] || Jstdutil.jar
|
18
|
-
format_type = args.match(/--html/) ? Jstdutil::ColorfulHtml : Jstdutil::RedGreen
|
20
|
+
format_type = args.match(/--html/) ? Jstdutil::ColorfulHtml : Jstdutil::RedGreen
|
19
21
|
report = Jstdutil.run("#{args.gsub(/(--jar\s+[^\s]+|--html)/, '')}", jar)
|
20
22
|
Jstdutil::Formatter.format(report, format_type)
|
21
23
|
end
|
data/lib/jstdutil/test_runner.rb
CHANGED
@@ -19,22 +19,17 @@ module Jstdutil
|
|
19
19
|
|
20
20
|
def test_cases(files)
|
21
21
|
files = files.respond_to?(:captures) ? files.captures : files
|
22
|
-
|
22
|
+
@args = @args.sub(/--reset\s*/, "")
|
23
23
|
|
24
|
+
cases = files.collect do |file|
|
25
|
+
@args = @args.sub(/(\s*--reset)?$/, " --reset") if file !~ /_test\.js$/
|
26
|
+
TestFile.new(file).test_cases
|
27
|
+
end.flatten.join(",")
|
28
|
+
|
24
29
|
cases == "" && "all" || cases
|
25
30
|
end
|
26
31
|
|
27
32
|
def run(tests = "all")
|
28
|
-
#begin
|
29
|
-
# @server.start unless @server.running?
|
30
|
-
#rescue StandardError => err
|
31
|
-
# puts err.message
|
32
|
-
#end
|
33
|
-
if !@server.running?
|
34
|
-
puts "Server not running, you want to start it with jstestdriver --port #{@server.uri.port}"
|
35
|
-
exit
|
36
|
-
end
|
37
|
-
|
38
33
|
puts(Time.now.strftime("%F %H:%M:%S Running #{tests}"))
|
39
34
|
puts(Jstdutil::Cli.run(args("tests" => tests)))
|
40
35
|
end
|
data/lib/jstdutil.rb
CHANGED
data/test/jstestdriver_test.rb
CHANGED
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christian Johansen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-18 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -86,7 +86,6 @@ files:
|
|
86
86
|
- lib/jstdutil/formatter.rb
|
87
87
|
- lib/jstdutil/hooks.rb
|
88
88
|
- lib/jstdutil/jstestdriver/config.rb
|
89
|
-
- lib/jstdutil/jstestdriver/server.rb
|
90
89
|
- lib/jstdutil/redgreen.rb
|
91
90
|
- lib/jstdutil/test_file.rb
|
92
91
|
- lib/jstdutil/test_runner.rb
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# require 'open3'
|
2
|
-
require "uri"
|
3
|
-
|
4
|
-
module Jstdutil
|
5
|
-
module JsTestDriver
|
6
|
-
class Server
|
7
|
-
attr_reader :uri
|
8
|
-
|
9
|
-
def initialize(config, args = nil)
|
10
|
-
uri = config.respond_to?(:server) ? config.server : config
|
11
|
-
@uri = URI.parse(uri)
|
12
|
-
@args = args
|
13
|
-
@pid = nil
|
14
|
-
rescue URI::InvalidURIError => err
|
15
|
-
raise StandardError.new("Invalid test driver server URL #{uri}")
|
16
|
-
end
|
17
|
-
|
18
|
-
def running?
|
19
|
-
response = nil
|
20
|
-
|
21
|
-
begin
|
22
|
-
Net::HTTP.start(@uri.host, @uri.port) { |http| response = http.head("/") }
|
23
|
-
rescue Errno::ECONNREFUSED => err
|
24
|
-
return false
|
25
|
-
end
|
26
|
-
|
27
|
-
response.code == "200"
|
28
|
-
end
|
29
|
-
|
30
|
-
def start
|
31
|
-
if !["localhost", "127.0.0.1", "0.0.0.0"].include?(@uri.host)
|
32
|
-
raise "Unable to start remote server on #{@uri.host}"
|
33
|
-
end
|
34
|
-
|
35
|
-
puts "Starting server on http://#{@uri.host}:#{@uri.port}"
|
36
|
-
# @server = IO.popen("jstestdriver #{@args} --port #{@uri.port}")
|
37
|
-
# [stdin, stdout, stderr] = Open3.popen3("jstestdriver #{@args} --port #{@uri.port}")
|
38
|
-
# @server = stderr
|
39
|
-
|
40
|
-
@pid = Process.fork do
|
41
|
-
io = `jstestdriver --port #{@uri.port}`
|
42
|
-
|
43
|
-
Signal.trap("HUP") do
|
44
|
-
puts "JsTestDriver at port #@port going down"
|
45
|
-
!io.closed? && io.close!
|
46
|
-
exit
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# sleep 0.5
|
51
|
-
end
|
52
|
-
|
53
|
-
def stop
|
54
|
-
# @server && !@server.closed? && @server.close
|
55
|
-
if @pid
|
56
|
-
Process.kill("HUP", @pid)
|
57
|
-
Process.wait
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|