summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Thomson <martin.thomson@gmail.com>2019-02-26 10:34:38 +1100
committerMartin Thomson <martin.thomson@gmail.com>2019-02-26 10:34:38 +1100
commit28706b6b791f83e54b04f8579f9cfc688bf3c2d0 (patch)
tree9d195dcf6f042c62c40e54b7fa3d26ebe3ef61d8
parent193496bdfce23da9a4e21bf748a837ad1eacf246 (diff)
downloadnss-hg-28706b6b791f83e54b04f8579f9cfc688bf3c2d0.tar.gz
Bug 1530134 - Run clang-format without docker as a fallback, r=jcj
Running clang-format with a bad version is better than not running it at all. Reviewers: jcj Reviewed By: jcj Bug #: 1530134 Differential Revision: https://phabricator.services.mozilla.com/D20938
-rwxr-xr-xmach31
1 files changed, 21 insertions, 10 deletions
diff --git a/mach b/mach
index 842c4fd86..f12b6413a 100755
--- a/mach
+++ b/mach
@@ -39,18 +39,16 @@ def run_tests(test, cycles="standard", env={}, silent=False):
subprocess.check_call(command, env=os_env, stdout=stdout, stderr=stderr)
class cfAction(argparse.Action):
- docker_command = ["docker"]
+ docker_command = None
restorecon = None
def __call__(self, parser, args, values, option_string=None):
- if not args.noroot:
- self.setDockerCommand()
+ self.setDockerCommand(args)
if values:
files = [os.path.relpath(os.path.abspath(x), start=cwd) for x in values]
else:
files = self.modifiedFiles()
- files = [os.path.join('/home/worker/nss', x) for x in files]
# First check if we can run docker.
try:
@@ -58,9 +56,16 @@ class cfAction(argparse.Action):
subprocess.check_call(
self.docker_command + ["images"], stdout=f)
except:
- print("Please install docker and start the docker daemon.")
- sys.exit(1)
+ self.docker_command = None
+
+ if self.docker_command is None:
+ print("warning: running clang-format directly, which isn't guaranteed to be correct")
+ command = [cwd + "/automation/clang-format/run_clang_format.sh"] + files
+ repr(command)
+ subprocess.call(command)
+ return
+ files = [os.path.join('/home/worker/nss', x) for x in files]
docker_image = 'clang-format-service:latest'
cf_docker_folder = cwd + "/automation/clang-format"
@@ -113,11 +118,17 @@ class cfAction(argparse.Action):
subprocess.check_call(command)
return
- def setDockerCommand(self):
+ def setDockerCommand(self, args):
+ from distutils.spawn import find_executable
if platform.system() == "Linux":
- from distutils.spawn import find_executable
- self.restorecon = find_executable('restorecon')
- self.docker_command = ["sudo"] + self.docker_command
+ self.restorecon = find_executable("restorecon")
+ dcmd = find_executable("docker")
+ if dcmd is not None:
+ self.docker_command = [dcmd]
+ if not args.noroot:
+ self.docker_command = ["sudo"] + self.docker_command
+ else:
+ self.docker_command = None
def modifiedFiles(self):
files = []