[roll] Roll fuchsia [check-licenses] Refactor project package and add tests

This change resolves critical data races, memory leaks, and silent
parsing failures within the `project` package. It also completely
overhauls the testing strategy for the package to use isolated unit
tests rather than integration-level golden files.

* Data Race Fixes: Added a `sync.Mutex` to the `Project` struct to
  protect `RegularFiles` and `LicenseFiles` from concurrent mutations
  by the directory crawler. Added a thread-safe `GetFiles()` method
  and updated `filter.go` to use it.

* Global State Safety: Encapsulated the global maps `AllProjects`,
  `FilteredProjects`, and `DedupedLicenseData` behind `sync.RWMutex`
  locks with thread-safe getters and setters in `config.go`.

* Memory Optimization: Removed the massive string allocations in
  `filter.go`'s deduplication logic. It now uses the cached,
  pre-computed `Hash()` strings as map keys instead of allocating new
  strings for the entire license text.

* SPDX Bug Fixes: Fixed two bugs in `spdx.go`. It now correctly
  defaults to "NOASSERTION" if a project has no licenses, and it no
  longer generates mathematically invalid `()` string expressions if a
  file contains zero data segments.

* Parsing Bug Fix: Updated `NewProject` to use the exported
  `string(file.SingleLicense)` constant, resolving a bug where
  explicitly defined license files failed to parse.

* Code Cleanup: Purged dead `getGitInfo` code and the unused `git`
  and `ctx` variables. Moved `init.go` contents into `config.go`.

* Testing: Purged the `testdata/` directory and rewrote
  `project_test.go` and `spdx_test.go` to dynamically scaffold tests
  using `t.TempDir()`.

Original-Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1566402
Original-Revision: 7417934a66ba0271c93896dfc5053775e455a0d7
GitOrigin-RevId: bae527f38323be1db122df06776ed05d4953b333
Change-Id: Icda6eb69af19541de0105ad922ef4f9d4fb3759c
1 file changed
tree: a2bf9561b5bd47be694813bdd31a37d60a359f6c
  1. ctf/
  2. git-hooks/
  3. infra/
  4. third_party/
  5. cobalt
  6. flower
  7. jiri.lock
  8. MILESTONE
  9. minimal
  10. prebuilts
  11. README.md
  12. stem
  13. test_durations
README.md

Integration

This repository contains Fuchsia's Global Integration manifest files.

Making changes

All changes should be made to the internal version of this repository. Our infrastructure automatically updates this version when the internal one changes.

Currently all changes must be made by a Google employee. Non-Google employees wishing to make a change can ask for assistance in one of the communication channels documented at get involved.

Obtaining the source

First install Jiri.

Next run:

$ jiri init
$ jiri import minimal https://fuchsia.googlesource.com/integration
$ jiri update

Third party

Third party projects should have their own subdirectory in ./third_party.