xref: /aosp_15_r20/external/toolchain-utils/compiler_wrapper/print_config_flag_test.go (revision 760c253c1ed00ce9abd48f8546f08516e57485fe)
1// Copyright 2019 The ChromiumOS Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package main
6
7import (
8	"strings"
9	"testing"
10)
11
12func TestRemovePrintConfigArg(t *testing.T) {
13	withTestContext(t, func(ctx *testContext) {
14		cmd := ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, "-print-config", mainCc)))
15		if err := verifyArgCount(cmd, 0, "-print-config"); err != nil {
16			t.Error(err)
17		}
18	})
19}
20
21func TestPrintConfig(t *testing.T) {
22	withTestContext(t, func(ctx *testContext) {
23		ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, "-print-config", mainCc)))
24		if !strings.Contains(ctx.stderrString(), "wrapper config: main.config{") {
25			t.Errorf("config not printed to stderr. Got: %s", ctx.stderrString())
26		}
27	})
28}
29