Skip to content

Commit

Permalink
src: fix multi-output-actions bug in make
Browse files Browse the repository at this point in the history
  • Loading branch information
refack committed Mar 11, 2019
1 parent 949e8bb commit 56756ea
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 145 deletions.
235 changes: 119 additions & 116 deletions pylib/gyp/MakefileWriter.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# found in the LICENSE file.

"""
Verifies actions with multiple outputs & dependncies will correctly rebuild.
Verifies actions with multiple outputs & dependencies will correctly rebuild.
This is a regression test for crrev.com/1177163002.
"""
Expand All @@ -17,10 +17,6 @@
import sys
import time

if sys.platform in ('darwin', 'win32'):
print("This test is currently disabled: https://crbug.com/483696.")
sys.exit(0)

test = TestGyp.TestGyp()

TESTDIR='relocate/src'
Expand All @@ -30,6 +26,7 @@
def build_and_check(content):
test.write(TESTDIR + '/input.txt', content)
test.build('action.gyp', 'upper', chdir=TESTDIR)
test.up_to_date('action.gyp', 'upper', chdir=TESTDIR)
test.built_file_must_match('result.txt', content, chdir=TESTDIR)

build_and_check('Content for first build.')
Expand Down
20 changes: 14 additions & 6 deletions test/actions-multiple-outputs-with-dependencies/src/action.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@
{
'target_name': 'lower',
'type': 'none',
'actions': [{
'action_name': 'lower_action',
'inputs': ['input.txt'],
'outputs': ['<(PRODUCT_DIR)/out1.txt', '<(PRODUCT_DIR)/out2.txt'],
'action': ['python', 'rcopy.py', '<@(_inputs)', '<@(_outputs)'],
}],
'actions': [
{
'action_name': 'lower_action',
'external': 'true',
'inputs': ['input.txt'],
'outputs': ['<(PRODUCT_DIR)/out1.txt', '<(PRODUCT_DIR)/out2.txt'],
'action': ['python', 'rcopy.py', '<@(_inputs)', '<@(_outputs)'],
},
{
'action_name': 'lower_action2',
'inputs': ['input.txt'],
'outputs': ['<(PRODUCT_DIR)/out2.1.txt'],
'action': ['python', 'rcopy.py', '<@(_inputs)', '<@(_outputs)'],
}],
},
],
}
18 changes: 3 additions & 15 deletions test/actions-multiple-outputs/gyptest-multiple-outputs.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
#!/usr/bin/env python

# Copyright (c) 2015 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
Verifies actions with multiple outputs will correctly rebuild.
"""

from __future__ import print_function

import TestGyp
import os
import sys

if sys.platform == 'win32':
print("This test is currently disabled: https://crbug.com/483696.")
sys.exit(0)

test = TestGyp.TestGyp()

Expand All @@ -28,6 +15,7 @@
def build_and_check():
# Build + check that both outputs exist.
test.build('multiple-outputs.gyp', chdir=chdir)
test.up_to_date('action.gyp', chdir=chdir)
test.built_file_must_exist('out1.txt', chdir=chdir)
test.built_file_must_exist('out2.txt', chdir=chdir)

Expand All @@ -36,10 +24,10 @@ def build_and_check():

# Remove either + rebuild. Both should exist (again).
os.remove(test.built_file_path('out1.txt', chdir=chdir))
build_and_check();
build_and_check()

# Remove the other + rebuild. Both should exist (again).
os.remove(test.built_file_path('out2.txt', chdir=chdir))
build_and_check();
build_and_check()

test.pass_test()
1 change: 1 addition & 0 deletions test/actions-multiple-outputs/src/multiple-outputs.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'actions': [
{
'action_name': 'action1',
'external': 'true',
'inputs': [],
'outputs': [
'<(PRODUCT_DIR)/out1.txt',
Expand Down
14 changes: 11 additions & 3 deletions test/lib/TestGyp.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,22 @@ def match_modulo_line_numbers(contents_a, contents_b):
return TestCommon.match_exact(contents_a, contents_b)


def mk_temp_dir(workdir):
def mk_temp_dir(workdir, hint=''):
# Put test output in out/testworkarea by default.
# Use temporary names so there are no collisions.
workdir = workdir or 'testworkarea'
workdir = os.path.join('out', workdir)
# Create work area if it doesn't already exist.
if not os.path.isdir(workdir):
os.makedirs(workdir)
return tempfile.mktemp(prefix='testgyp.', dir=workdir)
if hint:
slug = re.sub(r'[/.\\]', '_', hint)
dir_name = os.path.join(workdir, slug)
if os.path.exists(dir_name):
shutil.rmtree(dir_name)
return dir_name
else:
return tempfile.mktemp(prefix='testgyp.', dir=workdir)


@contextmanager
Expand Down Expand Up @@ -131,7 +138,8 @@ def __init__(self, gyp=None, **kw):
if 'description' not in kw:
bt = [t[0] for t in traceback.extract_stack() if 'gyptest' in t[0]]
kw['description'] = bt and bt.pop()
kw['workdir'] = mk_temp_dir(kw.get('workdir'))
kw_workdir = kw.get('workdir')
kw['workdir'] = mk_temp_dir(kw_workdir, kw['description'])
kw_formats = kw.pop('formats', [])

if not gyp:
Expand Down

0 comments on commit 56756ea

Please # to comment.