comp.lang.ada
 help / color / mirror / Atom feed
From: briot.emmanuel@gmail.com
Subject: Re: gprbuild and package renames (testsuites)
Date: Mon, 24 Jun 2019 08:39:05 -0700 (PDT)
Date: 2019-06-24T08:39:05-07:00	[thread overview]
Message-ID: <2aa12fd0-dcf6-4b31-9c13-612a359dd731@googlegroups.com> (raw)
In-Reply-To: <86e32abe-7c57-4ea1-879e-869464a6a316@googlegroups.com>

I don't think you'll be able to run all three testsuites from the same executable. Instead, you could use a "scenario variable" to configure mode1, mode2 and mode3. Some case statements would be used to select which packages are stubs, as well as a mode-specific executable name and likely mode-specific object dirs. Then you run all three executables independently.

Things get more interesting when you have multiple projects involved. In this case, that would mean having to duplicate the case statements in all projects (and things get even more complicated when you want to mock various combinations -- for instance mock postgresql and Kafka for one test, but not mock postgresql in another one).

In the end, the case statement approach doesn't scale really well. We ended up using "extending" and "extending all" projects. For instance:

   project Postgresql is
         ...  --   used to build production executables
   end Postgresql;

   with "postgresql.gpr";
   with "b.gpr";
   project Build is
        ...  --  used to build production executables
   end Build;
 
   project Postgresql_Mock extends "postgresql.gpr" is
       --  override any file you need
       for Source_Dirs use ("mocks");
   end Postgresql_Mock;

  
   with "postgresql_mock.gpr";
   with "b.gpr";
   project Unittest extends all "build.gpr" is
        --  any project imported by build.gpr or b.gpr that was
        --  also importing "postgresql.gpr" will now instead
        --  import "postgresql_mock.gpr" and thus see the mocks
   end Unittest;

This solution is not so easy to setup, and is kind of fragile because it frequently happens that gprbuild doesn't properly recompile all the files (though I could never reproduce systematically and thus report it). In general
this happens when the timestamps of the mocks are similar to the timestamps of
the original files, so by "touch"-ing some files we get around the gprbuild
issues...

Emmanuel

  reply	other threads:[~2019-06-24 15:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24  7:47 gprbuild and package renames (testsuites) Per Jakobsen
2019-06-24 15:39 ` briot.emmanuel [this message]
2019-06-25  5:47   ` Per Jakobsen
2019-06-26 14:14 ` Mark Lorenzen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox