[scan-build-py] Increase precision of timestamp in report directory name
authorDevin Coughlin <dcoughlin@apple.com>
Tue, 6 Sep 2016 23:42:51 +0000 (23:42 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Tue, 6 Sep 2016 23:42:51 +0000 (23:42 +0000)
commit80e74cdc6886b83a24587d86cccde0f057ceda38
tree755e2f3b5a62f9583ddd9c6c185626db340f8a7b
parent8ca2ed22b24f052173a882e1a061fdbb7f476647
[scan-build-py] Increase precision of timestamp in report directory name

This commit improves compatibility with the perl version of scan-build.

The perl version of scan-build produces output report directories with
increasing lexicographic ordering. This ordering is relied on by the CmpRuns.py
tool in utils/analyzer when comparing results for build commands with multiple
steps. That tool tries to line up the output directory for each step between
different runs of the analyzer based on the increasing directory name.

The python version of scan-build uses file.mkdtemp() with a time stamp
prefix to create report directories. The timestamp has a 1-second precision.
This means that when analysis of a single build step takes less than a second
the ordering property that CmpRuns.py expects will sometimes not hold,
depending on the timing and the random suffix generated by mkdtemp(). Ultimately
this causes CmpRuns to incorrectly correlate results from build steps and report
spurious differences between runs.

This commit increases the precision of the timestamp used in scan-build-py to
the microsecond level. This approach still has the same underlying issue -- but
in practice analysis of any build step is unlikely to take less than a
millisecond.

Differential Revision: https://reviews.llvm.org/D24163

llvm-svn: 280768
clang/tools/scan-build-py/libscanbuild/report.py
clang/tools/scan-build-py/tests/unit/test_report.py