본문으로 건너뛰기
cccskills
무료GitHub에 공개한국어 소개

Toolchain tests

`file_test` 기반으로 Carbon 도구 체인 테스트를 작성하고 구성하며 실행하는 방법을 안내합니다. 테스트 헤더, 사례 분할, 실패 접두사, 필요한 SemIR 출력만 남기는 방법, 갱신 스크립트로 예상 출력을 다시 만드는 절차를 다룹니다.

원문원문 설명 보기

Instructions for authoring, structuring, and running toolchain tests using the file_test infrastructure.

carbon-language/carbon-lang스타 33,929(GitHub 33,929 + cccskills 0)

실행 점수 미검증

설치 방법 보기

이럴 때 유용합니다

  • 도구 체인 `file_test` 작성
  • 테스트를 여러 사례로 분할
  • 실패를 확인하는 테스트 작성
  • 예상 출력 다시 생성

한국어 소개

할 수 있는 일

이 스킬은 file_test 기반으로 Carbon 도구 체인 테스트를 만들고 구성하고 실행하는 방법을 설명합니다. 표준 파일 헤더와 설정 주석, 최소 전처리 파일, 하나의 파일에서 여러 사례를 분리하는 방법을 다룹니다. fail_, todo_ 같은 접두사를 사용해 예상되는 실패나 잘못된 현재 동작을 표시하는 규칙도 안내합니다. 또한 마커를 사용해 SemIR 출력을 특정 선언에 한정하는 방법과 ./toolchain/autoupdate_testdata.py로 예상 표준 출력 및 표준 오류를 다시 생성하는 방법을 설명합니다.

이럴 때 유용합니다

Carbon 컴파일러 기능을 추가하거나 변경하고 해당 테스트를 작성할 때 참고할 수 있습니다. 성공하는 사례와 실패를 검증하는 사례를 나누거나, 캡처되는 출력 범위를 줄이고 싶을 때도 유용합니다. 상수 평가의 경계값을 포함해 안정적인 테스트를 구성하는 지침도 담고 있습니다.

사용 예시

  • “이 기능의 file_test를 성공 사례와 실패 사례로 나눠 작성해 주세요.”
  • “SemIR 출력이 대상 선언에만 나오도록 테스트를 구성해 주세요.”
  • “테스트의 예상 출력을 갱신하고 변경 내용을 확인해 주세요.”

주의 사항

대상은 Carbon 도구 체인 테스트입니다. // CHECK:STDOUT: 및 // CHECK:STDERR: 행을 직접 편집하지 말고 ./toolchain/autoupdate_testdata.py로 갱신해야 합니다. 갱신된 출력이 의도한 동작을 나타내는지는 별도로 확인해야 합니다. 언어 서버 테스트는 다른 규칙을 사용하므로 별도 스킬을 참조하세요.

이 소개문은 공개된 SKILL.md를 바탕으로 AI(OpenAI Codex)가 작성했습니다. 정확한 사양은 아래 원문을 확인하세요.

문서 점검

AI가 SKILL.md의 내용에서 주의가 필요한 작업과 도입 전제를 확인했습니다. 점수는 실제로 실행한 결과(실행 검증)만으로 매깁니다.

안전성전송·삭제·명령 실행 등을 명시하고 있는가
B일부 부족갱신 스크립트가 예상 출력을 다시 쓰므로 갱신 후 내용을 확인해야 합니다.
도입의 용이성필요한 도구나 API 키가 적고 적혀 있는가
B일부 부족Carbon 저장소와 업데이트 스크립트를 사용하지만 설치 절차는 제공하지 않습니다.

점수에는 넣지 않았습니다. 2026년 10월 26일 기준으로 AI(OpenAI Codex)가 판정했습니다. 참고용이므로 설치 전에 원문도 확인해 주세요.

평가가 다르다고 생각되면 재검토를 요청하기

어느 항목이 왜 다르다고 생각하는지 적어 주세요. 로그인은 필요 없습니다. SKILL.md와 대조해 평가를 다시 만들고 이곳에 반영합니다.

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

포함된 파일(1)

  • SKILL.md8.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Toolchain tests

<!-- 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 -->

Introduction

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.

Structure and Authoring

File Layout and Headers

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.

Minimized Preludes

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.

  • Builtin Primitive Testing: Standard operators (such as +, -, /, <, 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.

Split Tests and [[@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]]";
// ...
  • Always use 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.
  • Exactly [[@TEST_NAME]] (including the brackets) must be used. The test infrastructure automatically replaces it with the split's filename minus todo_ and fail_ prefixes.
  • Do not put code that is expected to pass and code that is expected to fail into the same split. Validation relies on non-failing splits producing absolutely no errors and failing splits producing the correct compiler errors independently.

File Prefixing: 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]].

Constant Evaluation Validation

