[build] Check that a second Ninja invocation does nothing.

Not checking Windows, where the set of linker outputs is not constant.

Change-Id: I1241aa4108f7feebc2638ca762743464fcb48a52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201165
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2021-05-26 17:48:30 +00:00 committed by commit-bot@chromium.org
parent f9b6901baf
commit 26f50368d2
2 changed files with 31 additions and 0 deletions

View file

@ -2830,6 +2830,7 @@
"arguments": [ "arguments": [
"--arch=ia32,x64,arm,arm64", "--arch=ia32,x64,arm,arm64",
"--mode=release", "--mode=release",
"--check-clean",
"create_sdk" "create_sdk"
] ]
}, },
@ -2867,6 +2868,7 @@
"arguments": [ "arguments": [
"--arch=x64", "--arch=x64",
"--mode=release", "--mode=release",
"--check-clean",
"create_sdk" "create_sdk"
], ],
"environment": { "environment": {

View file

@ -53,6 +53,11 @@ def BuildOptions():
help="Don't try to start goma", help="Don't try to start goma",
default=False, default=False,
action='store_true') action='store_true')
other_group.add_argument(
"--check-clean",
help="Check that a second invocation of Ninja has nothing to do",
default=False,
action='store_true')
parser.add_argument('build_targets', nargs='*') parser.add_argument('build_targets', nargs='*')
@ -192,6 +197,25 @@ def RunOneBuildCommand(build_config, args, env):
return 0 return 0
def CheckCleanBuild(build_config, args, env):
args = args + ['-n', '-d', 'explain']
print(' '.join(args))
process = subprocess.Popen(args,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=None)
out, err = process.communicate()
process.wait()
if process.returncode != 0:
return 1
if 'ninja: no work to do' not in out.decode('utf-8'):
print(err.decode('utf-8'))
return 1
return 0
def SanitizerEnvironmentVariables(): def SanitizerEnvironmentVariables():
with io.open('tools/bots/test_matrix.json', encoding='utf-8') as fd: with io.open('tools/bots/test_matrix.json', encoding='utf-8') as fd:
config = json.loads(fd.read()) config = json.loads(fd.read())
@ -270,6 +294,11 @@ def Main():
to_kill.terminate() to_kill.terminate()
return 1 return 1
if options.check_clean:
for (build_config, args, goma) in configs:
if CheckCleanBuild(build_config, args, env=env) != 0:
return 1
endtime = time.time() endtime = time.time()
print("The build took %.3f seconds" % (endtime - starttime)) print("The build took %.3f seconds" % (endtime - starttime))
return 0 return 0