mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 19:15:00 +01:00
This has is a nice-to-have for me. Frequently I want to run a specific test, and end up digging through output to be able to copy-paste the run line. This uses TIP lines to inject the command into the file when using AUTOUPDATE. Note, one of the reasons I want this is because "bazel test //toolchain/testing:file_test --test_output=all" has been regularly exceeding bazel's output limit for me (workaround is either opening the output file or specifying an obscure output limit flag), making it a little harder for me to get the commands. However, frequently I'm adding a file and want to iterate on it, so that's really the use case I have in mind here.
47 lines
1.7 KiB
Plaintext
47 lines
1.7 KiB
Plaintext
// 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
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/if_expr/basic.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/if_expr/basic.carbon
|
|
|
|
fn F() -> i32 { return 1; }
|
|
fn G() -> i32 { return 2; }
|
|
|
|
fn Select(b: bool) -> i32 {
|
|
return if b then F() else G();
|
|
}
|
|
|
|
// CHECK:STDOUT: ; ModuleID = 'basic.carbon'
|
|
// CHECK:STDOUT: source_filename = "basic.carbon"
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: define i32 @F() {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: ret i32 1
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: define i32 @G() {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: ret i32 2
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: define i32 @Select(i1 %b) {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: br i1 %b, label %if.expr.then, label %if.expr.else
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: if.expr.then: ; preds = %entry
|
|
// CHECK:STDOUT: %F.call = call i32 @F()
|
|
// CHECK:STDOUT: br label %if.expr.result
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: if.expr.else: ; preds = %entry
|
|
// CHECK:STDOUT: %G.call = call i32 @G()
|
|
// CHECK:STDOUT: br label %if.expr.result
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: if.expr.result: ; preds = %if.expr.else, %if.expr.then
|
|
// CHECK:STDOUT: %0 = phi i32 [ %F.call, %if.expr.then ], [ %G.call, %if.expr.else ]
|
|
// CHECK:STDOUT: ret i32 %0
|
|
// CHECK:STDOUT: }
|