Uploaded image for project: 'Qt Visual Studio Tools'
  1. Qt Visual Studio Tools
  2. QTVSADDINBUG-762

QtTest Project with corrupt QT_TESTCASE_BUILDDIR define

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 2.8.1 (rev.06)
    • 2.4.3
    • None
    • Visual Studio 2017 15.9.21

    Description

      Qt projects which use the testlib module cannot be compiled, because of the following compiler error:

      error C2664: "void QTest::setMainSourcePath(const char *,const char *)" : Conversion of argument 2 from "int" to "const char *" not possible

       

      This is caused by the following section inside the qtest.h

      #ifdef QT_TESTCASE_BUILDDIR
      #  define QTEST_SET_MAIN_SOURCE_PATH  QTest::setMainSourcePath(__FILE__, QT_TESTCASE_BUILDDIR);
      #else
      #  define QTEST_SET_MAIN_SOURCE_PATH  QTest::setMainSourcePath(__FILE__);
      #endif

      Since the QT_TESTCASE_BUILDDIR is defined by the mkspecs\features\testlib_defines.prf but the RegEx in QMake_DEFINES_ extracts only the key without the value, the above if branch is executed but the define is empty.
      To avoid that I've included also the values by using DEFINES=/-D(\S+)/$1/, which extracts correctly, but the value is incompatible with MSVC.

      The mentioned testlib_defines.prf contains the following content, but since apparently none of the vc templates is used, the alternative (incompatible) value is set.

      contains(TEMPLATE, vc.*): DEFINES += QT_TESTCASE_BUILDDIR=\"$$OUT_PWD\"
      else: DEFINES += QT_TESTCASE_BUILDDIR=$$shell_quote(\"$$OUT_PWD\")

      As a workaround I've now excluded the define which works at the moment. DEFINES=/-D((?!QT_TESTCASE_BUILDDIR)\S+)/$1/

      Attachments

        1. UT.zip
          2 kB
          anoymouserver

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              mecfc Miguel Costa
              anoymouserver anoymouserver
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes