[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/8] test/*: compatibility class for both minitest 4 and 5
From: |
Eric Wong |
Subject: |
[PATCH 4/8] test/*: compatibility class for both minitest 4 and 5 |
Date: |
Sat, 7 Sep 2013 20:03:23 +0000 |
This is to avoid annoying deprecation warnings in minitest 5, while
still preserving compatibility with minitest 4 (which is distributed
in Ruby 2.0.0 and part of the standard library).
---
test/helper.rb | 3 +++
test/test_buffer.rb | 2 +-
test/test_format.rb | 2 +-
test/test_format_change.rb | 2 +-
test/test_player.rb | 2 +-
test/test_player_client_handler.rb | 2 +-
test/test_player_integration.rb | 2 +-
test/test_process.rb | 2 +-
test/test_rg_integration.rb | 2 +-
test/test_rg_state.rb | 2 +-
test/test_sink.rb | 2 +-
test/test_sink_pipe_size.rb | 2 +-
test/test_sink_tee_integration.rb | 2 +-
test/test_source_av.rb | 2 +-
test/test_source_sox.rb | 2 +-
test/test_unixserver.rb | 2 +-
test/test_util.rb | 2 +-
17 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/test/helper.rb b/test/helper.rb
index e993463..a36332b 100644
--- a/test/helper.rb
+++ b/test/helper.rb
@@ -46,6 +46,9 @@ gem 'minitest'
require 'minitest/autorun'
require "tempfile"
+Testcase = Minitest.const_defined?(:Test) ? Minitest::Test
+ : Minitest::Unit::TestCase
+
FIFOS = []
at_exit { FIFOS.each { |(pid,path)| File.unlink(path) if $$ == pid } }
def tmpfifo
diff --git a/test/test_buffer.rb b/test/test_buffer.rb
index 259cd4f..677ca62 100644
--- a/test/test_buffer.rb
+++ b/test/test_buffer.rb
@@ -4,7 +4,7 @@ require './test/helper'
require 'stringio'
require 'dtas/buffer'
-class TestBuffer < Minitest::Unit::TestCase
+class TestBuffer < Testcase
def teardown
@to_close.each { |io| io.close unless io.closed? }
end
diff --git a/test/test_format.rb b/test/test_format.rb
index 0c0b292..f251e6b 100644
--- a/test/test_format.rb
+++ b/test/test_format.rb
@@ -4,7 +4,7 @@ require './test/helper'
require 'tempfile'
require 'dtas/format'
-class TestFormat < Minitest::Unit::TestCase
+class TestFormat < Testcase
def test_initialize
fmt = DTAS::Format.new
assert_equal %w(-ts32 -c2 -r44100), fmt.to_sox_arg
diff --git a/test/test_format_change.rb b/test/test_format_change.rb
index 99c694a..f840386 100644
--- a/test/test_format_change.rb
+++ b/test/test_format_change.rb
@@ -2,7 +2,7 @@
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require './test/player_integration'
require 'tmpdir'
-class TestFormatChange < Minitest::Unit::TestCase
+class TestFormatChange < Testcase
include PlayerIntegration
def test_format_change
diff --git a/test/test_player.rb b/test/test_player.rb
index 0fc776a..bc31967 100644
--- a/test/test_player.rb
+++ b/test/test_player.rb
@@ -4,7 +4,7 @@ require './test/helper'
require 'tempfile'
require 'dtas/player'
-class TestPlayer < Minitest::Unit::TestCase
+class TestPlayer < Testcase
def setup
@player = nil
tmp = Tempfile.new(%w(dtas-player-test .sock))
diff --git a/test/test_player_client_handler.rb
b/test/test_player_client_handler.rb
index 9cd84a5..88349bf 100644
--- a/test/test_player_client_handler.rb
+++ b/test/test_player_client_handler.rb
@@ -3,7 +3,7 @@
require './test/helper'
require 'dtas/player'
-class TestPlayerClientHandler < Minitest::Unit::TestCase
+class TestPlayerClientHandler < Testcase
class MockIO < Array
alias emit push
end
diff --git a/test/test_player_integration.rb b/test/test_player_integration.rb
index e7f7306..f71ed56 100644
--- a/test/test_player_integration.rb
+++ b/test/test_player_integration.rb
@@ -1,7 +1,7 @@
# Copyright (C) 2013, Eric Wong <address@hidden> and all contributors
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require './test/player_integration'
-class TestPlayerIntegration < Minitest::Unit::TestCase
+class TestPlayerIntegration < Testcase
include PlayerIntegration
def test_cmd_rate
diff --git a/test/test_process.rb b/test/test_process.rb
index 7f7b014..d32cb4a 100644
--- a/test/test_process.rb
+++ b/test/test_process.rb
@@ -2,7 +2,7 @@
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require './test/helper'
require 'dtas/process'
-class TestProcess < Minitest::Unit::TestCase
+class TestProcess < Testcase
include DTAS::Process
def test_encoding
diff --git a/test/test_rg_integration.rb b/test/test_rg_integration.rb
index 5c570ad..d6a90b0 100644
--- a/test/test_rg_integration.rb
+++ b/test/test_rg_integration.rb
@@ -1,7 +1,7 @@
# Copyright (C) 2013, Eric Wong <address@hidden> and all contributors
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require './test/player_integration'
-class TestRgIntegration < Minitest::Unit::TestCase
+class TestRgIntegration < Testcase
include PlayerIntegration
def tmp_pluck(len = 5)
diff --git a/test/test_rg_state.rb b/test/test_rg_state.rb
index c79e716..f9642a4 100644
--- a/test/test_rg_state.rb
+++ b/test/test_rg_state.rb
@@ -3,7 +3,7 @@
require './test/helper'
require 'dtas/rg_state'
-class TestRGState < Minitest::Unit::TestCase
+class TestRGState < Testcase
def test_rg_state
rg = DTAS::RGState.new
diff --git a/test/test_sink.rb b/test/test_sink.rb
index 2f39d1c..7831727 100644
--- a/test/test_sink.rb
+++ b/test/test_sink.rb
@@ -4,7 +4,7 @@ require './test/helper'
require 'dtas/sink'
require 'yaml'
-class TestSink < Minitest::Unit::TestCase
+class TestSink < Testcase
def test_serialize_reload
sink = DTAS::Sink.new
sink.name = "DAC"
diff --git a/test/test_sink_pipe_size.rb b/test/test_sink_pipe_size.rb
index 18328df..89001b8 100644
--- a/test/test_sink_pipe_size.rb
+++ b/test/test_sink_pipe_size.rb
@@ -3,7 +3,7 @@
begin
require 'io/splice'
require './test/player_integration'
- class TestSinkPipeSizeIntegration < Minitest::Unit::TestCase
+ class TestSinkPipeSizeIntegration < Testcase
include PlayerIntegration
def test_sink_pipe_size_integration
diff --git a/test/test_sink_tee_integration.rb
b/test/test_sink_tee_integration.rb
index 1fd6b0f..b186fdd 100644
--- a/test/test_sink_tee_integration.rb
+++ b/test/test_sink_tee_integration.rb
@@ -1,7 +1,7 @@
# Copyright (C) 2013, Eric Wong <address@hidden> and all contributors
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require './test/player_integration'
-class TestSinkTeeIntegration < Minitest::Unit::TestCase
+class TestSinkTeeIntegration < Testcase
include PlayerIntegration
def test_tee_integration
diff --git a/test/test_source_av.rb b/test/test_source_av.rb
index bc9d1fc..d6dc14f 100644
--- a/test/test_source_av.rb
+++ b/test/test_source_av.rb
@@ -4,7 +4,7 @@ require './test/helper'
require 'dtas/source/av'
require 'tempfile'
-class TestSourceAv < Minitest::Unit::TestCase
+class TestSourceAv < Testcase
def teardown
@tempfiles.each { |tmp| tmp.close! }
end
diff --git a/test/test_source_sox.rb b/test/test_source_sox.rb
index ce7227b..367f4df 100644
--- a/test/test_source_sox.rb
+++ b/test/test_source_sox.rb
@@ -4,7 +4,7 @@ require './test/helper'
require 'dtas/source/sox'
require 'tempfile'
-class TestSource < Minitest::Unit::TestCase
+class TestSource < Testcase
def teardown
@tempfiles.each { |tmp| tmp.close! }
end
diff --git a/test/test_unixserver.rb b/test/test_unixserver.rb
index 68fd16b..06ebd96 100644
--- a/test/test_unixserver.rb
+++ b/test/test_unixserver.rb
@@ -5,7 +5,7 @@ require 'tempfile'
require 'dtas/unix_server'
require 'stringio'
-class TestUNIXServer < Minitest::Unit::TestCase
+class TestUNIXServer < Testcase
def setup
@tmp = Tempfile.new(%w(dtas-unix_server-test .sock))
File.unlink(@tmp.path)
diff --git a/test/test_util.rb b/test/test_util.rb
index e768050..1a592b5 100644
--- a/test/test_util.rb
+++ b/test/test_util.rb
@@ -3,7 +3,7 @@
require './test/helper'
require 'dtas/util'
-class TestUtil < Minitest::Unit::TestCase
+class TestUtil < Testcase
include DTAS::Util
def test_util
orig = 6.0
--
1.8.4
- [PATCH 0/8] latest changes in dtas.git (dtas-splitfx), Eric Wong, 2013/09/07
- [PATCH 4/8] test/*: compatibility class for both minitest 4 and 5,
Eric Wong <=
- [PATCH 8/8] add dtas-splitfx - .cuesheets + make(1), Eric Wong, 2013/09/07
- [PATCH 1/8] source/sox: correctly extend xs for try_to_fail_harder, Eric Wong, 2013/09/07
- [PATCH 5/8] test/helper: delay at_exit registration for tmpfifo, Eric Wong, 2013/09/07
- [PATCH 3/8] test/player_integration: thread-safety fix, Eric Wong, 2013/09/07
- [PATCH 2/8] test/*.rb: test/unit compatibility, Eric Wong, 2013/09/07
- [PATCH 6/8] dtas-console: show paused track when paused, Eric Wong, 2013/09/07
- [PATCH 7/8] test/helper: fix var shadowing, Eric Wong, 2013/09/07