Home | History | Annotate | Line # | Download | only in unit-tests
      1  1.1  rillig # $NetBSD: deptgt-end-jobs.mk,v 1.1 2020/09/23 03:06:38 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # Tests for the special target .END in dependency declarations,
      4  1.1  rillig # which is run after making the desired targets.
      5  1.1  rillig #
      6  1.1  rillig # This test is very similar to deptgt-end.mk, except for the -j option.
      7  1.1  rillig # This option enables parallel mode, in which the code from job.c partially
      8  1.1  rillig # replaces the code from compat.c.
      9  1.1  rillig #
     10  1.1  rillig # Before 2020-08-22, this test crashed with a null pointer dereference.
     11  1.1  rillig # Before 2020-09-23, this test crashed with an assertion failure.
     12  1.1  rillig .MAKEFLAGS: -j 8
     13  1.1  rillig 
     14  1.1  rillig VAR=	Should not be expanded.
     15  1.1  rillig 
     16  1.1  rillig .BEGIN:
     17  1.1  rillig 	: $@ '$${VAR}'
     18  1.1  rillig 	...
     19  1.1  rillig 	: $@ '$${VAR}' deferred
     20  1.1  rillig # Oops: The deferred command must not be expanded twice.
     21  1.1  rillig # The Var_Subst in Compat_RunCommand looks suspicious.
     22  1.1  rillig # The Var_Subst in JobSaveCommand looks suspicious.
     23  1.1  rillig 
     24  1.1  rillig .END:
     25  1.1  rillig 	: $@ '$${VAR}'
     26  1.1  rillig 	...
     27  1.1  rillig 	: $@ '$${VAR}' deferred
     28  1.1  rillig 
     29  1.1  rillig all:
     30  1.1  rillig 	: $@ '$${VAR}'
     31  1.1  rillig 	...
     32  1.1  rillig 	: $@ '$${VAR}' deferred
     33  1.1  rillig # Oops: The deferred command must not be expanded twice.
     34  1.1  rillig # The Var_Subst in Compat_RunCommand looks suspicious.
     35  1.1  rillig # The Var_Subst in JobSaveCommand looks suspicious.
     36  1.1  rillig 
     37  1.1  rillig # The deferred commands are run in the order '.END .BEGIN all'.
     38  1.1  rillig # This may be unexpected at first since the natural order would be
     39  1.1  rillig # '.BEGIN all .END', but it is implemented correctly.
     40  1.1  rillig #
     41  1.1  rillig # At the point where the commands of a node with deferred commands are run,
     42  1.1  rillig # the deferred commands are appended to the commands of the .END node.
     43  1.1  rillig # This happens in Compat_RunCommand, and to prevent an endless loop, the
     44  1.1  rillig # deferred commands of the .END node itself are not appended to itself.
     45  1.1  rillig # Instead, the deferred commands of the .END node are run as if they were
     46  1.1  rillig # immediate commands.
     47