When testing constant evaluation in semantic checker tests, follow these conventions to ensure diagnostic stability and accuracy:

  • Literal Spelling Canonicalization: In Semantic IR, real literals (floating-point constants) with identical mathematical values can be assigned distinct internal representation identifiers based on spelling variations in source code. To completely prevent literal spelling mismatches in expected output checks, validation tests must be performed using canonical comparison methods (for example, passing converted values through an Expect(X as f64) function).
  • Generic Parameters Validation: To bypass compile-time constraints where local runtime variables are rejected as generic function arguments, test generic type conversions at runtime, and validate compile-time conversions by passing static literal values directly into primitive builtin calls.
  • Exhaustive Edge Case Verification: For complex mathematical algorithms (such as floating-point to integer truncation and rounding), map and execute test constraints covering every code branch, conditional exit, and fallback evaluation path.
  • Rounding Threshold Boundaries: Test cases that land extremely close to mathematical boundaries (for example, floating-point literals representing a tiny fraction above 1.0, such as $2^{30} \times 2^{-30}$ or $10^{10} \times 10^{-10}$, verifying correct exact truncation down to 1 or 0).
  • Precise Float Literal Spelling: Spell floating-point literals in test code with exact mathematical precision targeting target thresholds. For example, if testing the smallest fractional increment above 1.0, use the exact hex fractional representation (e.g. 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.
  • Representation Capacity Boundaries: Explicitly target edge cases near representation limits of target types. Test combinations of mantissas and exponents that yield values exactly on, just below, or just above the capacity limits of fixed-size destination types (e.g. signed/unsigned targets like i32 or u32).
  • Zero-Value Sizing Bounds: Verify boundary inputs of 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.

Test Code Comments

  • No agent thinking: Do not include comments describing your reasoning or "train of thought" (for example, "Wait, but...") inside the test files. Any comments left in tests should be concise and describe what the test itself is validating for human readers.

SemIR Dumps and Minimizing Output

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

Creating/Updating the Output

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.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Accessing GitHub issues

무료요약 있음

명령줄의 `gh`로 GitHub 이슈 본문과 댓글을 읽기 전용으로 확인하는 방법을 안내합니다. 번호나 URL로 이슈를 찾고 다른 저장소를 지정하는 방법, 댓글이 많은 경우 JSON과 `jq`로 내용을 추출하는 방법을 다룹니다.

  • 이슈 본문과 댓글 읽기
  • URL로 이슈 내용 확인
  • 다른 저장소의 이슈 조회
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

Agent tools

무료요약 있음

Carbon 저장소에서 일하는 AI 도우미가 전용 환경 도구로 파일을 읽고 검색하고 편집하는 규칙을 안내합니다. 임시 파일을 둘 위치와 삭제 시점, 사용자 지정 프로그램을 허용하는 경우도 설명합니다.

  • 정해진 도구로 Carbon 파일 검색
  • 파일 변경에 맞는 전용 도구 선택
  • 임시 파일 위치와 삭제 규칙 확인
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

Bazel usage

무료요약 있음

Carbon 프로젝트에서 Bazelisk로 빌드, 테스트, 실행하는 기본 절차를 안내합니다. 대상을 지정한 검증, ASan 활성화, 시스템 의존성 변경 후 캐시 재생성도 다룹니다.

  • Carbon 코드 빌드
  • 변경 사항과 관련된 테스트 실행
  • Bazel로 빌드한 프로그램 실행
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

Builtin functions

무료요약 있음

Carbon 컴파일러에 내장 함수를 추가하는 절차를 안내합니다. 함수 등록과 시그니처 검증부터 상수 평가, 런타임 호출의 LLVM IR 생성, Prelude 연결, 최소 Prelude를 이용한 개별 테스트까지 다룹니다.

  • 내장 함수 등록
  • 상수 평가 구현
  • LLVM IR 생성 추가
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

Code style

무료요약 있음

Carbon 툴체인의 Bazel, C++, Carbon, Markdown, Python 파일 서식 기준을 안내합니다. 주석, 문서, 이름, 설계 원칙과 변경 내용을 설명하는 커밋 메시지 작성법도 다룹니다.

  • Carbon 코드와 관련 파일 서식 정리
  • 주석과 문서 검토
  • 이름이 실제 의미에 맞는지 확인
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

Diagnostics

무료요약 있음

Carbon 도구 체인에서 오류와 경고 진단을 추가하거나 수정하는 방법을 안내합니다. 진단 종류 등록, 형식이 지정된 인수로 메시지 구성, 소스 위치에 라벨과 문맥 연결, 문구 규칙 및 테스트 범위 확인을 다룹니다.

  • 진단 메시지 추가
  • 소스 위치에 라벨 지정
  • 진단 문구 통일
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

carbon-language의 스킬 모두 보기

이 스킬의 문제 신고