[ScanDependencies] Fix JSON generation under certain circunstances. #67246
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The code of
ScanDependencies.cppwas creating invalid JSON since #66031 because in the case of havingextraPcmArgsandswiftOverlayDependencies, but notbridgingHeader, a comma will not be added at the end ofextraPcmArgs, creating an invalid JSON file. Additionally that same PR added a trailing comma at the end of theswiftOverlayDependencies, which valid JSON does not allow, but that bug was removed in #66366.Both problems are, however, present in the 5.9 branch, because #66936 included #66031, but not #66366.
Besides fixing the problem in
ScanDependencies.cppI modified every test that uses--scan-dependenciesto pass the produced JSON through Python'sjson.toolin order to validate proper JSON is produced. In most cases I was able to pipe the output of the tool intoFileCheck, but in some cases the validation is done by itself because the checks depend on the exact format generated by--scan-dependencies. In a couple of tests I added a call toFileCheckthat seemed to be missing.Without these changes, two tests seems to be generating invalid JSON in my machine:
ScanDependencies/local_cache_consistency.swift(which outputsExpecting ',' delimiter: line 525 column 11 (char 22799))ScanDependencies/placholder_overlay_deps.swift