test_server_rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1eb14ffcfc77aa7cd5856a818ce4ed1ecda02394
4
+ data.tar.gz: f8c26c02d7856423d23701ea87a5fde681f8a970
5
+ SHA512:
6
+ metadata.gz: 498695ac9e2ae50afae19bb83977ed5afaab3a840d49d4f45e582367c8b1e67de3caac2de69d80ece7f340aec83a808744d417eafb954c0c020a8489c71b4738
7
+ data.tar.gz: f707f1417d597368339fdfd2d8134fc52b55b680c2b5baa1b2be6d860a99252aace9683015f40f612319c0a9f6f5ef8e9c3dc3664d888426d581c1bf5525335f
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in test_server.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # test_server
2
+
3
+ dead simple fork based test server
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ gem install "test_server_rb"
9
+ test_server --serve
10
+
11
+ # in another process
12
+ test_server --test test/unit/hello.rb
13
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "test_server"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/test_server ADDED
@@ -0,0 +1,67 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ $: << 'test'
4
+ require 'bundler/setup'
5
+ require 'socket'
6
+ require 'terminal-notifier' if ENV['NOTIFY']
7
+
8
+ module TestServer
9
+ class << self
10
+ SOCK = "test.sock".freeze
11
+
12
+ def client
13
+ @client ||= UNIXSocket.new(SOCK)
14
+ end
15
+
16
+ def server
17
+ @server ||= UNIXServer.new(SOCK)
18
+ end
19
+
20
+ def running?
21
+ File.exist?(SOCK)
22
+ end
23
+
24
+ def test(files)
25
+ client.sendmsg files.join(' ')
26
+ end
27
+
28
+ def start!
29
+ `rm #{SOCK}` if running?
30
+ puts "Initializing TestServer with pid #{$$}..."
31
+ require 'test_helper'
32
+ puts "Ready!"
33
+ loop do
34
+ conn = server.accept
35
+ files, _ = conn.recvmsg
36
+ pid = fork do
37
+ puts "> Testing files: #{files}"
38
+ if files == ":all".freeze
39
+ all_glob = ENV['ALL_GLOB'] || 'test/unit/*_test.rb'
40
+ Dir.glob(all_glob).each { |f| load f }
41
+ else
42
+ files.split(' ').each { |f| load f }
43
+ end
44
+ end
45
+ _, status = Process.wait2(pid)
46
+ if ENV['NOTIFY']
47
+ msg = (status.exitstatus == 0) ? "Tests passed :)" : "Warning! Tests failed :("
48
+ TerminalNotifier.notify(msg)
49
+ end
50
+ end
51
+ ensure
52
+ `rm #{SOCK}`
53
+ end
54
+ end
55
+ end
56
+
57
+ queue = ARGV
58
+ until queue.empty?
59
+ case queue.shift
60
+ when "--serve"
61
+ TestServer.start!
62
+ when "--test"
63
+ TestServer.test(queue)
64
+ queue = []
65
+ end
66
+ end
67
+
@@ -0,0 +1,5 @@
1
+ require "test_server/version"
2
+
3
+ module TestServer
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module TestServer
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,26 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "test_server/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "test_server_rb"
8
+ spec.version = TestServer::VERSION
9
+ spec.authors = ["Josh Bodah"]
10
+ spec.email = ["joshuabodah@gmail.com"]
11
+
12
+ spec.summary = %q{dead simple fork based test server}
13
+ spec.homepage = "https://github.com/jbodah/test_server"
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test_server_rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Bodah
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-11-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - joshuabodah@gmail.com
44
+ executables:
45
+ - test_server
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - exe/test_server
56
+ - lib/test_server.rb
57
+ - lib/test_server/version.rb
58
+ - test_server.gemspec
59
+ homepage: https://github.com/jbodah/test_server
60
+ licenses: []
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.5.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: dead simple fork based test server
82
+ test_files: []