@@ -89,6 +89,31 @@ func TestMultiyear(t *testing.T) {
8989 run (t , "diff" , samplefile , sampleLicensed )
9090}
9191
92+ func TestCustomCopyright (t * testing.T ) {
93+ if os .Getenv ("RUNME" ) != "" {
94+ main ()
95+ return
96+ }
97+
98+ tmp := tempDir (t )
99+ t .Logf ("tmp dir: %s" , tmp )
100+ samplefile := filepath .Join (tmp , "file.c" )
101+ const sampleLicensed = "testdata/custom_copyright_file.c"
102+ const customLicense = "testdata/custom_copyright.tpl"
103+
104+ run (t , "cp" , "testdata/initial/file.c" , samplefile )
105+ cmd := exec .Command (os .Args [0 ],
106+ "-test.run=TestCustomCopyright" ,
107+ "-f" , customLicense , "-c" , "Google LLC" , "-y" , "2022" ,
108+ "-x" , "©" , samplefile ,
109+ )
110+ cmd .Env = []string {"RUNME=1" }
111+ if out , err := cmd .CombinedOutput (); err != nil {
112+ t .Fatalf ("%v\n %s" , err , out )
113+ }
114+ run (t , "diff" , samplefile , sampleLicensed )
115+ }
116+
92117func TestWriteErrors (t * testing.T ) {
93118 if os .Getenv ("RUNME" ) != "" {
94119 main ()
@@ -248,6 +273,7 @@ func TestAddLicense(t *testing.T) {
248273 // ensure files with existing license or generated files are
249274 // skipped. No need to test all permutations of these, since
250275 // there are specific tests below.
276+ {"// (c) 2022 Acme\n content" , "// (c) 2022 Acme\n content" , false },
251277 {"// Copyright 2000 Acme\n content" , "// Copyright 2000 Acme\n content" , false },
252278 {"// Code generated by go generate; DO NOT EDIT.\n content" , "// Code generated by go generate; DO NOT EDIT.\n content" , false },
253279 }
@@ -395,6 +421,7 @@ func TestHasLicense(t *testing.T) {
395421
396422 {"Copyright 2000" , true },
397423 {"CoPyRiGhT 2000" , true },
424+ {"(c) 2022" , true },
398425 {"Subject to the terms of the Mozilla Public License" , true },
399426 {"SPDX-License-Identifier: MIT" , true },
400427 {"spdx-license-identifier: MIT" , true },
0 commit comments