Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMAKE_POST_LINK process run

QMAKE_POST_LINK process run

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 2.9k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • HolidayH Offline
    HolidayH Offline
    Holiday
    wrote on last edited by
    #1

    Hi everyone.
    I have a project with unit tests (G-test). During building all project (solution), I want to interrupt project build if unit tests failed. How I can achive such behavior?

    I use START_COMMAND, which is "start /B "
    If use QMAKE_POST_LINK += $$START_COMMAND$$DESTDIR/$$TARGET $$PWD/TestFiles

    it build test, but if it fails, solution build don't stop.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      That's a rather unusual setup. The standard way of developing is to build everything and then run the tests. If you would like to do things more sequentially you should rather have a separated script that builds your various modules one after the other and run the tests after each module build.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Paul ColbyP Offline
        Paul ColbyP Offline
        Paul Colby
        wrote on last edited by
        #3

        As @SGaist said, that's a bit of an unusual pattern, which might indicate that you're going about something in a non-recommended way.

        But, if you do really want to break the build if an external command fails, then you need to add an additional qmake target.

        For example, here's how I break a build if doxygen fails to generate docs:

        doc.pro

        TEMPLATE = aux
        first.commands += doxygen all.dox && doxygen api.dox
        QMAKE_EXTRA_TARGETS += first
        

        The, my top-level (solution) .pro would look something like:

        TEMPLATE = subdirs
        SUBDIRS += src doc
        CONFIG += ordered
        doc.depends = src
        

        Out if curiosity, how are you building your G-test tests? via qmake or some other build tool?

        1 Reply Last reply
        0
        • HolidayH Offline
          HolidayH Offline
          Holiday
          wrote on last edited by Holiday
          #4

          @Paul-Colby said:

          Out if curiosity, how are you building your G-test tests? via qmake or some other build tool?

          via qmake
          build:
          int main(int argc, char* argv[])
          {
          QApplication a(argc, argv);

          ::testing::InitGoogleTest(&argc, argv);  //gtest.h function
          return RUN_ALL_TESTS();
          

          }

          Solution for my problem was find.
          I use START_COMMAND, which is "start /b /wait "

          and added command for process return value
          EXIT_RESULT_COMMAND = "EXIT /B %ERRORLEVEL%"

          use - add to test pro file command
          QMAKE_POST_LINK += $START_COMMAND$DESTDIR/$TARGET $PWD/TestFiles & $$EXIT_RESULT_COMMAND

          This will fail solution build (root pro file) if one of unit test fails

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved