caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Kenneth Adam Miller <kennethadammiller@gmail.com>
To: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Unit testing Core Async
Date: Mon, 15 Jun 2015 12:56:01 -0400	[thread overview]
Message-ID: <CAK7rcp9WQCrMjVkLhueBhjFMyaZD7sA3RGa7xmsfP3WmeQoAAw@mail.gmail.com> (raw)
In-Reply-To: <CALyFioTUGEOcwqsBOqWhms=3kL-N-Cmi9hCLnQCHLtrCNHK65Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3506 bytes --]

That helps-I was literally looking up a way to running unit tests on that
google group. I think that group helped a lot, I'll try and read what I can
there before I blast the list (I didn't know about it before hand).

On Mon, Jun 15, 2015 at 12:53 PM, Carl Eastlund <ceastlund@janestreet.com>
wrote:

> Internally at Jane Street -- and this may show up in some of the publicly
> released code, but off the top of my head, I don't know what file to point
> you at -- we run some of our async unit tests using
> [Thread_safe.block_on_async_exn].  That will spin up the scheduler if
> necessary, run the function you give it, block until the deferred is
> determined, then return.  It does not shut down the async scheduler; we
> generally don't do that until the program is done, so we would leave the
> scheduler up from one test to another.  I don't know the entire rationale
> behind this design, there may be a way to shut down the scheduler in
> between tests, but in general it does not appear to be necessary.
>
> As for partial reads, if you're concerned with receiving whole messages, I
> think [Reader.read_one_chunk_at_a_time] can do what you need -- if you get
> too little, just return [`Consumed (n_already_consumed, `Need
> n_total_bytes_to_proceed)].
>
> I hope this helps!
>
> On Mon, Jun 15, 2015 at 12:33 PM, Kenneth Adam Miller <
> kennethadammiller@gmail.com> wrote:
>
>> I've noticed that Core Async requites that a Scheduler.go () call be
>> placed-but that never returns. I have a Tcp.server that I'm creating, and I
>> like to use oUnit for my tests. Monads and all are beautiful, and Core is a
>> wonderful library, but I'm adamant that I have at least some minimal
>> functionality testing complete that demonstrates proper behavior as well as
>> intended usage.
>>
>> What I'm wondering is the following: would there be a way to have the
>> scheduler.go call be placed in order to fire things off, but in another
>> thread have all the test code be dependent on the server's responses and
>> all of that, so that once completed, it can call Shutdown.shutdown?
>>
>> I tried this out, and it introduced some issues.
>>
>> First, I think that my shutdown call got executed before the unit test
>> was able to complete. This is because using Async's Deferred introduces
>> some complication if you want behavior to proceed sequentially as in
>> without building deeply nested callback chains. What I'm used to is
>> asynchronous send, and blocking receive that operates on a common execution
>> chain. I don't see any kind of Deferred.await that blocks until the
>> instance resolves (yes, there's upon, but that's just nesting again because
>> it returns another deferred.
>>
>> Second, I think shutdown shuts *everything* down. What I need is just to
>> signal the completion of the job that was supposed to run, so that the
>> Scheduler.go returns in order to allow my unit tests to run to completion.
>>
>> Third, I'm not certain about the semantics of Pipe/Reader/Writer. It's
>> not behaviorally like what I'm familiar with. For instance, callbacks may
>> return prematurely and only have part of a message. In ZMQ, what you send
>> is what you get. So that makes me concerned in regards to the Tcp.Server,
>> because right now what I need is for the Pipe to just allow blocking
>> receive so that I can make the threads coordinated, but I need the Tcp
>> Server to allow me to receive whole protobuf messages.
>>
>> Can anyone please help me?
>>
>
>
>
> --
> Carl Eastlund
>

[-- Attachment #2: Type: text/html, Size: 4421 bytes --]

  reply	other threads:[~2015-06-15 16:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 16:33 Kenneth Adam Miller
2015-06-15 16:45 ` Francois Berenger
2015-06-15 16:53 ` Carl Eastlund
2015-06-15 16:56   ` Kenneth Adam Miller [this message]
2015-06-15 16:57     ` Kenneth Adam Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK7rcp9WQCrMjVkLhueBhjFMyaZD7sA3RGa7xmsfP3WmeQoAAw@mail.gmail.com \
    --to=kennethadammiller@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).