1#!/usr/local/bin/python3.8
2
3# Copyright 2014 Steven Watanabe
4# Distributed under the Boost Software License, Version 1.0.
5# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
6
7import BoostBuild
8import sys
9
10t = BoostBuild.Tester(pass_toolset=False)
11
12t.write("file.jam", """
13actions run {
14    $(ACTION)
15}
16
17# Raw commands only work on Windows
18if $(OS) = NT
19{
20    JAMSHELL on test-raw = % ;
21    JAMSHELL on test-raw-fail = % ;
22}
23ACTION on test-raw = "\"$(PYTHON)\" -V" ;
24run test-raw ;
25
26ACTION on test-raw-fail = missing-executable ;
27run test-raw-fail ;
28
29# On Windows, the command is stored in a temporary
30# file.  On other systems it is passed directly.
31if $(OS) = NT
32{
33    JAMSHELL on test-py = $(PYTHON) ;
34}
35else
36{
37    JAMSHELL on test-py = $(PYTHON) -c ;
38}
39ACTION on test-py = "
40from __future__ import print_function
41print(\\\",\\\".join([str(x) for x in range(3)]))
42" ;
43run test-py ;
44
45DEPENDS all : test-raw test-raw-fail test-py ;
46""")
47
48t.run_build_system(["-ffile.jam", "-d1", "-sPYTHON=" + sys.executable], status=1)
49t.expect_output_lines([
50    "...failed run test-raw-fail...",
51    "0,1,2",
52    "...failed updating 1 target...",
53    "...updated 2 targets..."])
54
55t.cleanup()
56