rubinius-report 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/.autotest +23 -0
  2. data/History.txt +6 -0
  3. data/Manifest.txt +6 -0
  4. data/README.txt +60 -0
  5. data/Rakefile +13 -0
  6. data/bin/rubinius_report +140 -0
  7. metadata +103 -0
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2011-08-02
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,6 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/rubinius_report
@@ -0,0 +1,60 @@
1
+ = rubinius-report
2
+
3
+ * http://github.com/rubinius/rubinius-report
4
+
5
+ == DESCRIPTION:
6
+
7
+ A launcher to simplify reporting crashes and profiling.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Crash mode: if a script crashes, post the details of the crash
12
+ * Profile mode: Run the script a few times and post flat and graph
13
+ profiling info.
14
+
15
+ == SYNOPSIS:
16
+
17
+ rbx -S rubinius_report crash -Iblah my_script.rb
18
+ rbx -S rubinius_report profile -e 'sleep 10'
19
+
20
+ == REQUIREMENTS:
21
+
22
+ * JSON
23
+
24
+ == INSTALL:
25
+
26
+ * gem install rubinius-report
27
+
28
+ == DEVELOPERS:
29
+
30
+ After checking out the source, run:
31
+
32
+ $ rake newb
33
+
34
+ This task will install any missing dependencies, run the tests/specs,
35
+ and generate the RDoc.
36
+
37
+ == LICENSE:
38
+
39
+ (The MIT License)
40
+
41
+ Copyright (c) 2011 Evan Phoenix
42
+
43
+ Permission is hereby granted, free of charge, to any person obtaining
44
+ a copy of this software and associated documentation files (the
45
+ 'Software'), to deal in the Software without restriction, including
46
+ without limitation the rights to use, copy, modify, merge, publish,
47
+ distribute, sublicense, and/or sell copies of the Software, and to
48
+ permit persons to whom the Software is furnished to do so, subject to
49
+ the following conditions:
50
+
51
+ The above copyright notice and this permission notice shall be
52
+ included in all copies or substantial portions of the Software.
53
+
54
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
55
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
56
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
57
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
58
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
59
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
60
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.spec 'rubinius-report' do
7
+ self.version = '1.0.0'
8
+ developer 'Evan Phoenix', 'evan@fallingsnow.net'
9
+
10
+ dependency 'json', '~> 1.2'
11
+ end
12
+
13
+ # vim: syntax=ruby
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+
4
+ require 'rubygems'
5
+ require 'tempfile'
6
+ require 'net/http'
7
+ require 'json'
8
+
9
+ class Reporter
10
+
11
+ DEFAULT_URL = 'http://rubinius.net:15001/report'
12
+
13
+ def initialize
14
+ @tmpfile = Tempfile.new "crash_report"
15
+ @tmpfile.close
16
+
17
+ @tmppath = @tmpfile.path
18
+
19
+ @url = ENV['RBX_REPORT_URL'] || DEFAULT_URL
20
+ end
21
+
22
+ def upload(report)
23
+ res = Net::HTTP.post_form(URI.parse(@url), {'report' => report})
24
+
25
+ if res.kind_of? Net::HTTPSuccess
26
+ STDERR.puts "Reported issue to '#{@url}'"
27
+ STDERR.puts "Server said: #{res.body}"
28
+ else
29
+ STDERR.puts "Error posting report to '#{@url}'"
30
+ STDERR.puts res.inspect
31
+
32
+ File.open "rubinius_report_error.html", "w" do |f|
33
+ f << res.body
34
+ end
35
+
36
+ STDERR.puts "Saved error from server in 'rubinius_report_error.html'"
37
+ end
38
+ end
39
+
40
+ def handle_crash
41
+ ary = ["-Xvm.crash_report_path=#{@tmppath}", *ARGV]
42
+
43
+ unless system(ARG0, *ary)
44
+ STDERR.puts "\nCrash detected, gathering information..."
45
+
46
+ report = File.read(@tmppath)
47
+
48
+ report_json = {
49
+ 'type' => 'crash',
50
+ 'when' => Time.now,
51
+ 'report' => report
52
+ }.to_json
53
+
54
+ upload report_json
55
+ end
56
+ end
57
+
58
+ def run_profiling(kind=nil)
59
+ stdout = @tmppath
60
+ stderr = "#{@tmppath}-err"
61
+
62
+ pid = fork do
63
+ STDOUT.reopen stdout
64
+ STDERR.reopen stderr
65
+
66
+ if kind
67
+ ary = ["-Xprofile", kind, *ARGV]
68
+ else
69
+ ary = ["-Xprofile", *ARGV]
70
+ end
71
+
72
+ ran = system(ARG0, *ary)
73
+
74
+ if ran
75
+ exit 0
76
+ else
77
+ exit 1
78
+ end
79
+
80
+ end
81
+
82
+ pid, status = Process.wait2(pid)
83
+
84
+ if status.to_i != 0
85
+ puts "Error executing: #{ARGV.join(' ')}"
86
+
87
+ puts "stdout:"
88
+ system "cat #{stdout}"
89
+
90
+ puts "stderr:"
91
+ system "cat #{stderr}"
92
+ exit 1
93
+ end
94
+
95
+ [File.read(stdout), File.read(stderr)]
96
+ end
97
+
98
+ def handle_profile
99
+ puts "Gathering 2 profiles of code, flat and graph."
100
+ puts "Beginning flat profile gathering..."
101
+
102
+ flat = run_profiling
103
+
104
+ puts "Flat profile done."
105
+ puts "Beginning graph profile gathering..."
106
+
107
+ graph = run_profiling("-Xprofiler.graph")
108
+
109
+ report_json = {
110
+ 'type' => 'profile',
111
+ 'when' => Time.now,
112
+ 'flat' => flat,
113
+ 'graph' => graph
114
+ }.to_json
115
+
116
+ upload report_json
117
+ end
118
+
119
+ end
120
+
121
+ r = Reporter.new
122
+
123
+ kind = ARGV.shift
124
+
125
+ case kind
126
+ when "crash"
127
+ r.handle_crash
128
+ when "profile"
129
+ r.handle_profile
130
+ else
131
+ STDERR.puts "Please specify the mode first, either 'crash' or 'profile'"
132
+ STDERR.puts "\nUsage: rbx -S rubinius_report [crash|profile] options..."
133
+ STDERR.puts "\noptions is any regular command line options to be passed"
134
+ STDERR.puts "to run your script."
135
+ STDERR.puts "\nWhen 'crash' is specified, your command is run and if it crashes"
136
+ STDERR.puts "a crash report is generated and sent via HTTP to Rubinius HQ."
137
+ STDERR.puts "\nWhen 'profile' is specified, your command is run twice and profiling"
138
+ STDERR.puts "data is gathered about it which is then sent via HTTP to Rubinius HQ."
139
+ exit 1
140
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubinius-report
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Evan Phoenix
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-04 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: json
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 11
29
+ segments:
30
+ - 1
31
+ - 2
32
+ version: "1.2"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 23
44
+ segments:
45
+ - 2
46
+ - 10
47
+ version: "2.10"
48
+ type: :development
49
+ version_requirements: *id002
50
+ description: A launcher to simplify reporting crashes and profiling.
51
+ email:
52
+ - evan@fallingsnow.net
53
+ executables:
54
+ - rubinius_report
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - History.txt
59
+ - Manifest.txt
60
+ - README.txt
61
+ files:
62
+ - .autotest
63
+ - History.txt
64
+ - Manifest.txt
65
+ - README.txt
66
+ - Rakefile
67
+ - bin/rubinius_report
68
+ homepage: http://github.com/rubinius/rubinius-report
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options:
73
+ - --main
74
+ - README.txt
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ requirements: []
96
+
97
+ rubyforge_project: rubinius-report
98
+ rubygems_version: 1.8.6
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: A launcher to simplify reporting crashes and profiling.
102
+ test_files: []
103
+