forked from erikd/http-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously ports were statically defined. When running more than one build on travis-ci, the build was failing when two build/test jobs were running on the machine at the same time. Now each run chooses three unique numbers in the range (30000, 60000).
- Loading branch information
Showing
7 changed files
with
50 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,48 @@ | ||
module Test.ServerDef where | ||
------------------------------------------------------------ | ||
-- Copyright : Erik de Castro Lopo <[email protected]> | ||
-- License : BSD3 | ||
------------------------------------------------------------ | ||
|
||
httpTestPort, httpsTestPort, testProxyPort :: Int | ||
httpTestPort = 31080 | ||
httpsTestPort = 31443 | ||
testProxyPort = 31088 | ||
module Test.ServerDef | ||
( PortsDef (..) | ||
, portsDef | ||
) where | ||
|
||
import Data.List (sort) | ||
import System.IO.Unsafe (unsafePerformIO) | ||
import System.Random | ||
|
||
data PortsDef = PortsDef | ||
{ httpTestPort :: Int | ||
, httpsTestPort :: Int | ||
, proxyTestPort :: Int | ||
} | ||
deriving Show | ||
|
||
|
||
-- Yeah, yeah, unsafePerformIO! Worst thing that can happen is that the tests | ||
-- fail. | ||
portsDef :: PortsDef | ||
portsDef = unsafePerformIO getPortsDef | ||
|
||
|
||
-- Grab three unique Ints in the range (30000, 60000) and stick them in a | ||
-- PortsDef constructor. | ||
getPortsDef :: IO PortsDef | ||
getPortsDef = do | ||
vals <- randomRL [] | ||
case sort vals of | ||
[a, b, c] -> return $ PortsDef a b c | ||
_ -> getPortsDef | ||
where | ||
randomRL :: [Int] -> IO [Int] | ||
randomRL xs | ||
| length xs == 3 = return $ sort xs | ||
| otherwise = do | ||
x <- randomRIO portRange | ||
if x `elem` xs | ||
then randomRL xs | ||
else randomRL (x:xs) | ||
|
||
portRange :: (Int, Int) | ||
portRange = (30000, 60000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.