1#!/usr/local/bin/python3.8
2
3# Copyright 2012. Jurko Gospodnetic
4# Distributed under the Boost Software License, Version 1.0.
5# (See accompanying file LICENSE_1_0.txt or copy at
6# http://www.boost.org/LICENSE_1_0.txt)
7
8#   Tests that variables in actions get expanded but double quote characters
9# get treated as regular characters and not string literal delimiters when
10# determining string tokens concatenated to the variable being expanded.
11#
12#   We also take care to make this test work correctly when run using both
13# Windows and Unix echo command variant. That is why we add the extra single
14# quotes around the text being echoed - they will make the double quotes be
15# displayed as regular characters in both cases but will be displayed
16# themselves only when using the Windows cmd shell's echo command.
17
18import BoostBuild
19
20t = BoostBuild.Tester(pass_toolset=0)
21t.write("file.jam", """\
22rule dummy ( i )
23{
24    local a = 1 2 3 ;
25    ECHO From "rule:" $(a)" seconds" ;
26    a on $(i) = $(a) ;
27}
28
29actions dummy
30{
31    echo 'From action: $(a)" seconds"'
32}
33
34dummy all ;
35""")
36t.run_build_system(["-ffile.jam", "-d1"])
37t.expect_output_lines("From rule: 1 seconds 2 seconds 3 seconds")
38t.expect_output_lines('*From action: 1" 2" 3" seconds"*')
39t.cleanup()
40