From 85acd315bdba97fcf0106edde1f1634ba9a7358c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Jourdois?= Date: Sun, 18 Jul 2010 15:40:41 +0200 Subject: [PATCH] Add a gitignore coherency test This tests helps to maintain .gitignore up to date, by : - testing if all ignored files have to be ignored, and - testing if all untracked files are ignored. [ Note : second version ] Make test work on older git versions I.e. the git version used on Debian stable. --- .gitignore | 5 ++--- t/gitignore.t | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 t/gitignore.t diff --git a/.gitignore b/.gitignore index 6c54293..d9bc9cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ -# Note! Please use 'git ls-files -i --exclude-standard' -# command after changing this file, to see if there are -# any tracked files which get ignored after the change. +# Note! Please run 'prove t/gitignore.t' after changing +# this file, to check its coherency # all dotfiles .* diff --git a/t/gitignore.t b/t/gitignore.t new file mode 100644 index 0000000..90904cd --- /dev/null +++ b/t/gitignore.t @@ -0,0 +1,45 @@ +#!/usr/bin/perl -w +# +# Test that .gitignore is coherent +# +# Stéphane (kwisatz) Jourdois +# -- +# + +use strict; +use Test::More tests => 3; + +BEGIN { use_ok( 'Git' ); } + + +# First, check that no tracked files are ignored +my $cmd = Git::command_output_pipe('ls-files', '--ignored', '--exclude-standard'); +my $output; +while (<$cmd>) { $output .= "--> $_" } +close $cmd; + +ok(!defined $output, 'No tracked file is ignored') + or diag(<) { $output .= "--> $_" } +close $cmd; + +ok(!defined $output, 'No untracked file is present') + or diag(<