<commit_before>extern crate timebomb;
extern crate zmq;

use std::net::TcpStream;
use timebomb::timeout_ms;
use zmq::*;

#[cfg(not(target_os = "windows"))]
#[inline]
fn get_endpoint(receiver: &Socket) -> String {
    receiver.get_last_endpoint().unwrap().unwrap()
}
#[cfg(target_os = "windows")]
#[inline]
fn get_endpoint(receiver: &Socket) -> String {
    receiver.get_last_endpoint().unwrap().unwrap().replace("tcp://0.0.0.0", "tcp://127.0.0.1").to_owned()
}

fn create_socketpair() -> (Socket, Socket) {
    let ctx = Context::default();

    let sender = ctx.socket(zmq::REQ).unwrap();
    let receiver = ctx.socket(zmq::REP).unwrap();

    // Don't block forever
    sender.set_sndtimeo(1000).unwrap();
    sender.set_rcvtimeo(1000).unwrap();
    receiver.set_sndtimeo(1000).unwrap();
    receiver.set_rcvtimeo(1000).unwrap();

    receiver.bind("tcp://*:*").unwrap();
    let ep = get_endpoint(&receiver);
    sender.connect(&ep).unwrap();

    (sender, receiver)
}

macro_rules! test {
    ($name:ident, $block:block) => {
        #[test]
        fn $name() {
            timeout_ms(|| {
                $block
            }, 10000);
        }
    }
}<commit_msg>bind "127.0.0.1:*" instead of "*:*"<commit_after>extern crate timebomb;
extern crate zmq;

use std::net::TcpStream;
use timebomb::timeout_ms;
use zmq::*;

fn create_socketpair() -> (Socket, Socket) {
    let ctx = Context::default();

    let sender = ctx.socket(zmq::REQ).unwrap();
    let receiver = ctx.socket(zmq::REP).unwrap();

    // Don't block forever
    sender.set_sndtimeo(1000).unwrap();
    sender.set_rcvtimeo(1000).unwrap();
    receiver.set_sndtimeo(1000).unwrap();
    receiver.set_rcvtimeo(1000).unwrap();

    receiver.bind("tcp://127.0.0.1:*").unwrap();
    let ep = receiver.get_last_endpoint().unwrap().unwrap();
    sender.connect(&ep).unwrap();

    (sender, receiver)
}

macro_rules! test {
    ($name:ident, $block:block) => {
        #[test]
        fn $name() {
            timeout_ms(|| {
                $block
            }, 10000);
        }
    }
}
{'fraction_non_alphanumeric': 0.1905458089668616, 'fraction_numerical': 0.031189083820662766, 'mean_word_length': 3.1558704453441297, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4388663', 'n_tokens_mistral': 754, 'n_tokens_neox': 730, 'n_words': 119}