250205.9 · 9aab4778ae6d573f6701e03b53a45791dbaa36d8
Get rid of the last bits of Barfly
reading declarations
@@ -27,7 +27,6 @@ lib/App/Ack/Filter/MatchGroup.pm squash -t/Barfly.pm t/Util.pm t/test-pager @@ -66,8 +65,6 @@ t/ack-s.t t/ack-show-types.t t/ack-type-del.t t/ack-type.t-t/ack-underline.barfly-t/ack-underline.t t/ack-v.yaml t/ack-version.t t/ack-w.t
dev/barfly.vim
@@ -1,17 +0,0 @@-" Barfly syntax file-if exists("b:current_syntax")- finish-endif--" The "done" detection could be better here... any X in the string will-" highlight when we define it this way:-syn keyword barflyKeyword BEGIN END RUN YES NO YESLINES-syn match barflyComment /^#.*$/ contains=hwdTodo--"-" highlighting defs-"-hi def link barflyComment Comment-hi def link barflyKeyword Special--let b:current_syntax = "barfly"
t/Barfly.pm
@@ -1,162 +0,0 @@-package Barfly;--use warnings;-use strict;--use Test::More;--sub run_tests {- my $class = shift;- my $filename = shift;-- my $self = bless {- blocks => [],- }, $class;-- my $block;- my $section;-- open( my $fh, '<', $filename ) or die "Can't open $filename: $!";-- my %blocknames_seen;- my $lineno = 0;- while ( my $line = <$fh> ) {- ++$lineno;- chomp $line;- $line =~ s/\s*$//;- next if $line =~ /^#/;- next unless $line =~ /\S/;-- $line =~ s/\s+$//;- if ( $line =~ /^BEGIN\s+(.*)/ ) {- if ( defined($block) ) {- die 'We are already in the middle of a block';- }-- my $blockname = $1;- $blocknames_seen{ $blockname }++ and die qq{Block "$blockname" is duplicated in $filename at $lineno};-- $block = Barfly::Block->new( $blockname, $filename, $lineno );- $section = undef;- }- elsif ( $line eq 'END' ) {- push( @{$self->{blocks}}, $block );- $block = undef;- $section = undef;- }- elsif ( $line eq 'RUN' || $line eq 'YES' || $line eq 'NO' || $line eq 'YESLINES' ) {- $section = $line;- }- else {- $block->add_line( $section, $line );- }- }- close $fh or die "Can't close $filename: $!";-- my @blocks = @{$self->{blocks}} or return fail( "No blocks found in $filename!" );- for my $block ( @blocks ) {- $block->run;- }-- return;-}---package Barfly::Block;--use Test::More;-use Util;--sub new {- my $class = shift;- my $label = shift // die 'Block label cannot be blank';- my $filename = shift;- my $lineno = shift;-- return bless {- label => $label,- filename => $filename,- lineno => $lineno,- }, $class;-}--sub add_line {- my $self = shift;- my $section = shift;- my $line = shift;-- push @{$self->{$section}}, $line;-- return;-}---sub run {- local $Test::Builder::Level = $Test::Builder::Level + 1;-- my $self = shift;-- return subtest sprintf( '%s: %s, line %d', $self->{label}, $self->{filename}, $self->{lineno} ) => sub {- plan tests => 2;-- my @command_lines = @{$self->{RUN} // []} or die 'No RUN lines specified!';-- subtest "$self->{label}: YES/NO" => sub {- plan tests => scalar @command_lines;-- # Set up scratch file- my @yes = @{$self->{YES} // []};- my @no = @{$self->{NO} // []};-- my $tempfile = create_tempfile( @yes, @no );-- for my $command_line ( @command_lines ) {- subtest $command_line => sub {- plan tests => 2;-- $command_line = _untaint( $command_line );-- my @args = split( / /, $command_line );- @args > 1 or die "Invalid command line: $command_line";- shift @args eq 'ack' or die 'Command line must begin with ack';-- my @results = main::run_ack( @args, $tempfile->filename );- main::lists_match( \@results, \@yes, $command_line );- };- }- };-- subtest "$self->{label}: YESLINES" => sub {- return pass( 'No yeslines' ) if !$self->{YESLINES};-- plan tests => scalar @command_lines;-- my @all_lines = @{$self->{YESLINES}};- my @input_lines = grep { /[^ ^]/ } @all_lines;- my $tempfile = create_tempfile( @input_lines );-- for my $command_line ( @command_lines ) {- subtest $command_line => sub {- plan tests => 2;-- $command_line = _untaint( $command_line );-- my @args = split( / /, $command_line );- @args > 1 or die "Invalid command line: $command_line";- shift @args eq 'ack' or die 'Command line must begin with ack';-- push( @args, '--underline' );-- my @results = main::run_ack( @args, $tempfile->filename );- main::lists_match( \@results, \@all_lines, $command_line );- };- }- };- };-}--sub _untaint {- return $_[0] =~ /(.*)/ ? $1 : undef;-}--1;
t/ack-underline.barfly
@@ -1,47 +0,0 @@-# BEGIN comment here-#-# RUN-# ack command line(s)-# They should NOT be shell-escaped. Args are split on whitespace before-# being passed in to ack.-#-# YESLINES-# Lines that should match with underlines shown-# ^^^^^^^^^^-# YES-# Lines that should match, but without the underlines.-#-# NO-# Lines that should not match.-#-# END-#-# Blank lines are always ignored.---BEGIN Back-references--RUN-ack (\w+)-\1-ack (?:(\w+)-\1)---YES-Bamm-Bamm-Ack-Ack-foo-foo--NO-Bamm Bamm-Bamm-Bam--YESLINES-Pebbles & Bamm-Bamm- ^^^^^^^^^--ha-ha-ha-ha-ho-ho-hee-hee-hoo-hah-^^^^^ ^^^^^ ^^^^^ ^^^^^^^--END--# vi:set ft=barfly:
@@ -3,20 +3,13 @@ use warnings; use strict; -use Test::More tests => 8;+use Test::More tests => 7; use lib 't'; use Util;-use Barfly; prep_environment(); -# Run some basic tests.-Barfly->run_tests( 't/ack-underline.barfly' );--# Most of the rest of this file is done manually rather than in Barfly-# because Barfly relies on --underline working correctly.- my $bill_ = reslash( 't/text/bill-of-rights.txt' ); my $getty = reslash( 't/text/gettysburg.txt' );
@@ -7,7 +7,6 @@ use lib 't'; use Test::More tests => 8; use Util;-use Barfly; prep_environment();