From 1190176be7912db327f5e2784e51ce87c385201b Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 28 Feb 2018 20:00:25 +0300 Subject: Improve current thread tests (#161) * Create variables as closer as possible to their usage * Check that no message is lost in test current_thread::hammer_turn --- tests/current_thread.rs | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'tests/current_thread.rs') diff --git a/tests/current_thread.rs b/tests/current_thread.rs index 51695f40..dfc80334 100644 --- a/tests/current_thread.rs +++ b/tests/current_thread.rs @@ -38,9 +38,6 @@ fn spawn_from_block_on_all() { #[test] fn block_waits() { - let cnt = Rc::new(Cell::new(0)); - let cnt2 = cnt.clone(); - let (tx, rx) = oneshot::channel(); thread::spawn(|| { @@ -48,6 +45,9 @@ fn block_waits() { tx.send(()).unwrap(); }); + let cnt = Rc::new(Cell::new(0)); + let cnt2 = cnt.clone(); + block_on_all(rx.then(move |_| { cnt.set(1 + cnt.get()); Ok::<_, ()>(()) @@ -300,28 +300,28 @@ fn spawn_in_drop() { let (tx, rx) = oneshot::channel(); - struct OnDrop(Option); + current_thread.spawn({ + struct OnDrop(Option); - impl Drop for OnDrop { - fn drop(&mut self) { - (self.0.take().unwrap())(); + impl Drop for OnDrop { + fn drop(&mut self) { + (self.0.take().unwrap())(); + } } - } - struct MyFuture { - _data: Box, - } + struct MyFuture { + _data: Box, + } - impl Future for MyFuture { - type Item = (); - type Error = (); + impl Future for MyFuture { + type Item = (); + type Error = (); - fn poll(&mut self) -> Poll<(), ()> { - Ok(().into()) + fn poll(&mut self) -> Poll<(), ()> { + Ok(().into()) + } } - } - current_thread.spawn({ MyFuture { _data: Box::new(OnDrop(Some(move || { current_thread::spawn(lazy(move || { @@ -355,10 +355,18 @@ fn hammer_turn() { let (tx, rx) = mpsc::unbounded(); current_thread.spawn({ - rx.for_each(|_| { + let cnt = Rc::new(Cell::new(0)); + let c = cnt.clone(); + + rx.for_each(move |_| { + c.set(1 + c.get()); Ok(()) }) .map_err(|e| panic!("err={:?}", e)) + .map(move |v| { + assert_eq!(N, cnt.get()); + v + }) }); thread::spawn(move || { -- cgit v1.2.3 ='dependabot/composer/phpstan/phpstan-strict-rules-1.5.5'>dependabot/composer/phpstan/phpstan-strict-rules-1.5.5 Mirror of https://github.com/nextcloud/newsmatthias
summaryrefslogtreecommitdiffstats
blob: a0b10aeed0ab4994196ca922394cc9eeff761139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php if ($_['cronWarning']) { ?>
    <news-instant-notification id="cron-warning">
        <p><?php p($l->t('Ajax cron mode detected! Your feeds will ' .
            'not be updated correctly. It is recommended to either use ' .
            'the operating system cron or a custom updater.'
        )); ?>
            <ul>
                <li>
                    <a href="https://doc.owncloud.org/server/8.0/admin_manual/configuration_server/background_jobs_configuration.html#cron"
                       target="_blank">
                    <?php
                        p($l->t('How to set up the operating system cron'));
                    ?>
                    </a>
                </li>
                <li>
                    <a href="https://github.com/owncloud/news/wiki/Custom-Updater"
                       target="_blank">
                        <?php
                            p($l->t('How to set up a custom updater ' .
                                    '(faster and no possible deadlock) '
                            ));
                        ?>
                    </a>
                </li>
            </ul>
        </p>
    </news-instant-notification>
<?php }; ?>