Remove commands duplication between `compiletest` and `tests/rustdoc` · rust-lang/rust@51fedf6
@@ -240,237 +240,40 @@ def concat_multi_lines(f):
240240print_err(lineno, line, 'Trailing backslash at the end of the file')
241241242242243+def get_known_directive_names():
244+def filter_line(line):
245+line = line.strip()
246+return line.startswith('"') and (line.endswith('",') or line.endswith('"'))
247+248+# Equivalent to `src/tools/compiletest/src/header.rs` constant of the same name.
249+with open(
250+os.path.join(
251+# We go back to `src`.
252+os.path.dirname(os.path.dirname(__file__)),
253+"tools/compiletest/src/command-list.rs",
254+ ),
255+"r",
256+encoding="utf8"
257+ ) as fd:
258+content = fd.read()
259+return [
260+line.strip().replace('",', '').replace('"', '')
261+for line in content.split('\n')
262+if filter_line(line)
263+ ]
264+265+266+# To prevent duplicating the list of commmands between `compiletest` and `htmldocck`, we put
267+# it into a common file which is included in rust code and parsed here.
268+# FIXME: This setup is temporary until we figure out how to improve this situation.
269+KNOWN_DIRECTIVE_NAMES = get_known_directive_names()
270+243271LINE_PATTERN = re.compile(r'''
244272 //@\s+
245273 (?P<negated>!?)(?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*)
246274 (?P<args>.*)$
247275''', re.X | re.UNICODE)
248276249-# Equivalent to `src/tools/compiletest/src/header.rs` constant of the same name.
250-KNOWN_DIRECTIVE_NAMES = [
251-# tidy-alphabetical-start
252-"assembly-output",
253-"aux-bin",
254-"aux-build",
255-"aux-codegen-backend",
256-"aux-crate",
257-"build-aux-docs",
258-"build-fail",
259-"build-pass",
260-"check-fail",
261-"check-pass",
262-"check-run-results",
263-"check-stdout",
264-"check-test-line-numbers-match",
265-"compare-output-lines-by-subset",
266-"compile-flags",
267-"dont-check-compiler-stderr",
268-"dont-check-compiler-stdout",
269-"dont-check-failure-status",
270-"edition",
271-"error-pattern",
272-"exec-env",
273-"failure-status",
274-"filecheck-flags",
275-"forbid-output",
276-"force-host",
277-"ignore-16bit",
278-"ignore-32bit",
279-"ignore-64bit",
280-"ignore-aarch64",
281-"ignore-aarch64-unknown-linux-gnu",
282-"ignore-android",
283-"ignore-apple",
284-"ignore-arm",
285-"ignore-avr",
286-"ignore-beta",
287-"ignore-cdb",
288-"ignore-compare-mode-next-solver",
289-"ignore-compare-mode-polonius",
290-"ignore-cross-compile",
291-"ignore-debug",
292-"ignore-eabi",
293-"ignore-emscripten",
294-"ignore-endian-big",
295-"ignore-freebsd",
296-"ignore-fuchsia",
297-"ignore-gdb",
298-"ignore-gdb-version",
299-"ignore-gnu",
300-"ignore-haiku",
301-"ignore-horizon",
302-"ignore-i686-pc-windows-msvc",
303-"ignore-ios",
304-"ignore-linux",
305-"ignore-lldb",
306-"ignore-llvm-version",
307-"ignore-loongarch64",
308-"ignore-macabi",
309-"ignore-macos",
310-"ignore-mode-assembly",
311-"ignore-mode-codegen",
312-"ignore-mode-codegen-units",
313-"ignore-mode-coverage-map",
314-"ignore-mode-coverage-run",
315-"ignore-mode-crashes",
316-"ignore-mode-debuginfo",
317-"ignore-mode-incremental",
318-"ignore-mode-js-doc-test",
319-"ignore-mode-mir-opt",
320-"ignore-mode-pretty",
321-"ignore-mode-run-make",
322-"ignore-mode-run-pass-valgrind",
323-"ignore-mode-rustdoc",
324-"ignore-mode-rustdoc-json",
325-"ignore-mode-ui",
326-"ignore-mode-ui-fulldeps",
327-"ignore-msp430",
328-"ignore-msvc",
329-"ignore-musl",
330-"ignore-netbsd",
331-"ignore-nightly",
332-"ignore-none",
333-"ignore-nto",
334-"ignore-nvptx64",
335-"ignore-nvptx64-nvidia-cuda",
336-"ignore-openbsd",
337-"ignore-pass",
338-"ignore-remote",
339-"ignore-riscv64",
340-"ignore-s390x",
341-"ignore-sgx",
342-"ignore-spirv",
343-"ignore-stable",
344-"ignore-stage1",
345-"ignore-stage2",
346-"ignore-test",
347-"ignore-thumb",
348-"ignore-thumbv8m.base-none-eabi",
349-"ignore-thumbv8m.main-none-eabi",
350-"ignore-tvos",
351-"ignore-unix",
352-"ignore-unknown",
353-"ignore-uwp",
354-"ignore-visionos",
355-"ignore-vxworks",
356-"ignore-wasi",
357-"ignore-wasm",
358-"ignore-wasm32",
359-"ignore-wasm32-bare",
360-"ignore-wasm64",
361-"ignore-watchos",
362-"ignore-windows",
363-"ignore-windows-gnu",
364-"ignore-x32",
365-"ignore-x86",
366-"ignore-x86_64",
367-"ignore-x86_64-unknown-linux-gnu",
368-"incremental",
369-"known-bug",
370-"llvm-cov-flags",
371-"min-cdb-version",
372-"min-gdb-version",
373-"min-lldb-version",
374-"min-llvm-version",
375-"min-system-llvm-version",
376-"needs-asm-support",
377-"needs-dlltool",
378-"needs-dynamic-linking",
379-"needs-force-clang-based-tests",
380-"needs-git-hash",
381-"needs-llvm-components",
382-"needs-profiler-support",
383-"needs-relocation-model-pic",
384-"needs-run-enabled",
385-"needs-rust-lld",
386-"needs-rust-lldb",
387-"needs-sanitizer-address",
388-"needs-sanitizer-cfi",
389-"needs-sanitizer-dataflow",
390-"needs-sanitizer-hwaddress",
391-"needs-sanitizer-kcfi",
392-"needs-sanitizer-leak",
393-"needs-sanitizer-memory",
394-"needs-sanitizer-memtag",
395-"needs-sanitizer-safestack",
396-"needs-sanitizer-shadow-call-stack",
397-"needs-sanitizer-support",
398-"needs-sanitizer-thread",
399-"needs-threads",
400-"needs-unwind",
401-"needs-wasmtime",
402-"needs-xray",
403-"no-auto-check-cfg",
404-"no-prefer-dynamic",
405-"normalize-stderr-32bit",
406-"normalize-stderr-64bit",
407-"normalize-stderr-test",
408-"normalize-stdout-test",
409-"only-16bit",
410-"only-32bit",
411-"only-64bit",
412-"only-aarch64",
413-"only-apple",
414-"only-arm",
415-"only-avr",
416-"only-beta",
417-"only-bpf",
418-"only-cdb",
419-"only-gnu",
420-"only-i686-pc-windows-msvc",
421-"only-ios",
422-"only-linux",
423-"only-loongarch64",
424-"only-loongarch64-unknown-linux-gnu",
425-"only-macos",
426-"only-mips",
427-"only-mips64",
428-"only-msp430",
429-"only-msvc",
430-"only-nightly",
431-"only-nvptx64",
432-"only-riscv64",
433-"only-sparc",
434-"only-sparc64",
435-"only-stable",
436-"only-thumb",
437-"only-tvos",
438-"only-unix",
439-"only-visionos",
440-"only-wasm32",
441-"only-wasm32-bare",
442-"only-wasm32-wasip1",
443-"only-watchos",
444-"only-windows",
445-"only-x86",
446-"only-x86_64",
447-"only-x86_64-fortanix-unknown-sgx",
448-"only-x86_64-pc-windows-gnu",
449-"only-x86_64-pc-windows-msvc",
450-"only-x86_64-unknown-linux-gnu",
451-"pp-exact",
452-"pretty-compare-only",
453-"pretty-expanded",
454-"pretty-mode",
455-"regex-error-pattern",
456-"remap-src-base",
457-"revisions",
458-"run-fail",
459-"run-flags",
460-"run-pass",
461-"run-rustfix",
462-"rustc-env",
463-"rustfix-only-machine-applicable",
464-"should-fail",
465-"should-ice",
466-"stderr-per-bitwidth",
467-"test-mir-pass",
468-"unset-exec-env",
469-"unset-rustc-env",
470-# Used by the tidy check `unknown_revision`.
471-"unused-revision-names",
472-# tidy-alphabetical-end
473-]
474277475278def get_commands(template):
476279with io.open(template, encoding='utf-8') as f: