@@ -1221,6 +1221,54 @@ func TestNewPlanJob(t *testing.T) {
12211221 (repoNamePatterns . [(?i)foo bar baz])))
12221222 REPOSCOMPUTEEXCLUDED
12231223 NOOP))))))
1224+ ` ),
1225+ },
1226+
1227+ // This test shows that we can handle languages not in Linguist
1228+ {
1229+ query : `context:global repo:sourcegraph/.* lang:magik` ,
1230+ protocol : search .Streaming ,
1231+ searchType : query .SearchTypeKeyword ,
1232+ want : autogold .Expect (`
1233+ (LOG
1234+ (ALERT
1235+ (features . error decoding features)
1236+ (protocol . Streaming)
1237+ (onSourcegraphDotCom . true)
1238+ (query . )
1239+ (originalQuery . )
1240+ (patternType . keyword)
1241+ (TIMEOUT
1242+ (timeout . 20s)
1243+ (LIMIT
1244+ (limit . 10000)
1245+ (PARALLEL
1246+ (REPOPAGER
1247+ (containsRefGlobs . false)
1248+ (repoOpts.repoFilters . [sourcegraph/.*])
1249+ (repoOpts.searchContextSpec . global)
1250+ (PARTIALREPOS
1251+ (ZOEKTREPOSUBSETTEXTSEARCH
1252+ (fileMatchLimit . 10000)
1253+ (select . )
1254+ (zoektQueryRegexps . [(?i)(?im:\.MAGIK$)])
1255+ (query . file_regex:"(?i:\\.MAGIK)(?m:$)")
1256+ (type . text))))
1257+ (REPOPAGER
1258+ (containsRefGlobs . false)
1259+ (repoOpts.repoFilters . [sourcegraph/.*])
1260+ (repoOpts.searchContextSpec . global)
1261+ (PARTIALREPOS
1262+ (SEARCHERTEXTSEARCH
1263+ (useFullDeadline . true)
1264+ (patternInfo . TextPatternInfo{//,filematchlimit:10000,lang:magik,f:"(?i)\\.magik$"})
1265+ (numRepos . 0)
1266+ (pathRegexps . [(?i)\.magik$])
1267+ (indexed . false))))
1268+ (REPOSCOMPUTEEXCLUDED
1269+ (repoOpts.repoFilters . [sourcegraph/.*])
1270+ (repoOpts.searchContextSpec . global))
1271+ NOOP)))))
12241272` ),
12251273 },
12261274 }
@@ -1278,6 +1326,7 @@ func TestToTextPatternInfo(t *testing.T) {
12781326 cases := []struct {
12791327 input string
12801328 output autogold.Value
1329+ feat search.Features
12811330 }{{
12821331 input : `type:repo archived` ,
12831332 output : autogold .Expect (`{"Query":{"Value":"archived","IsNegated":false,"IsRegExp":false},"IsStructuralPat":false,"CombyRule":"","IsCaseSensitive":false,"FileMatchLimit":30,"Index":"yes","Select":[],"IncludePaths":null,"ExcludePaths":"","IncludeLangs":null,"ExcludeLangs":null,"PathPatternsAreCaseSensitive":false,"PatternMatchesContent":false,"PatternMatchesPath":false,"Languages":null}` ),
@@ -1410,9 +1459,17 @@ func TestToTextPatternInfo(t *testing.T) {
14101459 }, {
14111460 input : `repo:^github\.com/sgtest/sourcegraph-typescript$ file:^README\.md "basic :[_] access :[_]" patterntype:structural` ,
14121461 output : autogold .Expect (`{"Query":{"Value":"\"basic :[_] access :[_]\"","IsNegated":false,"IsRegExp":false},"IsStructuralPat":true,"CombyRule":"","IsCaseSensitive":false,"FileMatchLimit":30,"Index":"yes","Select":[],"IncludePaths":["^README\\.md"],"ExcludePaths":"","IncludeLangs":null,"ExcludeLangs":null,"PathPatternsAreCaseSensitive":false,"PatternMatchesContent":true,"PatternMatchesPath":true,"Languages":null}` ),
1462+ }, {
1463+ input : `sgtest lang:magik type:file` ,
1464+ feat : search.Features {ContentBasedLangFilters : true },
1465+ output : autogold .Expect (`{"Query":{"Value":"sgtest","IsNegated":false,"IsRegExp":false},"IsStructuralPat":false,"CombyRule":"","IsCaseSensitive":false,"FileMatchLimit":30,"Index":"yes","Select":[],"IncludePaths":null,"ExcludePaths":"","IncludeLangs":["Magik"],"ExcludeLangs":null,"PathPatternsAreCaseSensitive":false,"PatternMatchesContent":true,"PatternMatchesPath":false,"Languages":["magik"]}` ),
1466+ }, {
1467+ input : `sgtest lang:magik type:file` ,
1468+ feat : search.Features {ContentBasedLangFilters : false },
1469+ output : autogold .Expect (`{"Query":{"Value":"sgtest","IsNegated":false,"IsRegExp":false},"IsStructuralPat":false,"CombyRule":"","IsCaseSensitive":false,"FileMatchLimit":30,"Index":"yes","Select":[],"IncludePaths":["(?i)\\.magik$"],"ExcludePaths":"","IncludeLangs":null,"ExcludeLangs":null,"PathPatternsAreCaseSensitive":false,"PatternMatchesContent":true,"PatternMatchesPath":false,"Languages":["magik"]}` ),
14131470 }}
14141471
1415- test := func (input string ) string {
1472+ test := func (input string , feat search. Features ) string {
14161473 searchType := overrideSearchType (input , query .SearchTypeLiteral )
14171474 plan , err := query .Pipeline (query .Init (input , searchType ))
14181475 if err != nil {
@@ -1423,14 +1480,14 @@ func TestToTextPatternInfo(t *testing.T) {
14231480 }
14241481 b := plan [0 ]
14251482 resultTypes := computeResultTypes (b , query .SearchTypeLiteral , defaultResultTypes )
1426- p := toTextPatternInfo (b , resultTypes , & search. Features {} , limits .DefaultMaxSearchResults )
1483+ p := toTextPatternInfo (b , resultTypes , & feat , limits .DefaultMaxSearchResults )
14271484 v , _ := json .Marshal (p )
14281485 return string (v )
14291486 }
14301487
14311488 for _ , tc := range cases {
14321489 t .Run (tc .input , func (t * testing.T ) {
1433- tc .output .Equal (t , test (tc .input ))
1490+ tc .output .Equal (t , test (tc .input , tc . feat ))
14341491 })
14351492 }
14361493}
0 commit comments