@@ -2216,6 +2216,35 @@ def create_files(files, srcdir, code):
22162216 path = os .path .join (ext_path , filename )
22172217 self .assertNotIn (path , out )
22182218
2219+ def test_cli_make_exclude (self ):
2220+ code = dedent ("""
2221+ /*[clinic input]
2222+ [clinic start generated code]*/
2223+ """ )
2224+ with os_helper .temp_dir (quiet = False ) as tmp_dir :
2225+ # add some folders, some C files and a Python file
2226+ for fn in "file1.c" , "file2.c" , "file3.c" , "file4.c" :
2227+ path = os .path .join (tmp_dir , fn )
2228+ with open (path , "w" , encoding = "utf-8" ) as f :
2229+ f .write (code )
2230+
2231+ # Run clinic in verbose mode with --make on tmpdir.
2232+ # Exclude file2.c and file3.c.
2233+ out = self .expect_success (
2234+ "-v" , "--make" , "--srcdir" , tmp_dir ,
2235+ "--exclude" , os .path .join (tmp_dir , "file2.c" ),
2236+ # The added ./ should be normalised away.
2237+ "--exclude" , os .path .join (tmp_dir , "./file3.c" ),
2238+ # Relative paths should also work.
2239+ "--exclude" , "file4.c"
2240+ )
2241+
2242+ # expect verbose mode to only mention the C files in tmp_dir
2243+ self .assertIn ("file1.c" , out )
2244+ self .assertNotIn ("file2.c" , out )
2245+ self .assertNotIn ("file3.c" , out )
2246+ self .assertNotIn ("file4.c" , out )
2247+
22192248 def test_cli_verbose (self ):
22202249 with os_helper .temp_dir () as tmp_dir :
22212250 fn = os .path .join (tmp_dir , "test.c" )
0 commit comments