From 12b062b2c862fd436cff0df4ebb2e5ca22e75e19 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 5 Mar 2017 04:02:45 +0300 Subject: unittests: Run all unit tests in their own processes Used sed -r -i -e '/ helpers =/ s/$/\nlocal itp = helpers.gen_itp(it)/; s/^(\s*)it\(/\1itp(/' test/unit/**/*_spec.lua to alter all tests. Locally they all run fine now. Reasoning: 1. General: state from one test should not affect other tests. 2. Local: travis build is failing with something which may be an output of garbage collector. This should prevent state of the garbage collector from interferring as well. --- test/unit/multiqueue_spec.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'test/unit/multiqueue_spec.lua') diff --git a/test/unit/multiqueue_spec.lua b/test/unit/multiqueue_spec.lua index c7f8dd8328..632a091d60 100644 --- a/test/unit/multiqueue_spec.lua +++ b/test/unit/multiqueue_spec.lua @@ -1,4 +1,5 @@ local helpers = require("test.unit.helpers") +local itp = helpers.gen_itp(it) local ffi = helpers.ffi local eq = helpers.eq @@ -36,13 +37,13 @@ describe("multiqueue (multi-level event-queue)", function() put(child3, 'c3i2') end) - it('keeps count of added events', function() + itp('keeps count of added events', function() eq(3, multiqueue.multiqueue_size(child1)) eq(4, multiqueue.multiqueue_size(child2)) eq(2, multiqueue.multiqueue_size(child3)) end) - it('keeps count of removed events', function() + itp('keeps count of removed events', function() multiqueue.multiqueue_get(child1) eq(2, multiqueue.multiqueue_size(child1)) multiqueue.multiqueue_get(child1) @@ -57,7 +58,7 @@ describe("multiqueue (multi-level event-queue)", function() eq(0, multiqueue.multiqueue_size(child1)) end) - it('removing from parent removes from child', function() + itp('removing from parent removes from child', function() eq('c1i1', get(parent)) eq('c1i2', get(parent)) eq('c2i1', get(parent)) @@ -67,7 +68,7 @@ describe("multiqueue (multi-level event-queue)", function() eq('c2i4', get(parent)) end) - it('removing from child removes from parent', function() + itp('removing from child removes from parent', function() eq('c2i1', get(child2)) eq('c2i2', get(child2)) eq('c1i1', get(child1)) @@ -77,13 +78,13 @@ describe("multiqueue (multi-level event-queue)", function() eq('c2i4', get(parent)) end) - it('removing from child at the beginning of parent', function() + itp('removing from child at the beginning of parent', function() eq('c1i1', get(child1)) eq('c1i2', get(child1)) eq('c2i1', get(parent)) end) - it('removing from parent after get from parent and put to child', function() + itp('removing from parent after get from parent and put to child', function() eq('c1i1', get(parent)) eq('c1i2', get(parent)) eq('c2i1', get(parent)) @@ -99,7 +100,7 @@ describe("multiqueue (multi-level event-queue)", function() eq('c1i22', get(parent)) end) - it('removing from parent after get and put to child', function() + itp('removing from parent after get and put to child', function() eq('c1i1', get(child1)) eq('c1i2', get(child1)) eq('c2i1', get(child2)) @@ -117,7 +118,7 @@ describe("multiqueue (multi-level event-queue)", function() eq('c1i12', get(parent)) end) - it('put after removing from child at the end of parent', function() + itp('put after removing from child at the end of parent', function() eq('c3i1', get(child3)) eq('c3i2', get(child3)) put(child1, 'c1i11') @@ -133,7 +134,7 @@ describe("multiqueue (multi-level event-queue)", function() eq('c2i11', get(parent)) end) - it('removes from parent queue when child is freed', function() + itp('removes from parent queue when child is freed', function() free(child2) eq('c1i1', get(parent)) eq('c1i2', get(parent)) -- cgit From 9400466282918396c814ef456d0f65dca51b8889 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 11 Mar 2017 13:28:18 +0300 Subject: unittests: Check core dumps in after_each, like in functests --- test/unit/multiqueue_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/unit/multiqueue_spec.lua') diff --git a/test/unit/multiqueue_spec.lua b/test/unit/multiqueue_spec.lua index 632a091d60..b72040a396 100644 --- a/test/unit/multiqueue_spec.lua +++ b/test/unit/multiqueue_spec.lua @@ -1,4 +1,4 @@ -local helpers = require("test.unit.helpers") +local helpers = require("test.unit.helpers")(after_each) local itp = helpers.gen_itp(it) local ffi = helpers.ffi -- cgit From e2a578f40dbd4836330402a44844c7ef8a0df5c5 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 11 Mar 2017 16:02:47 +0300 Subject: unittests: Do not import libnvim or headers in main process Slows down unit tests much, but gets rid of as much preserved state as possible. --- test/unit/multiqueue_spec.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test/unit/multiqueue_spec.lua') diff --git a/test/unit/multiqueue_spec.lua b/test/unit/multiqueue_spec.lua index b72040a396..bb90728c24 100644 --- a/test/unit/multiqueue_spec.lua +++ b/test/unit/multiqueue_spec.lua @@ -1,10 +1,12 @@ local helpers = require("test.unit.helpers")(after_each) local itp = helpers.gen_itp(it) -local ffi = helpers.ffi -local eq = helpers.eq +local deferred_call = helpers.deferred_call +local cimport = helpers.cimport +local ffi = helpers.ffi +local eq = helpers.eq -local multiqueue = helpers.cimport("./test/unit/fixtures/multiqueue.h") +local multiqueue = cimport("./test/unit/fixtures/multiqueue.h") describe("multiqueue (multi-level event-queue)", function() local parent, child1, child2, child3 @@ -21,7 +23,7 @@ describe("multiqueue (multi-level event-queue)", function() multiqueue.multiqueue_free(q) end - before_each(function() + before_each(deferred_call(function() parent = multiqueue.multiqueue_new_parent(ffi.NULL, ffi.NULL) child1 = multiqueue.multiqueue_new_child(parent) child2 = multiqueue.multiqueue_new_child(parent) @@ -35,7 +37,7 @@ describe("multiqueue (multi-level event-queue)", function() put(child2, 'c2i4') put(child3, 'c3i1') put(child3, 'c3i2') - end) + end)) itp('keeps count of added events', function() eq(3, multiqueue.multiqueue_size(child1)) -- cgit From bf68907778aba402ead678a6846f865d29e666d8 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 12 Mar 2017 02:54:23 +0300 Subject: unittests: Use more adequate names for some functions --- test/unit/multiqueue_spec.lua | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'test/unit/multiqueue_spec.lua') diff --git a/test/unit/multiqueue_spec.lua b/test/unit/multiqueue_spec.lua index bb90728c24..bb08a8386f 100644 --- a/test/unit/multiqueue_spec.lua +++ b/test/unit/multiqueue_spec.lua @@ -1,7 +1,7 @@ local helpers = require("test.unit.helpers")(after_each) local itp = helpers.gen_itp(it) -local deferred_call = helpers.deferred_call +local child_call_once = helpers.child_call_once local cimport = helpers.cimport local ffi = helpers.ffi local eq = helpers.eq @@ -23,21 +23,23 @@ describe("multiqueue (multi-level event-queue)", function() multiqueue.multiqueue_free(q) end - before_each(deferred_call(function() - parent = multiqueue.multiqueue_new_parent(ffi.NULL, ffi.NULL) - child1 = multiqueue.multiqueue_new_child(parent) - child2 = multiqueue.multiqueue_new_child(parent) - child3 = multiqueue.multiqueue_new_child(parent) - put(child1, 'c1i1') - put(child1, 'c1i2') - put(child2, 'c2i1') - put(child1, 'c1i3') - put(child2, 'c2i2') - put(child2, 'c2i3') - put(child2, 'c2i4') - put(child3, 'c3i1') - put(child3, 'c3i2') - end)) + before_each(function() + child_call_once(function() + parent = multiqueue.multiqueue_new_parent(ffi.NULL, ffi.NULL) + child1 = multiqueue.multiqueue_new_child(parent) + child2 = multiqueue.multiqueue_new_child(parent) + child3 = multiqueue.multiqueue_new_child(parent) + put(child1, 'c1i1') + put(child1, 'c1i2') + put(child2, 'c2i1') + put(child1, 'c1i3') + put(child2, 'c2i2') + put(child2, 'c2i3') + put(child2, 'c2i4') + put(child3, 'c3i1') + put(child3, 'c3i2') + end) + end) itp('keeps count of added events', function() eq(3, multiqueue.multiqueue_size(child1)) -- cgit