vcpkg/scripts/test_ports/vcpkg-from-git-test
Billy O'Neal d816079874
[vcpkg_from_git] Improve diagnostics. (#36539)
While authoring vcpkg_from_git to authenticated servers documentation,
@JavierMatosD and I discovered some failure modes that are not clear in
the output.

Example with REF set to a branch name:

```console
The port under test is:
vcpkg_from_git(
    OUT_SOURCE_PATH out
    URL https://github.com/microsoft/vcpkg
    REF 2024.01.12
)
========== BEFORE ===============
Computing installation plan...
The following packages will be built and installed:
    test-port:x64-windows@1 -- D:\test\test-port
Detecting compiler hash for triplet x64-windows...
Installing 1/1 test-port:x64-windows@1...
Building test-port:x64-windows@1...
-- Installing port from location: D:\test\test-port
-- Fetching https://github.com/microsoft/vcpkg 2024.01.12...
CMake Error at scripts/cmake/vcpkg_from_git.cmake:141 (message):
  unable to rev-parse 2024.01.12 after fetching git repository
Call Stack (most recent call first):
  D:/test/test-port/portfile.cmake:1 (vcpkg_from_git)
  scripts/ports.cmake:170 (include)

error: building test-port:x64-windows failed with: BUILD_FAILED
Elapsed time to handle test-port:x64-windows: 1.8 s
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
  https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+test-port
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?title=[test-port]+Build+error+on+x64-windows&body=Copy+issue+body+from+D%3A%2Fvcpkg2%2Finstalled%2Fvcpkg%2Fissue_body.md

========== AFTER ================
Computing installation plan...
The following packages will be built and installed:
    test-port:x64-windows@1 -- D:\test\test-port
Detecting compiler hash for triplet x64-windows...
Installing 1/1 test-port:x64-windows@1...
Building test-port:x64-windows@1...
-- Installing port from location: D:\test\test-port
-- Fetching https://github.com/microsoft/vcpkg 2024.01.12...
CMake Error at scripts/cmake/vcpkg_from_git.cmake:142 (message):
  After fetching 2024.01.12, the target ref 2024.01.12 appears inaccessible.
  A common cause of this failure is setting REF to a named branch or tag
  rather than a commit SHA.  REF must be a commit SHA.  If the git server
  does not advertise commit SHAs (uploadpack.allowReachableSHA1InWant is
  false), you can set FETCH_REF to a named branch in which the desired commit
  SHA is in the history.  For example, you may be able to fix this error by
  changing "REF 2024.01.12" to "REF a-commit-sha FETCH_REF 2024.01.12".  (git
  rev-parse 2024.01.12 failed)
Call Stack (most recent call first):
  D:/test/test-port/portfile.cmake:1 (vcpkg_from_git)
  scripts/ports.cmake:170 (include)

error: building test-port:x64-windows failed with: BUILD_FAILED
Elapsed time to handle test-port:x64-windows: 1.9 s
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
  https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+test-port
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?title=[test-port]+Build+error+on+x64-windows&body=Copy+issue+body+from+D%3A%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md
```

Example with REF ste to a branch name with FETCH_REF set:

```console
PS D:\test> run-test
The following packages are not installed:
    test-port:x64-windows
The following packages are not installed:
    test-port:x64-windows
The port under test is:
vcpkg_from_git(
    OUT_SOURCE_PATH out
    URL https://github.com/microsoft/vcpkg
    REF 2024.01.12
    FETCH_REF master
)
========== BEFORE ===============
Computing installation plan...
The following packages will be built and installed:
    test-port:x64-windows@1 -- D:\test\test-port
Detecting compiler hash for triplet x64-windows...
Installing 1/1 test-port:x64-windows@1...
Building test-port:x64-windows@1...
-- Installing port from location: D:\test\test-port
-- Fetching https://github.com/microsoft/vcpkg master...
CMake Error at scripts/cmake/vcpkg_from_git.cmake:141 (message):
  unable to rev-parse 2024.01.12 after fetching git repository
Call Stack (most recent call first):
  D:/test/test-port/portfile.cmake:1 (vcpkg_from_git)
  scripts/ports.cmake:170 (include)

error: building test-port:x64-windows failed with: BUILD_FAILED
Elapsed time to handle test-port:x64-windows: 1.6 s
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
  https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+test-port
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?title=[test-port]+Build+error+on+x64-windows&body=Copy+issue+body+from+D%3A%2Fvcpkg2%2Finstalled%2Fvcpkg%2Fissue_body.md

========== AFTER ================
Computing installation plan...
The following packages will be built and installed:
    test-port:x64-windows@1 -- D:\test\test-port
Detecting compiler hash for triplet x64-windows...
Installing 1/1 test-port:x64-windows@1...
Building test-port:x64-windows@1...
-- Installing port from location: D:\test\test-port
-- Fetching https://github.com/microsoft/vcpkg master...
CMake Error at scripts/cmake/vcpkg_from_git.cmake:138 (message):
  After fetching master, the target ref 2024.01.12 appears inaccessible.  A
  common cause of this failure is setting REF to a named branch or tag rather
  than a commit SHA.  REF must be a commit SHA.  (git rev-parse 2024.01.12
  failed)
Call Stack (most recent call first):
  D:/test/test-port/portfile.cmake:1 (vcpkg_from_git)
  scripts/ports.cmake:170 (include)

error: building test-port:x64-windows failed with: BUILD_FAILED
Elapsed time to handle test-port:x64-windows: 1.5 s
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
  https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+test-port
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?title=[test-port]+Build+error+on+x64-windows&body=Copy+issue+body+from+D%3A%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md
```

---------

Co-authored-by: Thomas1664 <46387399+Thomas1664@users.noreply.github.com>
2024-03-06 11:28:35 -08:00
..
portfile.cmake [vcpkg_from_git] Improve diagnostics. (#36539) 2024-03-06 11:28:35 -08:00
vcpkg.json [scripts-audit] minor vcpkg_from_* fixes (#19657) 2022-03-18 09:59:45 -07:00