]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: use new flag mechanims to handle importC test
authorRobert Griesemer <gri@golang.org>
Thu, 17 Mar 2022 21:04:37 +0000 (14:04 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 21 Mar 2022 19:10:43 +0000 (19:10 +0000)
Change-Id: I6f0cb850ee23184380c03a53c12425c350aa16e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/393714
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/check_test.go
src/cmd/compile/internal/types2/testdata/check/importC.src
src/go/types/check_test.go
src/go/types/testdata/check/importC.src

index 89d2cc644cfea9de8537209eb7bfaa55da309b24..988983ee04e4756f847086d6a45052aa71f4ad36 100644 (file)
@@ -130,6 +130,7 @@ func testFiles(t *testing.T, filenames []string, colDelta uint, manual bool) {
        var conf Config
        flags := flag.NewFlagSet("", flag.PanicOnError)
        flags.StringVar(&conf.GoVersion, "lang", "", "")
+       flags.BoolVar(&conf.FakeImportC, "fakeImportC", false, "")
        if err := parseFlags(filenames[0], nil, flags); err != nil {
                t.Fatal(err)
        }
@@ -156,10 +157,6 @@ func testFiles(t *testing.T, filenames []string, colDelta uint, manual bool) {
        }
 
        // typecheck and collect typechecker errors
-       // special case for importC.src
-       if len(filenames) == 1 && strings.HasSuffix(filenames[0], "importC.src") {
-               conf.FakeImportC = true
-       }
        conf.Trace = manual && testing.Verbose()
        conf.Importer = defaultImporter()
        conf.Error = func(err error) {
index f55be2d5c53c89ca57076da9755e2019d6b55d1b..807802199fda5cbe695fd86cba48062736f45d98 100644 (file)
@@ -1,3 +1,5 @@
+// -fakeImportC
+
 // Copyright 2015 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
index 6bee41d141a2e0390b3972687587f9cccb24719a..d962b0c4052080be37cae6ac5ec30d79cb90124b 100644 (file)
@@ -233,6 +233,7 @@ func testFiles(t *testing.T, sizes Sizes, filenames []string, srcs [][]byte, man
        conf.Sizes = sizes
        flags := flag.NewFlagSet("", flag.PanicOnError)
        flags.StringVar(&conf.GoVersion, "lang", "", "")
+       flags.BoolVar(&conf.FakeImportC, "fakeImportC", false, "")
        if err := parseFlags(filenames[0], srcs[0], flags); err != nil {
                t.Fatal(err)
        }
@@ -265,17 +266,10 @@ func testFiles(t *testing.T, sizes Sizes, filenames []string, srcs [][]byte, man
        }
 
        // typecheck and collect typechecker errors
-       // special case for importC.src
-       if len(filenames) == 1 {
-               if strings.HasSuffix(filenames[0], "importC.src") {
-                       conf.FakeImportC = true
-               }
-       }
-
-       conf.Importer = imp
        if imp == nil {
-               conf.Importer = importer.Default()
+               imp = importer.Default()
        }
+       conf.Importer = imp
        conf.Error = func(err error) {
                if *haltOnError {
                        defer panic(err)
index f55be2d5c53c89ca57076da9755e2019d6b55d1b..807802199fda5cbe695fd86cba48062736f45d98 100644 (file)
@@ -1,3 +1,5 @@
+// -fakeImportC
+
 // Copyright 2015 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.