@@ -155,7 +155,9 @@ fn fetch_spec(spec_name: &str) -> Result<SpecSources> {
155155}
156156
157157fn auxiliary_url ( path : & str ) -> Option < String > {
158- if path. starts_with ( "vk_video/" ) || path == "vk_platform.h" {
158+ if path. starts_with ( "vk_video/" ) {
159+ Some ( format ! ( "{}{}" , BASE_VK_HEADERS , path) )
160+ } else if path == "vk_platform.h" {
159161 Some ( format ! ( "{}vulkan/{}" , BASE_VK_HEADERS , path) )
160162 } else if path. starts_with ( "KHR/" ) || path. starts_with ( "EGL/" ) {
161163 Some ( format ! ( "{}{}" , BASE_EGL , path) )
@@ -174,3 +176,78 @@ fn fetch_text(url: &str) -> Result<String> {
174176 . with_context ( || format ! ( "HTTP error from {}" , url) ) ?;
175177 Ok ( resp. text ( ) ?)
176178}
179+
180+ #[ cfg( all( test, feature = "fetch" ) ) ]
181+ mod tests {
182+ use super :: * ;
183+
184+ /// Collect every remote URL that `--fetch` mode may request, then HEAD each
185+ /// one to verify it still resolves. This catches stale base-paths and
186+ /// renamed upstream files before they break real generation runs.
187+ #[ test]
188+ fn remote_urls_are_reachable ( ) {
189+ // -- spec XMLs (fetch_spec) ------------------------------------------
190+ let spec_urls = vec ! [
191+ format!( "{}gl.xml" , BASE_GL ) ,
192+ format!( "{}glx.xml" , BASE_GL ) ,
193+ format!( "{}wgl.xml" , BASE_GL ) ,
194+ format!( "{}egl.xml" , BASE_EGL ) ,
195+ format!( "{}vk.xml" , BASE_VK ) ,
196+ ] ;
197+
198+ // -- supplemental XMLs -----------------------------------------------
199+ let supplemental_urls = vec ! [
200+ GLSL_EXTS_URL . to_string( ) ,
201+ format!( "{}gl_angle_ext.xml" , BASE_ANGLE ) ,
202+ format!( "{}egl_angle_ext.xml" , BASE_ANGLE ) ,
203+ ] ;
204+
205+ // -- auxiliary headers (auxiliary_url) --------------------------------
206+ // One representative URL per branch in auxiliary_url(), plus every
207+ // bundled vk_video header since those are dictated by the Vulkan spec
208+ // and new ones appear (or move) over time.
209+ let auxiliary_urls: Vec < String > = vec ! [
210+ "vk_platform.h" ,
211+ "KHR/khrplatform.h" ,
212+ "EGL/eglplatform.h" ,
213+ "xxhash.h" ,
214+ "vk_video/vulkan_video_codecs_common.h" ,
215+ "vk_video/vulkan_video_codec_h264std.h" ,
216+ "vk_video/vulkan_video_codec_h264std_decode.h" ,
217+ "vk_video/vulkan_video_codec_h264std_encode.h" ,
218+ "vk_video/vulkan_video_codec_h265std.h" ,
219+ "vk_video/vulkan_video_codec_h265std_decode.h" ,
220+ "vk_video/vulkan_video_codec_h265std_encode.h" ,
221+ "vk_video/vulkan_video_codec_av1std.h" ,
222+ "vk_video/vulkan_video_codec_av1std_decode.h" ,
223+ "vk_video/vulkan_video_codec_av1std_encode.h" ,
224+ "vk_video/vulkan_video_codec_vp9std.h" ,
225+ "vk_video/vulkan_video_codec_vp9std_decode.h" ,
226+ ]
227+ . into_iter ( )
228+ . map ( |p| auxiliary_url ( p) . unwrap_or_else ( || panic ! ( "no URL mapping for '{}'" , p) ) )
229+ . collect ( ) ;
230+
231+ let all_urls = spec_urls
232+ . into_iter ( )
233+ . chain ( supplemental_urls)
234+ . chain ( auxiliary_urls) ;
235+
236+ let client = reqwest:: blocking:: Client :: new ( ) ;
237+ let mut failures = Vec :: new ( ) ;
238+
239+ for url in all_urls {
240+ let result = client. head ( & url) . send ( ) . and_then ( |r| r. error_for_status ( ) ) ;
241+
242+ if let Err ( e) = result {
243+ failures. push ( format ! ( " {} — {}" , url, e) ) ;
244+ }
245+ }
246+
247+ assert ! (
248+ failures. is_empty( ) ,
249+ "the following remote URLs are unreachable:\n {}" ,
250+ failures. join( "\n " )
251+ ) ;
252+ }
253+ }
0 commit comments