Buildd-setup faffing around with __FILE__ breaks my unit tests.

Sune Vuorela sune at debian.org
Sun Feb 10 20:11:49 GMT 2019


On Sunday, February 10, 2019 8:38:00 PM CET Ximin Luo wrote:
> Yes, pass the source dir in through the build system "somehow", there are
> lots of possible ways you can do this, and this is what every other test
> runner does. A command-line argument or environment variable would be
> simplest.

So what you are saying is rewrite all test cases or build systems for tests 
using QFINDTESTDATA?  I don't think that's a feasible approach.

Also note that the way QFINDTESTDATA is implemented doesn't require support 
from the build system at all. Only the compiler. So quite some 
rearchitechturing  of lots of existing tests are needed. 

I could of course try to get something into Qt like

#ifndef QTEST_SOURCE_LOCATION
#define QTEST_SOURCE_LOCATION __FILE__
#endif

then redo QTESTDATA to 
#define QTESTDATA(filepath) ..... (filepath, QTEST_SOURCE_LOCATION) 

and then go thru all the unit tests in the world and for the cmake based tests 
add

target_compile_definitions(testname PRIVATE -DQTEST_SOURCE_LOCATION="$
{CMAKE_CURRENT_SOURCE_DIR}") 

and something similar for all the qmake based builds. and for the other build 
systems. 



The more I look into this, the more I think the better approach is to just 
keep the build dir part of the build environment required for reproducibility. 
Just like exact compiler and dependency version. 
Then this problem all goes away. 


I still don't think I have understood why modifying the existing behaviour of 
__FILE__ is actually needed.


/Sune
 - who by the way cleaned most of Qt for the __DATE__ and __TIME__ macros.
-- 
I didn’t stop pretending when I became an adult, it’s just that when I was a 
kid I was pretending that I fit into the rules and structures of this world. 
And now that I’m an adult, I pretend that those rules and structures exist.
   - zefrank





More information about the Reproducible-builds mailing list