Skip to content

Commit

Permalink
Merge pull request luvit#973 from zhaozg/ci_master
Browse files Browse the repository at this point in the history
green Ci
  • Loading branch information
creationix authored Apr 23, 2017
2 parents e25de1b + 03bee4e commit 0d2d252
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
6 changes: 5 additions & 1 deletion deps/dns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ local insert = table.insert
local concat = table.concat
local ipapi

if ffi.os=='Windows' then

if _G._luvit_dns_load then
ipapi = _G._luvit_dns_load
elseif ffi.os=='Windows' then
ffi.cdef[[
typedef uint32_t DWORD; //Integer
typedef uint32_t ULONG; //Alias
Expand Down Expand Up @@ -102,6 +105,7 @@ if ffi.os=='Windows' then
]]

ipapi = ffi.load('Iphlpapi.dll')
_G._luvit_dns_load = ipapi
end

local DEFAULT_SERVERS = {
Expand Down
1 change: 1 addition & 0 deletions deps/ustring.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ function ustring.uindex2index(ustr,uindex,initrawindex,inituindex)
-- convert the index of a UIF-8 char into a raw index
-- return `nil` if rawindex is invaild
-- the last 2 arguments are optional and used for better performance (only if uindex isn't negative)
uindex = uindex or 1
local ulen = #ustr
if uindex < 0 then
local index = 0
Expand Down
15 changes: 8 additions & 7 deletions tests/test-dns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ require('tap')(function (test)
end))
end)
test("resolveSrv", function (expect)
dns.resolveSrv('_https._tcp.luvit.io', expect(function(err, answers)
dns.resolveSrv('www.luvit.io', expect(function(err, answers)
assert(not err)
p(answers)
assert(#answers > 0)
Expand All @@ -74,23 +74,24 @@ require('tap')(function (test)
end))
end)
test("resolveCname", function (expect)
dns.resolveCname('try.luvit.io', expect(function(err, answers)
dns.setTimeout(5000)
dns.resolveCname('www.luvit.io', expect(function(err, answers)
assert(not err)
p(answers)
assert(#answers > 0)
end))
end)
test("resolveTxt", function (expect)
dns.resolveTxt('google._domainkey.luvit.io', expect(function(err, answers)
dns.resolveTxt('lit.luvit.io', expect(function(err, answers)
assert(not err)
p(answers)
assert(#answers > 0)
end))
end)
test("resolveTxtTimeout Order", function (expect)
dns.setServers( { { ['host'] = '127.0.0.1', ['port'] = 53234 }, { ['host'] = '8.8.8.8', ['port'] = 53 } })
dns.setTimeout(200)
dns.resolveTxt('google._domainkey.luvit.io', expect(function(err, answers)
dns.setTimeout(2000)
dns.resolveTxt('lit.luvit.io', expect(function(err, answers)
assert(not err)
p(answers)
assert(#answers > 0)
Expand All @@ -100,14 +101,14 @@ require('tap')(function (test)
test("resolveTxtTimeout", function (expect)
dns.setServers( { { ['host'] = '127.0.0.1', ['port'] = 53234 } } )
dns.setTimeout(200)
dns.resolveTxt('google._domainkey.luvit.io', expect(function(err, answers)
dns.resolveTxt('lit.luvit.io', expect(function(err, answers)
assert(err)
end))
end)
test("resolveTxtTCP", function (expect)
dns.setTimeout(2000)
dns.setServers( { { ['host'] = '8.8.8.8', ['port'] = 53, ['tcp'] = true } } )
dns.resolveTxt('google._domainkey.luvit.io', expect(function(err, answers)
dns.resolveTxt('lit.luvit.io', expect(function(err, answers)
assert(not err)
end))
end)
Expand Down
1 change: 1 addition & 0 deletions tests/test-process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ require('tap')(function(test)
function onEnd()
assert(data:find('TEST1=1'))
p('found')
child.stdin:destroy()
end

child.stdout:once('end', expect(onEnd))
Expand Down
14 changes: 7 additions & 7 deletions tests/test-ustring.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ end

require('tap')(function(test)
test('ustring', function(expect)

-- construct & tostring
local r = "abc123\11\27\0中文-日本語-한국❤😘😄💎💛"
local u = ustring.new(r)
Expand All @@ -49,13 +49,13 @@ require('tap')(function(test)
assert(compareTable(u2,u))
assert(compareTable(u2,e))
assert(u2 == u) -- __eq

-- uindex
assert(u:uindex(13) == 11)
assert(u:uindex(43) == 21)
assert(u:uindex(13,10,10) == 11)
assert(u:uindex(43,39,20) == 21)
assert(u:index2uindex(13) == 11)
assert(u:index2uindex(43) == 21)
assert(u:index2uindex(13,10,10) == 11)
assert(u:index2uindex(43,39,20) == 21)

-- other
local u = ustring.new "xx中x中😄" .. ustring.new "文💛"
assert(tostring(u) == "xx中x中😄文💛")
Expand Down

0 comments on commit 0d2d252

Please sign in to comment.