Skip to content

Commit

Permalink
[test] Do not overwrite test file in clang_compilation_db_* tests
Browse files Browse the repository at this point in the history
Summary:
This diff avoids overwriting test files in the clang_compilation_db_escaped/realpath tests. Both Makefiles of the tests are running below:

```
$(COPY) "../codetoanalyze/path_with_spaces/hel_lo.c" "../codetoanalyze/path with spaces/hel lo.c" \
|| diff "../codetoanalyze/path_with_spaces/hel_lo.c" "../codetoanalyze/path with spaces/hel lo.c"
```

If they run in a bad timing, at the same time:

* one is trying to copy the target file (write)
* one is trying to diff the target file (read)

it can introduce the `diff` running failure. This diff tries to avoid the overwriting at the copy to avoid the timing issue.

Reviewed By: geralt-encore

Differential Revision: D49597444

fbshipit-source-id: d6ef35b9246230dbaa0b32b8a30ee504bf1c4c4e
  • Loading branch information
skcho authored and facebook-github-bot committed Sep 25, 2023
1 parent 59eaaaf commit 92aa0ec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ XCODE_ISYSROOT := $(XCODE_BASE)/$(XCODE_ISYSROOT_SUFFIX)
endif

define copy_or_same_file
$(COPY) "$(1)" "$(2)" || diff -q "$(1)" "$(2)"
$(COPY) -n "$(1)" "$(2)" || diff "$(1)" "$(2)"
endef

INTERACTIVE := $(shell [ -t 0 ] && ! [ x"$$TERM" = xdumb ] && echo 1)
Expand Down

0 comments on commit 92aa0ec

Please sign in to comment.