OK, with all the recent changes there are several failures in building the unit tests. There many be multiple issues here but I just create one ticket now.
The full unit test build log is attached
system: Fedora 19, on x86-64
uname -a
Linux HPQuad 3.11.10-200.fc19.x86_64 #1 SMP Mon Dec 2 20:28:03 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
compiler used:
gcc -v
Thread model: posix
gcc version 4.8.2 20131017 (Red Hat 4.8.2-1) (GCC)
FYI: if you check out the git repository, you can build the unit tests this way:
(on a GNU/Linux machine, like what I am using is Fedora 19)
[atai@HPQuad sqrat.git]$ cd ..
[atai@HPQuad sqrat]$ mkdir b
[atai@HPQuad sqrat]$ cd b
[atai@HPQuad b]$ ../sqrat.git/autotools/configure && make -j 4 check
Last edit: Andy Tai 2013-12-20
a few key failure lines:
../sqrat.git/autotools/../sqrattest/SquirrelFunctions.cpp: In member function ‘virtual void SqratTest_CallSquirrelFunction_Test::TestBody()’:
../sqrat.git/autotools/../sqrattest/SquirrelFunctions.cpp:69:55: error: could not convert ‘Sqrat::Function::Evaluate() with R = bool’ from ‘Sqrat::SharedPtr<bool>’ to ‘bool’
ASSERT_TRUE(returnTrue.Evaluate<bool>());
^
../sqrat.git/autotools/../sqrattest/SquirrelFunctions.cpp:70:57: error: could not convert ‘Sqrat::Function::Evaluate() with R = long long unsigned int’ from ‘Sqrat::SharedPtr<long long="" unsigned="" int="">’ to ‘bool’
ASSERT_TRUE(returnTrue.Evaluate<SQBool>());
^
../sqrat.git/autotools/../sqrattest/SquirrelFunctions.cpp: In function ‘int NativeOp(int, int, Sqrat::Function)’:
../sqrat.git/autotools/../sqrattest/SquirrelFunctions.cpp:83:37: error: cannot convert ‘Sqrat::SharedPtr<int>’ to ‘int’ in return
return opFunc.Evaluate<int>(a, b);
../sqrat.git/autotools/../include/sqrat/sqratUtil.h:304:17: error: initializing argument 2 of ‘bool Sqrat::operator==(const Sqrat::SharedPtr<int>&, const int)’ [-fpermissive]
bool friend operator ==(const SharedPtr<T>& left, const T right)
^
../sqrat.git/autotools/../include/sqrat/sqratUtil.h: In instantiation of ‘Sqrat::SharedPtr<T>::SharedPtr(const Sqrat::SharedPtr<T>&) [with T = bool]’:
../sqrat.git/autotools/../include/sqrat/sqratFunction.h:120:33: required from ‘Sqrat::SharedPtr<T> Sqrat::Function::Evaluate() [with R = bool]’
../sqrat.git/autotools/../sqrattest/SquirrelFunctions.cpp:69:54: required from here
../sqrat.git/autotools/../include/sqrat/sqratUtil.h:180:24: error: expression cannot be used as a function
m_RefCount = copy.m_RefCount();
../sqrat.git/autotools/../include/sqrat/sqratUtil.h: In instantiation of ‘Sqrat::SharedPtr<T>& Sqrat::SharedPtr<T>::operator=(const Sqrat::SharedPtr<T>&) [with T = bool]’:
../sqrat.git/autotools/../include/sqrat/sqratTypes.h:260:19: required from ‘Sqrat::Var<Sqrat::SharedPtr<T> >::Var(HSQUIRRELVM, SQInteger) [with T = bool; HSQUIRRELVM = SQVM*; SQInteger = long long int]’
../sqrat.git/autotools/../include/sqrat/sqratFunction.h:135:55: required from ‘Sqrat::SharedPtr<T> Sqrat::Function::Evaluate() [with R = bool]’
../sqrat.git/autotools/../sqrattest/SquirrelFunctions.cpp:69:54: required from here
../sqrat.git/autotools/../include/sqrat/sqratUtil.h:219:28: error: expression cannot be used as a function
../sqrat.git/autotools/../include/sqrat/sqratUtil.h: In instantiation of ‘Sqrat::SharedPtr<T>& Sqrat::SharedPtr<T>::operator=(const Sqrat::SharedPtr<T>&) [with T = long long unsigned int]’:
../sqrat.git/autotools/../include/sqrat/sqratTypes.h:260:19: required from ‘Sqrat::Var<Sqrat::SharedPtr<T> >::Var(HSQUIRRELVM, SQInteger) [with T = long long unsigned int; HSQUIRRELVM = SQVM*; SQInteger = long long int]’
../sqrat.git/autotools/../include/sqrat/sqratFunction.h:135:55: required from ‘Sqrat::SharedPtr<T> Sqrat::Function::Evaluate() [with R = long long unsigned int]’
../sqrat.git/autotools/../sqrattest/SquirrelFunctions.cpp:70:56: required from here
../sqrat.git/autotools/../include/sqrat/sqratUtil.h:219:28: error: expression cannot be used as a function
make[1]: *** [squirrel_functions-SquirrelFunctions.o] Error 1
The unit tests may not cover all uses cases of Sqrat but they do represent a good coverage of what Sqrat supports. so we shall make sure new changes do not break the tests (unless API changes intentionally require breaking existing usage patterns)
Last edit: Andy Tai 2013-12-20
Diff:
There are two groups of failures: type conversion involving the new SharedPtr, and some failures involving table APIs
There was an API change that broke them (as far as I can tell from that log, the one API change is the thing that broke them). I was asking about this earlier, but since there was no discussion for a few days I just added the API change. We can still revert it. It was just a small bug fix that I saw no better way around. It being the use of SharedPtr in Function::Evaluate. I can make most of those failures in the unit tests go away by adding an implicit bool conversion (which I think is a good idea to add anyways), but some of the SharedPtr objects need to be dereferenced using the * operator (or -> operator). Function::Evaluate, Array::GetValue, and Table::GetValue currently use SharedPtr as opposed to the old return values. There was an issue with these functions not working with classes that do not have a default constructor. This could have been fixed by changing the API in a different way (pass by reference), but I found this to be the least intrusive and CPU intensive way (no unnecessary constructors are called). People will have to change around code in the places in which they call the changed functions (they are seldom used functions anyways, depends on what you're binding though), and documentation should exist in a changelog for the newest version such that people are aware that this will be an issue when they change versions.
http://forum.squirrel-lang.org/mainsite/forums/default.aspx?g=posts&m=7486#post7486
By the way, I want to eventually setup a Linux distro on my PC so that I can run the unit tests, but it'd be easier if there was some way to get them to work on Windows. I know there exists a SLN file for Visual C++, but I'm not sure if it is up to date.
I added that "implicit" bool conversion. I made it explicit though because I don't think it should be implicit. SharedPtr can be used exactly as a normal pointer now as far as I can tell.
Additionally, there was this change that I doubt affects any code (but it is one of the only other API changes, I can't remember doing any other ones)
Last edit: Wizzard 2013-12-20
I also plan on changing Sqrat::Class::Prop to match Sqrat::Class::GlobalProp's prototype. I don't think this will affect anything, but I just wanted to note that here in the small chance that it causes a problem (it will use a template instead of what it currently uses, but it should not affect calls to it).
Fixed a bug that caused some of the errors
Does that last commit fix them?
Not sure. I am not in front of the computer that I have for running the unit tests. Will check tonight
OK, still failure on some table stuff
../sqrat.git/autotools/../sqrattest/TableBinding.cpp: In member function ‘virtual void SqratTest_TableGet_Test::TestBody()’:
../sqrat.git/autotools/../sqrattest/TableBinding.cpp:176:62: error: no matching function for call to ‘Sqrat::Table::GetValue(const char)’
SharedPtr<string> value2 = table.GetValue(key.c_str());
^
../sqrat.git/autotools/../sqrattest/TableBinding.cpp:176:62: note: candidates are:
In file included from ../sqrat.git/autotools/../include/sqrat.h:54:0,
from ../sqrat.git/autotools/../sqrattest/TableBinding.cpp:25:
../sqrat.git/autotools/../include/sqrat/sqratTable.h:229:18: note: template<class T=""> Sqrat::SharedPtr<T> Sqrat::TableBase::GetValue(const SQChar)
SharedPtr<T> GetValue(const SQChar name)
^
../sqrat.git/autotools/../include/sqrat/sqratTable.h:229:18: note: template argument deduction/substitution failed:
../sqrat.git/autotools/../sqrattest/TableBinding.cpp:176:62: note: couldn't deduce template parameter ‘T’
SharedPtr<string> value2 = table.GetValue(key.c_str());
^
In file included from ../sqrat.git/autotools/../include/sqrat.h:54:0,
from ../sqrat.git/autotools/../sqrattest/TableBinding.cpp:25:
../sqrat.git/autotools/../include/sqrat/sqratTable.h:267:18: note: template<class T=""> Sqrat::SharedPtr<T> Sqrat::TableBase::GetValue(int)
SharedPtr<T> GetValue(int index)
^
../sqrat.git/autotools/../include/sqrat/sqratTable.h:267:18: note: template argument deduction/substitution failed:
../sqrat.git/autotools/../sqrattest/TableBinding.cpp:176:62: note: cannot convert ‘key.std::basic_string<_CharT, _Traits, _Alloc>::c_str<char, std::char_traits<char="">, std::allocator<char> >()’ (type ‘const char’) to type ‘int’
SharedPtr<string> value2 = table.GetValue(key.c_str());
^
../sqrat.git/autotools/../sqrattest/TableBinding.cpp:193:52: error: no matching function for call to ‘Sqrat::Table::GetValue(int&)’
SharedPtr<string> value2 = table.GetValue(i);
^
../sqrat.git/autotools/../sqrattest/TableBinding.cpp:193:52: note: candidates are:
In file included from ../sqrat.git/autotools/../include/sqrat.h:54:0,
from ../sqrat.git/autotools/../sqrattest/TableBinding.cpp:25:
../sqrat.git/autotools/../include/sqrat/sqratTable.h:229:18: note: template<class T=""> Sqrat::SharedPtr<T> Sqrat::TableBase::GetValue(const SQChar)
SharedPtr<T> GetValue(const SQChar name)
^
complete build log at this point after the latest checkins
Okay. I tried to fix the unit tests again. I really wish I could test them myself :(
now everything builds
commit 9e5190f6417d28a88ce483e8b61b6dacc8448a13
Author: Andy Tai atai@atai.org
Date: Sat Dec 21 03:13:18 2013 -0800
Last edit: Andy Tai 2013-12-21
these four unit tests fail (I did not do any debugging yet on these to see where things fail in the unit tests)
FAIL: table_binding
FAIL: squirrel_functions
FAIL: run_stack_handling
FAIL: array_binding
Last edit: Andy Tai 2013-12-21
While I can understand why table_binding, squirrel_functions, and array_binding might be failing due to their use of features I implemented without testing fully, I am unsure why run_stack_handling would fail. Hmm...
I will try doing some tests tomorrow (its late at night) to make sure Table::GetValue, Array::GetValue, and Function::Evaluate work as I intend. I never tested those and just assumed they worked.
Last edit: Wizzard 2013-12-21
run_stack_handling fixed
valgrind reports on "squirrel_function":
[atai@HPQuad build]$ valgrind ./squirrel_functions
==311== Memcheck, a memory error detector
==311== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==311== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==311== Command: ./squirrel_functions
==311==
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from SqratTest
[ RUN ] SqratTest.CallSquirrelFunction
==311== Conditional jump or move depends on uninitialised value(s)
==311== at 0x40A554: Sqrat::SharedPtr<int>::Reset() (sqratUtil.h:272)
==311== by 0x40B563: Sqrat::SharedPtr<int>::Init(int) (sqratUtil.h:253)
==311== by 0x40A400: Sqrat::SharedPtr<int>::SharedPtr() (sqratUtil.h:163)
==311== by 0x40A4A0: Sqrat::Var<Sqrat::SharedPtr<int> >::Var(SQVM, long long) (sqratTypes.h:255)
==311== by 0x409585: Sqrat::SharedPtr<int> Sqrat::Function::Evaluate<int, int,="" int="">(int, int) (sqratFunction.h:208)
==311== by 0x4042DA: SqratTest_CallSquirrelFunction_Test::TestBody() (SquirrelFunctions.cpp:60)
==311== by 0x412ED1: testing::Test::Run() (gtest.cc:2070)
==311== by 0x413570: testing::internal::TestInfoImpl::Run() (gtest.cc:2292)
==311== by 0x41E26F: testing::internal::TestInfoImpl::RunTest(testing::TestInfo) (gtest-internal-inl.h:643)
==311== by 0x420A7B: void testing::internal::List<testing::TestInfo*>::ForEach<void (*)(testing::TestInfo*)="">(void ()(testing::TestInfo)) const (gtest-internal-inl.h:397)
==311== by 0x41395A: testing::TestCase::Run() (gtest.cc:2388)
==311== by 0x41E3BF: testing::TestCase::RunTestCase(testing::TestCase) (gtest-internal-inl.h:762)
==311==
==311== Use of uninitialised value of size 8
==311== at 0x40A55E: Sqrat::SharedPtr<int>::Reset() (sqratUtil.h:274)
==311== by 0x40B563: Sqrat::SharedPtr<int>::Init(int) (sqratUtil.h:253)
==311== by 0x40A400: Sqrat::SharedPtr<int>::SharedPtr() (sqratUtil.h:163)
==311== by 0x40A4A0: Sqrat::Var<Sqrat::SharedPtr<int> >::Var(SQVM, long long) (sqratTypes.h:255)
==311== by 0x409585: Sqrat::SharedPtr<int> Sqrat::Function::Evaluate<int, int,="" int="">(int, int) (sqratFunction.h:208)
==311== by 0x4042DA: SqratTest_CallSquirrelFunction_Test::TestBody() (SquirrelFunctions.cpp:60)
==311== by 0x412ED1: testing::Test::Run() (gtest.cc:2070)
==311== by 0x413570: testing::internal::TestInfoImpl::Run() (gtest.cc:2292)
==311== by 0x41E26F: testing::internal::TestInfoImpl::RunTest(testing::TestInfo) (gtest-internal-inl.h:643)
==311== by 0x420A7B: void testing::internal::List<testing::TestInfo*>::ForEach<void (*)(testing::TestInfo*)="">(void ()(testing::TestInfo)) const (gtest-internal-inl.h:397)
==311== by 0x41395A: testing::TestCase::Run() (gtest.cc:2388)
==311== by 0x41E3BF: testing::TestCase::RunTestCase(testing::TestCase) (gtest-internal-inl.h:762)
==311==
==311== Use of uninitialised value of size 8
==311== at 0x40A5AD: Sqrat::SharedPtr<int>::Reset() (sqratUtil.h:283)
==311== by 0x40B563: Sqrat::SharedPtr<int>::Init(int) (sqratUtil.h:253)
==311== by 0x40A400: Sqrat::SharedPtr<int>::SharedPtr() (sqratUtil.h:163)
==311== by 0x40A4A0: Sqrat::Var<Sqrat::SharedPtr<int> >::Var(SQVM, long long) (sqratTypes.h:255)
==311== by 0x409585: Sqrat::SharedPtr<int> Sqrat::Function::Evaluate<int, int,="" int="">(int, int) (sqratFunction.h:208)
==311== by 0x4042DA: SqratTest_CallSquirrelFunction_Test::TestBody() (SquirrelFunctions.cpp:60)
==311== by 0x412ED1: testing::Test::Run() (gtest.cc:2070)
==311== by 0x413570: testing::internal::TestInfoImpl::Run() (gtest.cc:2292)
==311== by 0x41E26F: testing::internal::TestInfoImpl::RunTest(testing::TestInfo) (gtest-internal-inl.h:643)
==311== by 0x420A7B: void testing::internal::List<testing::TestInfo*>::ForEach<void (*)(testing::TestInfo*)="">(void ()(testing::TestInfo)) const (gtest-internal-inl.h:397)
==311== by 0x41395A: testing::TestCase::Run() (gtest.cc:2388)
==311== by 0x41E3BF: testing::TestCase::RunTestCase(testing::TestCase) (gtest-internal-inl.h:762)
==311==
==311== Use of uninitialised value of size 8
==311== at 0x40A5B2: Sqrat::SharedPtr<int>::Reset() (sqratUtil.h:283)
==311== by 0x40B563: Sqrat::SharedPtr<int>::Init(int) (sqratUtil.h:253)
==311== by 0x40A400: Sqrat::SharedPtr<int>::SharedPtr() (sqratUtil.h:163)
==311== by 0x40A4A0: Sqrat::Var<Sqrat::SharedPtr<int> >::Var(SQVM, long long) (sqratTypes.h:255)
==311== by 0x409585: Sqrat::SharedPtr<int> Sqrat::Function::Evaluate<int, int,="" int="">(int, int) (sqratFunction.h:208)
==311== by 0x4042DA: SqratTest_CallSquirrelFunction_Test::TestBody() (SquirrelFunctions.cpp:60)
==311== by 0x412ED1: testing::Test::Run() (gtest.cc:2070)
==311== by 0x413570: testing::internal::TestInfoImpl::Run() (gtest.cc:2292)
==311== by 0x41E26F: testing::internal::TestInfoImpl::RunTest(testing::TestInfo) (gtest-internal-inl.h:643)
==311== by 0x420A7B: void testing::internal::List<testing::TestInfo*>::ForEach<void (*)(testing::TestInfo*)="">(void ()(testing::TestInfo)) const (gtest-internal-inl.h:397)
==311== by 0x41395A: testing::TestCase::Run() (gtest.cc:2388)
==311== by 0x41E3BF: testing::TestCase::RunTestCase(testing::TestCase) (gtest-internal-inl.h:762)
==311==
squirrel_functions: ../sqrat.git/autotools/../include/sqrat/sqratUtil.h:346: T& Sqrat::SharedPtr<T>::operator*() const [with T = int]: Assertion `m_Ptr != __null' failed.
==311==
==311== HEAP SUMMARY:
==311== in use at exit: 64,341 bytes in 448 blocks
==311== total heap usage: 770 allocs, 322 frees, 129,528 bytes allocated
==311==
this needs deeper look
Weird. I found a line that was definitely breaking Table::GetValue. It works now in my small little test application. I assume this issue was breaking all the SharedPtr functions. I changed a couple other things but I think they had zero effect on the problem.
That line shouldn't even compile. I have stared at it awhile and looked at the operators I defined. Why does that line compile? I'd rather have it give an error so users know that that type of syntax is invalid (it would've helped me). I was supposed to write value.Init(new T(instance)) instead.
thanks wizzard, the latest changes fixed the unit test "squirrel_function"
commit a4683d857664e89e247eb5db151c557d6a865838
Author: Andy Tai atai@atai.org
Date: Sun Dec 22 02:29:10 2013 -0800
now the only failure left:
[atai@HPQuad build]$ valgrind ./table_binding
==9162== Memcheck, a memory error detector
==9162== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==9162== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==9162== Command: ./table_binding
==9162==
[==========] Running 6 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 6 tests from SqratTest
[ RUN ] SqratTest.SimpleTableBinding
../sqrat.git/autotools/../sqrattest/TableBinding.cpp:111: Failure
Value of: 1
Expected: value != null
Which is: false
table_binding: ../sqrat.git/autotools/../include/sqrat/sqratUtil.h:358: T* Sqrat::SharedPtr<T>::operator->() const [with T = std::basic_string<char>]: Assertion `m_Ptr != null' failed.
==9162==
In the unit test I added some code to try to retrieve the table fields in C++ that were supposedly created via SetValue() earlier. the table does not have these fields after SetValue() is called. Reason not clear to me