From 26f50368d2878fe28f0fedb78ad3d00f9ffc2d33 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Wed, 26 May 2021 17:48:30 +0000 Subject: [PATCH] [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 Reviewed-by: Tess Strickland Commit-Queue: Ryan Macnak --- tools/bots/test_matrix.json | 2 ++ tools/build.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json index 83064f4ef9a..67fb0a05950 100644 --- a/tools/bots/test_matrix.json +++ b/tools/bots/test_matrix.json @@ -2830,6 +2830,7 @@ "arguments": [ "--arch=ia32,x64,arm,arm64", "--mode=release", + "--check-clean", "create_sdk" ] }, @@ -2867,6 +2868,7 @@ "arguments": [ "--arch=x64", "--mode=release", + "--check-clean", "create_sdk" ], "environment": { diff --git a/tools/build.py b/tools/build.py index fb17356aba4..aa0f6253ffc 100755 --- a/tools/build.py +++ b/tools/build.py @@ -53,6 +53,11 @@ def BuildOptions(): help="Don't try to start goma", default=False, 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='*') @@ -192,6 +197,25 @@ def RunOneBuildCommand(build_config, args, env): 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(): with io.open('tools/bots/test_matrix.json', encoding='utf-8') as fd: config = json.loads(fd.read()) @@ -270,6 +294,11 @@ def Main(): to_kill.terminate() 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() print("The build took %.3f seconds" % (endtime - starttime)) return 0