diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-03-29 18:45:57 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-03-30 14:00:44 +0200 |
commit | 78340c3d2336c2d5ea5365120a8fbd2319764f58 (patch) | |
tree | e3086d7802c3a58e65628e0b9b5154a1fefe494d /test/end-to-end/user-errors | |
parent | 1d8321976c7634f80b7f878b4219899fe0748d70 (diff) | |
download | justbuild-78340c3d2336c2d5ea5365120a8fbd2319764f58.tar.gz |
Improve error messages on reading invalid target files
... by including the details of the parse error.
Diffstat (limited to 'test/end-to-end/user-errors')
-rw-r--r-- | test/end-to-end/user-errors/TARGETS | 12 | ||||
-rwxr-xr-x | test/end-to-end/user-errors/json-errors.sh | 42 |
2 files changed, 53 insertions, 1 deletions
diff --git a/test/end-to-end/user-errors/TARGETS b/test/end-to-end/user-errors/TARGETS index cb1b881e..f12f6151 100644 --- a/test/end-to-end/user-errors/TARGETS +++ b/test/end-to-end/user-errors/TARGETS @@ -4,5 +4,15 @@ , "test": ["flat-stage.sh"] , "deps": [["test/end-to-end", "tool-under-test"]] } -, "TESTS": {"type": "install", "tainted": ["test"], "deps": ["flat-stage"]} +, "json-errors": + { "type": ["@", "rules", "shell/test", "script"] + , "name": ["json-errors"] + , "test": ["json-errors.sh"] + , "deps": [["test/end-to-end", "tool-under-test"]] + } +, "TESTS": + { "type": "install" + , "tainted": ["test"] + , "deps": ["flat-stage", "json-errors"] + } } diff --git a/test/end-to-end/user-errors/json-errors.sh b/test/end-to-end/user-errors/json-errors.sh new file mode 100755 index 00000000..ec57c962 --- /dev/null +++ b/test/end-to-end/user-errors/json-errors.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Copyright 2023 Huawei Cloud Computing Technology Co., Ltd. +# +# 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 +# +# http://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. + +set -e + +readonly ROOT="${PWD}" +readonly JUST="${ROOT}/bin/tool-under-test" +readonly LBR="${TEST_TMPDIR}/local-build-root" + +touch ROOT +cat > TARGETS <<'EOF' +{ "THIS": would be the default target if it where syntactically correct ... +EOF + +"${JUST}" build --local-build-root "${LBR}" 2>msg && exit 1 || : +cat msg +grep -q 'default target' msg +grep -q 'TARGETS' msg +grep -q 'line' msg # expect to see a position of the parsing error +grep -q '"THIS"' msg # expect to see the last valid token + + +"${JUST}" build --local-build-root "${LBR}" some-target 2>msg && exit 1 || : +cat msg +# expect the error to happen while trying to analyse the default target +grep -q '["@","","","some-target"]' msg +grep -q 'line' msg # expect to see a position of the parsing error +grep -q '"THIS"' msg # expect to see the last valid token + +echo OK |