1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
# Copyright 2021, 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#+PROPERTY: header-args :mkdirp yes :main no
* Test data for ~bazel-mode-flymake~
#+BEGIN_SRC bazel-workspace :tangle WORKSPACE
workspace(name = "test")
#+END_SRC
#+NAME: starlark
#+BEGIN_SRC bazel-starlark :tangle buildifier.bzl
def foo(bar):
""" """
a = 1 / 2
#+END_SRC
To make the Flymake test hermetic, we generate Buildifier output statically and
tangle the output when running the test. Execute this code block to regenerate
the Buildifier output:
#+BEGIN_SRC sh :noweb yes :results output scalar :wrap "src js :tangle buildifier.json"
buildifier -mode=check -lint=warn -format=json -v -path=buildifier.bzl <<'EOF'
<<starlark>>
EOF
#+END_SRC
#+RESULTS:
#+BEGIN_SRC js :tangle buildifier.json
{
"success": false,
"files": [
{
"filename": "buildifier.bzl",
"formatted": true,
"valid": true,
"warnings": [
{
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
},
"category": "module-docstring",
"actionable": true,
"message": "The file has no module docstring.\nA module docstring is a string literal (not a comment) which should be the first statement of a file (it may follow comment lines).",
"url": "https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#module-docstring"
},
{
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 12
},
"category": "function-docstring-header",
"actionable": true,
"message": "The docstring for the function \"foo\" should start with a one-line summary.",
"url": "https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#function-docstring-header"
},
{
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 14
},
"category": "integer-division",
"actionable": true,
"message": "The \"/\" operator for integer division is deprecated in favor of \"//\".",
"url": "https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#integer-division"
}
]
}
]
}
#+END_SRC
We also provide a “fake” Buildifier binary that only emits our canned output.
It waits for the file =signal= to exist; you can use this to simulate a “slow”
Buildifier.
#+BEGIN_SRC sh :tangle buildifier :shebang "#!/bin/bash" :var dir=(file-name-unquote (expand-file-name default-directory))
# Fake waiting for file input.
cat > /dev/null
# Wait for signal file to exist.
while [[ ! -e "${dir:?}/signal" ]]; do
sleep 1
done
# Fake some Buildifier output.
cat -- "${dir:?}/buildifier.json"
#+END_SRC
|