参考所有分组,完成尽量多的内容:收紧项目源列表路径守卫,结论测试通过
This commit is contained in:
@@ -38,6 +38,7 @@ trap 'rm -f "$source_list"' EXIT
|
||||
} > "$source_list"
|
||||
|
||||
./list-filtered-existing-paths.sh \
|
||||
--project-relative \
|
||||
"$filter" \
|
||||
"missing cnc sim core source" \
|
||||
"missing cnc sim core source in CMake list" < "$source_list"
|
||||
|
||||
@@ -6,8 +6,14 @@ cd "$(dirname "$0")"
|
||||
# LinuxCNC source basis: source-list filters validate project bridge/shim
|
||||
# paths before native and wasm probes link them with LinuxCNC source objects,
|
||||
# keeping missing adapter files from silently dropping LinuxCNC-backed checks.
|
||||
project_relative=0
|
||||
if [[ "${1:-}" == "--project-relative" ]]; then
|
||||
project_relative=1
|
||||
shift
|
||||
fi
|
||||
|
||||
if [[ "$#" -lt 3 ]]; then
|
||||
echo "usage: $0 <filter> <missing-path-message> <missing-filter-message> [missing-path-hint]" >&2
|
||||
echo "usage: $0 [--project-relative] <filter> <missing-path-message> <missing-filter-message> [missing-path-hint]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -19,6 +25,11 @@ missing_path_hint=${4:-}
|
||||
found=0
|
||||
while IFS= read -r path; do
|
||||
[[ -z "$path" ]] && continue
|
||||
if [[ "$project_relative" -eq 1 &&
|
||||
( "$path" = /* || "$path" == .. || "$path" == ../* || "$path" == */.. || "$path" == */../* ) ]]; then
|
||||
echo "project source path must stay project-relative: $path" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$path" ]]; then
|
||||
echo "$missing_path_message: $path" >&2
|
||||
if [[ -n "$missing_path_hint" ]]; then
|
||||
|
||||
@@ -16,6 +16,7 @@ trap 'rm -f "$source_list"' EXIT
|
||||
} > "$source_list"
|
||||
|
||||
./list-filtered-existing-paths.sh \
|
||||
--project-relative \
|
||||
"$filter" \
|
||||
"missing LinuxCNC rs274 API project source" \
|
||||
"missing LinuxCNC rs274 API project source in CMake list" < "$source_list"
|
||||
|
||||
@@ -13,6 +13,7 @@ filter=${1:-}
|
||||
./list-cmake-set-sources.sh cnc_sim_core_sources core/
|
||||
./list-cmake-set-sources.sh cnc_sim_linuxcnc_rs274_backend_sources core/
|
||||
} | ./list-filtered-existing-paths.sh \
|
||||
--project-relative \
|
||||
"$filter" \
|
||||
"missing wasm-safe project source" \
|
||||
"missing wasm-safe project source in CMake list"
|
||||
|
||||
@@ -10,6 +10,7 @@ cd "$(dirname "$0")"
|
||||
filter=${1:-}
|
||||
|
||||
./list-cmake-set-sources.sh linuxcnc_wasm_safe_probe_shims | ./list-filtered-existing-paths.sh \
|
||||
--project-relative \
|
||||
"$filter" \
|
||||
"missing wasm-safe shim source" \
|
||||
"missing wasm-safe shim in CMake list"
|
||||
|
||||
@@ -120,6 +120,7 @@ case "$source_set" in
|
||||
esac
|
||||
|
||||
printf '%s\n' "${sources[@]}" | ./list-filtered-existing-paths.sh \
|
||||
--project-relative \
|
||||
"$filter" \
|
||||
"$missing_source_message" \
|
||||
"$missing_filter_message"
|
||||
|
||||
@@ -28,6 +28,7 @@ missing_dump_source_log=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_missing_rs274_dump_pro
|
||||
missing_api_source_log=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_missing_rs274_api_project_source.XXXXXX.log")
|
||||
missing_core_source_log=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_missing_core_source.XXXXXX.log")
|
||||
missing_bridge_source_log=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_missing_bridge_smoke_project_source.XXXXXX.log")
|
||||
escaped_project_source_log=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_escaped_project_source.XXXXXX.log")
|
||||
missing_support_object_log=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_missing_linuxcnc_support_object.XXXXXX.log")
|
||||
missing_source_manifest=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_native_syntax_missing_source_manifest.XXXXXX.txt")
|
||||
missing_source_log=$(mktemp "${TMPDIR:-/tmp}/cnc_sim_native_syntax_missing_source.XXXXXX.log")
|
||||
@@ -57,6 +58,7 @@ cleanup_native_test_temps() {
|
||||
"$missing_api_source_log" \
|
||||
"$missing_core_source_log" \
|
||||
"$missing_bridge_source_log" \
|
||||
"$escaped_project_source_log" \
|
||||
"$missing_support_object_log" \
|
||||
"$missing_source_manifest" \
|
||||
"$missing_source_log" \
|
||||
@@ -171,6 +173,7 @@ for forbidden_manual_cleanup in \
|
||||
'rm -f "$missing_api_source_log"' \
|
||||
'rm -f "$missing_core_source_log"' \
|
||||
'rm -f "$missing_bridge_source_log"' \
|
||||
'rm -f "$escaped_project_source_log"' \
|
||||
'rm -f "$missing_support_object_log"' \
|
||||
'rm -f "$missing_source_manifest" "$missing_source_log"' \
|
||||
'rm -f "$kinematics_unknown_filter_log"' \
|
||||
@@ -212,7 +215,21 @@ grep -F 'exec 9>"${TMPDIR:-/tmp}/cnc_sim_rs274_source_link.lock"' test-linuxcnc-
|
||||
grep -F "flock 9" test-linuxcnc-source-link.sh >/dev/null
|
||||
grep -F "missing LinuxCNC support object" list-linuxcnc-source-support-objects.sh >/dev/null
|
||||
grep -F 'echo "$missing_path_message: $path"' list-filtered-existing-paths.sh >/dev/null
|
||||
grep -F 'project source path must stay project-relative: $path' list-filtered-existing-paths.sh >/dev/null
|
||||
grep -F "build LinuxCNC first or set LINUXCNC_ROOT to a built tree" list-linuxcnc-source-support-objects.sh >/dev/null
|
||||
if printf '../core/src/canon_event_sink.cpp\n' | ./list-filtered-existing-paths.sh \
|
||||
--project-relative \
|
||||
"" \
|
||||
"missing project source" \
|
||||
"missing project source in list" >"$escaped_project_source_log" 2>&1; then
|
||||
echo "project source filter accepted an escaped project source path" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! grep -F "project source path must stay project-relative: ../core/src/canon_event_sink.cpp" "$escaped_project_source_log" >/dev/null; then
|
||||
echo "project source filter did not report escaped project paths clearly" >&2
|
||||
sed -n '1,20p' "$escaped_project_source_log" >&2
|
||||
exit 1
|
||||
fi
|
||||
native_link_flags=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-native-linkflags.sh)
|
||||
grep -Fx -- "-L" <<<"$native_link_flags" >/dev/null
|
||||
grep -Fx -- "$linuxcnc_root/lib" <<<"$native_link_flags" >/dev/null
|
||||
|
||||
Reference in New Issue
Block a user