명령줄의 `gh`로 GitHub 이슈 본문과 댓글을 읽기 전용으로 확인하는 방법을 안내합니다. 번호나 URL로 이슈를 찾고 다른 저장소를 지정하는 방법, 댓글이 많은 경우 JSON과 `jq`로 내용을 추출하는 방법을 다룹니다.
- 이슈 본문과 댓글 읽기
- URL로 이슈 내용 확인
- 다른 저장소의 이슈 조회
`file_test` 기반으로 Carbon 도구 체인 테스트를 작성하고 구성하며 실행하는 방법을 안내합니다. 테스트 헤더, 사례 분할, 실패 접두사, 필요한 SemIR 출력만 남기는 방법, 갱신 스크립트로 예상 출력을 다시 만드는 절차를 다룹니다.
Instructions for authoring, structuring, and running toolchain tests using the file_test infrastructure.
실행 점수 미검증
설치 방법 보기이 스킬은 file_test 기반으로 Carbon 도구 체인 테스트를 만들고 구성하고 실행하는 방법을 설명합니다. 표준 파일 헤더와 설정 주석, 최소 전처리 파일, 하나의 파일에서 여러 사례를 분리하는 방법을 다룹니다. fail_, todo_ 같은 접두사를 사용해 예상되는 실패나 잘못된 현재 동작을 표시하는 규칙도 안내합니다. 또한 마커를 사용해 SemIR 출력을 특정 선언에 한정하는 방법과 ./toolchain/autoupdate_testdata.py로 예상 표준 출력 및 표준 오류를 다시 생성하는 방법을 설명합니다.
Carbon 컴파일러 기능을 추가하거나 변경하고 해당 테스트를 작성할 때 참고할 수 있습니다. 성공하는 사례와 실패를 검증하는 사례를 나누거나, 캡처되는 출력 범위를 줄이고 싶을 때도 유용합니다. 상수 평가의 경계값을 포함해 안정적인 테스트를 구성하는 지침도 담고 있습니다.
file_test를 성공 사례와 실패 사례로 나눠 작성해 주세요.”대상은 Carbon 도구 체인 테스트입니다. // CHECK:STDOUT: 및 // CHECK:STDERR: 행을 직접 편집하지 말고 ./toolchain/autoupdate_testdata.py로 갱신해야 합니다. 갱신된 출력이 의도한 동작을 나타내는지는 별도로 확인해야 합니다. 언어 서버 테스트는 다른 규칙을 사용하므로 별도 스킬을 참조하세요.
이 소개문은 공개된 SKILL.md를 바탕으로 AI(OpenAI Codex)가 작성했습니다. 정확한 사양은 아래 원문을 확인하세요.
AI가 SKILL.md의 내용에서 주의가 필요한 작업과 도입 전제를 확인했습니다. 점수는 실제로 실행한 결과(실행 검증)만으로 매깁니다.
점수에는 넣지 않았습니다. 2026년 10월 26일 기준으로 AI(OpenAI Codex)가 판정했습니다. 참고용이므로 설치 전에 원문도 확인해 주세요.
설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.
This skill provides guidelines and patterns for creating and updating tests for
the Carbon toolchain, especially file tests in toolchain/*/testdata/ (for
example, toolchain/check/testdata/).
Toolchain tests evaluate Carbon source files through Lexing, Parsing, Checking, and optionally Lowering. Output (for example SemIR dumps, Clang errors) is captured and validated using inline CHECK records.
Language server tests also use file_test, but with quite different
conventions (an LSP message stream, AUTOUPDATE-SPLIT, FROM_FILE_SPLIT).
Refer to the Language server skill
(SKILL.md) for those.
Test files must start with the standard Carbon license, followed by
configuration comments. Separate sections with blank comment lines (//).
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/...
//
// AUTOUPDATE
// AUTOUPDATE is mandatory for files using CHECK markers.// TIP: lines are automatically generated by the autoupdater. You do not
need to hand-write them. It is harmless to add them, but the script will
handle it.When writing tests entirely unrelated to the Core package, specify a minimal
prelude file using // INCLUDE-FILE. Usually, include
toolchain/testing/testdata/min_prelude/ scripts, such as int.carbon or
primitives.carbon. This significantly speeds up execution and minimizes STDOUT
noise.
+, -, /,
<, etc.) are not imported or available inside minimized preludes. To
write tests with a minimal prelude footprint, call primitive builtins
directly (e.g., float.negate, float.div) inside your test code to build
expressions.[[@TEST_NAME]]A single physical file can test multiple scenarios using split constraints:
// --- passing_case.carbon
library "[[@TEST_NAME]]";
// ...
// --- fail_bad_case.carbon
library "[[@TEST_NAME]]";
// ...
library "[[@TEST_NAME]]"; in each split rather than
hardcoding the library name. This prevents name conflicts, avoids redefining
the default library, and keeps the test code clean and templateable.[[@TEST_NAME]] (including the brackets) must be used. The test
infrastructure automatically replaces it with the split's filename minus
todo_ and fail_ prefixes.fail_ and todo_Expected failures must be differentiated from unexpected failures (and from bugs). Include prefixes to name individual split files or the main test:
fail_...: The test should and does produce compiler errors.todo_fail_...: The test should produce errors but currently does not.fail_todo_...: The test does produce errors or crashes, but it shouldn't
(or produces the wrong errors or otherwise misbehaves with errors).todo_...: The test has some incorrect behavior, but doesn't produce errors
currently, and shouldn't.Main File Naming: The main test file (and any split-files) must have a
fail_ prefix if they have an associated error. Exception: The main file
may omit fail_ if it contains a least one split that has a fail_ prefix.
Both the fail_ and todo_ prefixes are stripped from filename properties like
[[@TEST_NAME]].
When testing constant evaluation in semantic checker tests, follow these conventions to ensure diagnostic stability and accuracy:
Expect(X as f64) function).0x1.0000000000001p0) or a highly
precise decimal fractional spelling (e.g. 1.0000000000000001) instead of
coarse fractions like 1.1 to ensure correct boundary assertions.i32 or u32).0 and 0.0
explicitly. Assert that zero inputs are sized and simplified correctly
without triggering calculation underflows, division-by-zero errors, or
underestimating required bit allocations.Limit STDOUT checks to the logic under test. Always use //@dump-sem-ir-begin
and //@dump-sem-ir-end around the specific declarations/blocks where SemIR
output is desired. Only use these markers and not
--dump-sem-ir-ranges=if-present or similar extra args—new tests use
//@dump-sem-ir... to naturally filter output to the highlighted segments based
on the default behavior.
//@dump-sem-ir-begin
fn F(x:? form(ref i32));
//@dump-sem-ir-end
AI tools should never hand-write or manually touch // CHECK:STDOUT: or
// CHECK:STDERR: comments.
Write your Carbon test code, headers, and // AUTOUPDATE then run the test
updater:
./toolchain/autoupdate_testdata.py toolchain/PATH/TO/YOUR/TEST.carbon
Review the updated test outputs (for example, by way of git diff). Ensure
logic paths are correctly tested rather than producing massive boilerplate
blocks.
Autoupdating makes the tests pass whether or not the new behavior is correct, so deciding that the new output is the output you wanted is a separate step. See the Review testdata changes skill.
아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.
로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.
아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.
명령줄의 `gh`로 GitHub 이슈 본문과 댓글을 읽기 전용으로 확인하는 방법을 안내합니다. 번호나 URL로 이슈를 찾고 다른 저장소를 지정하는 방법, 댓글이 많은 경우 JSON과 `jq`로 내용을 추출하는 방법을 다룹니다.
Carbon 저장소에서 일하는 AI 도우미가 전용 환경 도구로 파일을 읽고 검색하고 편집하는 규칙을 안내합니다. 임시 파일을 둘 위치와 삭제 시점, 사용자 지정 프로그램을 허용하는 경우도 설명합니다.
Carbon 프로젝트에서 Bazelisk로 빌드, 테스트, 실행하는 기본 절차를 안내합니다. 대상을 지정한 검증, ASan 활성화, 시스템 의존성 변경 후 캐시 재생성도 다룹니다.
Carbon 컴파일러에 내장 함수를 추가하는 절차를 안내합니다. 함수 등록과 시그니처 검증부터 상수 평가, 런타임 호출의 LLVM IR 생성, Prelude 연결, 최소 Prelude를 이용한 개별 테스트까지 다룹니다.
Carbon 툴체인의 Bazel, C++, Carbon, Markdown, Python 파일 서식 기준을 안내합니다. 주석, 문서, 이름, 설계 원칙과 변경 내용을 설명하는 커밋 메시지 작성법도 다룹니다.
Carbon 도구 체인에서 오류와 경고 진단을 추가하거나 수정하는 방법을 안내합니다. 진단 종류 등록, 형식이 지정된 인수로 메시지 구성, 소스 위치에 라벨과 문맥 연결, 문구 규칙 및 테스트 범위 확인을 다룹니다.