summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Hoelz <rob@hoelz.ro>2013-03-24 23:07:07 +0100
committerRob Hoelz <rob@hoelz.ro>2013-03-24 23:07:07 +0100
commit09df8b639deb55727b3edfdb9153c07bd3d113fc (patch)
tree1f04c9635e6afd5fc97ea6df49ea753dbfadd2b3
parent04fde6b928aa66741332c707d4d2fb0617c543d9 (diff)
downloadpygments-09df8b639deb55727b3edfdb9153c07bd3d113fc.tar.gz
Remove Perl 6 helper scripts
-rw-r--r--p6-scripts/check-files5
-rwxr-xr-xp6-scripts/check-for-regressions.pl160
-rw-r--r--p6-scripts/setup.sh11
-rwxr-xr-xp6-scripts/update-last-versions.pl42
4 files changed, 0 insertions, 218 deletions
diff --git a/p6-scripts/check-files b/p6-scripts/check-files
deleted file mode 100644
index dd1bbab6..00000000
--- a/p6-scripts/check-files
+++ /dev/null
@@ -1,5 +0,0 @@
-test.p6
-grammar-test.p6
-Grammar.pm
-Optimizer.pm
-RoleQ.pm
diff --git a/p6-scripts/check-for-regressions.pl b/p6-scripts/check-for-regressions.pl
deleted file mode 100755
index 3e02fa11..00000000
--- a/p6-scripts/check-for-regressions.pl
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-use autodie;
-use feature qw(say state);
-use utf8;
-use charnames ();
-
-use Encode qw(decode_utf8);
-use File::Slurp qw(read_file write_file);
-use File::Spec;
-
-my $PYTHON = 'python';
-if(system('which python2 1>/dev/null 2>/dev/null') == 0) {
- $PYTHON = 'python2';
-}
-
-binmode STDOUT, ':encoding(utf8)';
-
-sub decolorize {
- my ( $line ) = @_;
-
- $line =~ s/\e\[[\d;]*m//g;
-
- return $line;
-}
-
-sub pygmentize {
- my ( $filename ) = @_;
-
- state $pygments_mtime = (stat 'pygments/lexers/agile.py')[9];
-
- my ( undef, undef, $basename ) = File::Spec->splitpath($filename);
-
- my $current_version_filename = File::Spec->catfile('p6-scripts/.current-version', $basename);
- my $filename_mtime = (stat $filename)[9];
- my $current_mtime = (stat $current_version_filename)[9];
-
- if(defined $current_mtime && $current_mtime > $filename_mtime && $current_mtime > $pygments_mtime) {
- return read_file($current_version_filename);
- }
-
- my @lines;
-
- my ( $read, $write );
- pipe $read, $write;
- my $pid = fork;
-
- if($pid) {
- close $write;
- binmode $read, ':encoding(utf8)';
- while(<$read>) {
- push @lines, $_;
- }
- close $read;
- waitpid $pid, 0;
- } else {
- close $read;
- open STDOUT, '>&', $write;
- open STDERR, '>', '/dev/null';
-
- exec $PYTHON, './pygmentize', '-l', 'perl6', '-O', 'outencoding=utf-8', $filename;
- }
-
- unless(-e 'p6-scripts/.current-version') {
- mkdir('p6-scripts/.current-version');
- }
- write_file($current_version_filename, \@lines);
-
- return @lines;
-}
-
-sub find_difference {
- my ( $lhs, $rhs ) = @_;
-
- my $index = 0;
-
- while($index < length($lhs) &&
- $index < length($rhs) &&
- substr($lhs, $index, 1) eq substr($rhs, $index, 1)) {
-
- $index++;
- }
-
- my $lhs_char = $index > length($lhs) ? '(none)' : sprintf('0x%x', ord(substr($lhs, $index, 1)));
- my $rhs_char = $index > length($rhs) ? '(none)' : sprintf('0x%x', ord(substr($rhs, $index, 1)));
-
- return ( $index, $lhs_char, $rhs_char );
-}
-
-sub compare_lines {
- my ( $format, $offset, $old_lines, $new_lines ) = @_;
-
- foreach my $line_no ( 0 .. $#$old_lines ) {
- my $old = $old_lines->[$line_no];
- my $new = $new_lines->[$line_no];
-
- unless($old eq $new) {
- my ( $pos, $old_char, $new_char ) = find_difference($old, $new);
- $pos = length(decolorize(substr($old, 0, $pos)));
-
- printf $format . "\n", $line_no + $offset + 1;
- say "Old: '$old_char' (" . charnames::viacode($old_char) . ')';
- say "New: '$new_char' (" . charnames::viacode($new_char) . ')';
- print $old;
- say ' ' x $pos, '↑';
- say ' ' x $pos, '↓';
- print $new;
-
- return;
- }
- }
-
- return 1;
-}
-
-unless(@ARGV) {
- @ARGV = read_file('p6-scripts/check-files');
-}
-
-my @files = grep {
- $_->[0] !~ /^#/
-} map {
- chomp;
- [ split /:/, $_ ]
-} @ARGV;
-
-foreach my $pair (@files) {
- my ( $filename, $good_line ) = @$pair;
- my $last_version_filename = File::Spec->catfile('p6-scripts/.last-version', $filename);
-
- unless(-e $last_version_filename) {
- say "'$last_version_filename' does not exist; skipping '$filename'";
- next;
- }
-
- my @old_lines = map { decode_utf8($_) } read_file($last_version_filename);
- my @new_lines = pygmentize(File::Spec->catfile('tests/examplefiles', $filename));
-
- unless(@new_lines == @old_lines) {
- say "$filename: line count mismatch";
- next;
- }
-
- if(defined $good_line) {
- splice @old_lines, 0, $good_line;
- splice @new_lines, 0, $good_line;
- }
-
- next unless compare_lines("Text for line %d of file $filename does not match",
- $good_line || 0,
- [ map { decolorize($_) } @old_lines ],
- [ map { decolorize($_) } @new_lines ]);
-
- next unless compare_lines("Colors for line %d of file $filename do not match",
- $good_line || 0,
- \@old_lines,
- \@new_lines);
-}
diff --git a/p6-scripts/setup.sh b/p6-scripts/setup.sh
deleted file mode 100644
index 19e11c3b..00000000
--- a/p6-scripts/setup.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-if which python2 &>/dev/null; then
- PYTHON=python2
-else
- PYTHON=python
-fi
-
-function p {
- $PYTHON ./pygmentize -l perl6 -O outencoding=utf-8 "$1" 2>/dev/null | nl -ba | less -FRX
-}
-
-export PATH="$(pwd):$PATH"
diff --git a/p6-scripts/update-last-versions.pl b/p6-scripts/update-last-versions.pl
deleted file mode 100755
index b690bddd..00000000
--- a/p6-scripts/update-last-versions.pl
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-use autodie;
-use feature qw(say);
-
-use File::Slurp qw(read_file);
-use File::Spec;
-
-my $PYTHON = 'python';
-if(system('which python2 1>/dev/null 2>/dev/null') == 0) {
- $PYTHON = 'python2';
-}
-
-my @files = grep {
- !/^#/
-} map {
- chomp;
- (split /:/, $_)[0]
-} read_file('p6-scripts/check-files');
-
-unless(-d 'p6-scripts/.last-version') {
- mkdir('p6-scripts/.last-version');
-}
-foreach my $filename (@files) {
- my $last_version_filename = File::Spec->catfile('p6-scripts/.last-version', $filename);
-
- my $fh;
-
- open $fh, '>', $last_version_filename;
-
- my $pid = fork;
-
- if($pid) {
- waitpid $pid, 0;
- } else {
- open STDOUT, '>&', $fh;
- open STDERR, '>', '/dev/null';
- exec $PYTHON, './pygmentize', '-l', 'perl6', '-O', 'outencoding=utf-8', File::Spec->catfile('tests/examplefiles', $filename);
- }
-}