comparison tests/test-fileset.t @ 38879:e79a69af1593

fileset: insert hints where status should be computed This will allow us to compute status against a narrowed set of files. For example, "path:build/ & (unknown() + missing())" is rewritten as "path:build/ & <withstatus>(unknown() + missing(), 'unknown missing')", and the status call can be narrowed by the left-hand-side matcher, "path:build/". mctx.buildstatus() calls will be solely processed by getmatchwithstatus().
author Yuya Nishihara <yuya@tcha.org>
date Sat, 21 Jul 2018 20:27:53 +0900
parents 899b4c74209c
children 3984409e144b
comparison
equal deleted inserted replaced
38878:0f56d08e6271 38879:e79a69af1593
173 (symbol 'a2') 173 (symbol 'a2')
174 (and 174 (and
175 (func 175 (func
176 (symbol 'grep') 176 (symbol 'grep')
177 (string 'b')) 177 (string 'b'))
178 (func 178 (withstatus
179 (symbol 'clean') 179 (func
180 None))) 180 (symbol 'clean')
181 None)
182 (string 'clean'))))
181 * optimized: 183 * optimized:
182 (or 184 (or
183 (patterns 185 (patterns
184 (symbol 'a1') 186 (symbol 'a1')
185 (symbol 'a2')) 187 (symbol 'a2'))
186 (and 188 (and
187 (func 189 (withstatus
188 (symbol 'clean') 190 (func
189 None) 191 (symbol 'clean')
192 None)
193 (string 'clean'))
190 (func 194 (func
191 (symbol 'grep') 195 (symbol 'grep')
192 (string 'b')))) 196 (string 'b'))))
193 * matcher: 197 * matcher:
194 <unionmatcher matchers=[ 198 <unionmatcher matchers=[
371 a1 375 a1
372 a2 376 a2
373 b1 377 b1
374 b2 378 b2
375 c1 379 c1
380
381 Test insertion of status hints
382
383 $ fileset -p optimized 'added()'
384 * optimized:
385 (withstatus
386 (func
387 (symbol 'added')
388 None)
389 (string 'added'))
390 c1
391
392 $ fileset -p optimized 'a* & removed()'
393 * optimized:
394 (and
395 (symbol 'a*')
396 (withstatus
397 (func
398 (symbol 'removed')
399 None)
400 (string 'removed')))
401 a2
402
403 $ fileset -p optimized 'a* - removed()'
404 * optimized:
405 (minus
406 (symbol 'a*')
407 (withstatus
408 (func
409 (symbol 'removed')
410 None)
411 (string 'removed')))
412 a1
413
414 $ fileset -p analyzed -p optimized '(added() + removed()) - a*'
415 * analyzed:
416 (and
417 (withstatus
418 (or
419 (func
420 (symbol 'added')
421 None)
422 (func
423 (symbol 'removed')
424 None))
425 (string 'added removed'))
426 (not
427 (symbol 'a*')))
428 * optimized:
429 (and
430 (not
431 (symbol 'a*'))
432 (withstatus
433 (or
434 (func
435 (symbol 'added')
436 None)
437 (func
438 (symbol 'removed')
439 None))
440 (string 'added removed')))
441 c1
442
443 $ fileset -p optimized 'a* + b* + added() + unknown()'
444 * optimized:
445 (withstatus
446 (or
447 (patterns
448 (symbol 'a*')
449 (symbol 'b*'))
450 (func
451 (symbol 'added')
452 None)
453 (func
454 (symbol 'unknown')
455 None))
456 (string 'added unknown'))
457 a1
458 a2
459 b1
460 b2
461 c1
462 c3
463
464 $ fileset -p analyzed -p optimized 'removed() & missing() & a*'
465 * analyzed:
466 (and
467 (withstatus
468 (and
469 (func
470 (symbol 'removed')
471 None)
472 (func
473 (symbol 'missing')
474 None))
475 (string 'removed missing'))
476 (symbol 'a*'))
477 * optimized:
478 (and
479 (symbol 'a*')
480 (withstatus
481 (and
482 (func
483 (symbol 'removed')
484 None)
485 (func
486 (symbol 'missing')
487 None))
488 (string 'removed missing')))
489
490 $ fileset -p optimized 'clean() & revs(0, added())'
491 * optimized:
492 (and
493 (withstatus
494 (func
495 (symbol 'clean')
496 None)
497 (string 'clean'))
498 (func
499 (symbol 'revs')
500 (list
501 (symbol '0')
502 (withstatus
503 (func
504 (symbol 'added')
505 None)
506 (string 'added')))))
507 b1
508
509 $ fileset -p optimized 'clean() & status(null, 0, b* & added())'
510 * optimized:
511 (and
512 (withstatus
513 (func
514 (symbol 'clean')
515 None)
516 (string 'clean'))
517 (func
518 (symbol 'status')
519 (list
520 (symbol 'null')
521 (symbol '0')
522 (and
523 (symbol 'b*')
524 (withstatus
525 (func
526 (symbol 'added')
527 None)
528 (string 'added'))))))
529 b1
376 530
377 Test files properties 531 Test files properties
378 532
379 >>> open('bin', 'wb').write(b'\0a') and None 533 >>> open('bin', 'wb').write(b'\0a') and None
380 $ fileset 'binary()' 534 $ fileset 'binary()'