2016-10-07 18:31:03 +00:00
#!/bin/bash
set +xe
2017-08-20 17:19:58 +00:00
# Release mode
case " $1 " in
"--release" ) echo "Testing release exa..." ; exa_binary = " $HOME /target/release/exa " ; ;
*) exa_binary = " $HOME /target/debug/exa " ; ;
esac
2017-06-25 10:53:59 +00:00
2017-08-19 22:27:26 +00:00
if [ ! -f " $exa_binary " ] ; then
echo " exa binary ( $exa_binary ) does not exist "
2017-08-20 17:19:58 +00:00
if [ " $1 " != "--release" ] ; then echo -e "create it first with \033[1;32mbuild-exa\033[0m or \033[1;32mb\033[0m" ; fi
2017-08-19 22:27:26 +00:00
exit 1
fi
2017-06-25 10:53:59 +00:00
# The exa command that ends up being run
exa = " $exa_binary --colour=always "
2016-10-07 18:31:03 +00:00
# Directory containing our awkward testcase files
2017-06-25 10:53:59 +00:00
testcases = "/testcases"
2016-10-07 18:31:03 +00:00
# Directory containing existing test results to compare against
2017-06-25 10:53:59 +00:00
results = "/vagrant/xtests"
2016-10-07 18:31:03 +00:00
2017-08-10 17:45:26 +00:00
# We want to use strict mode here. It’ s important that no combination of
# testing flags happens to work by accident!
2017-08-19 12:57:56 +00:00
export EXA_STRICT = "1"
# We also don’ t want to see reams and reams of debug output.
export EXA_DEBUG = ""
2017-08-10 17:45:26 +00:00
2017-04-28 18:26:57 +00:00
# Check that no files were created more than a year ago.
# Files not from the current year use a different date format, meaning
# that tests will fail until the VM gets re-provisioned.
2017-07-03 07:46:38 +00:00
# (Ignore the folder that deliberately has dates in the past)
sudo find $testcases -mtime +365 -not -path "*/dates/*" -printf "File %p has not been modified since %TY! Consider re-provisioning; tests will probably fail.\n"
2017-04-28 18:26:57 +00:00
2017-04-28 18:34:23 +00:00
2016-10-07 18:31:03 +00:00
# Long view tests
2017-04-29 10:03:43 +00:00
$exa $testcases /files -l | diff -q - $results /files_l || exit 1
2016-10-07 18:31:03 +00:00
$exa $testcases /files -lh | diff -q - $results /files_lh || exit 1
$exa $testcases /files -lhb | diff -q - $results /files_lhb || exit 1
$exa $testcases /files -lhB | diff -q - $results /files_lhb2 || exit 1
2017-07-04 16:42:16 +00:00
$exa $testcases /attributes/dirs/no-xattrs_empty -lh | diff -q - $results /empty || exit 1
2016-10-29 18:07:43 +00:00
2017-06-25 10:53:59 +00:00
$exa --color-scale $testcases /files -l | diff -q - $results /files_l_scale || exit 1
2017-05-16 19:53:28 +00:00
2017-04-28 18:34:23 +00:00
2016-10-07 18:31:03 +00:00
# Grid view tests
COLUMNS = 40 $exa $testcases /files | diff -q - $results /files_40 || exit 1
COLUMNS = 80 $exa $testcases /files | diff -q - $results /files_80 || exit 1
COLUMNS = 120 $exa $testcases /files | diff -q - $results /files_120 || exit 1
COLUMNS = 160 $exa $testcases /files | diff -q - $results /files_160 || exit 1
COLUMNS = 200 $exa $testcases /files | diff -q - $results /files_200 || exit 1
Override the names of . and ..
There was a problem when displaying . and .. in directory listings: their names would normalise to actual names! So instead of literally seeing `.`, you’d see the current directory’s name, inserted in sort order into the list of results. Obviously this is not what we want.
In unrelated news, putting `.` and `..` into the list of paths read from a directory just takes up more heap space for something that’s basically constant.
We can solve both these problems at once by moving the DotFilter to the files iterator in Dir, rather than at the Dir’s creation. Having the iterator know whether it should display `.` and `..` means it can emit those files first, and because it knows what those files really represent, it can override their file names to actually be those sequences of dots.
This is not a perfect solution: the main casualty is that a File can now be constructed with a name, some metadata, both, or neither. This is currently handled with a bunch of Options, and returns IOResult even without doing any IO operations.
But at least all the tests pass!
2017-06-28 17:41:31 +00:00
COLUMNS = 100 $exa $testcases /files/* | diff -q - $results /files_star_100 || exit 1
2017-05-02 16:40:32 +00:00
COLUMNS = 150 $exa $testcases /files/* | diff -q - $results /files_star_150 || exit 1
COLUMNS = 200 $exa $testcases /files/* | diff -q - $results /files_star_200 || exit 1
2017-04-28 18:34:23 +00:00
2016-10-07 18:31:03 +00:00
# Long grid view tests
COLUMNS = 40 $exa $testcases /files -lG | diff -q - $results /files_lG_40 || exit 1
COLUMNS = 80 $exa $testcases /files -lG | diff -q - $results /files_lG_80 || exit 1
COLUMNS = 120 $exa $testcases /files -lG | diff -q - $results /files_lG_120 || exit 1
COLUMNS = 160 $exa $testcases /files -lG | diff -q - $results /files_lG_160 || exit 1
COLUMNS = 200 $exa $testcases /files -lG | diff -q - $results /files_lG_200 || exit 1
2017-05-02 16:40:32 +00:00
COLUMNS = 100 $exa $testcases /files/* -lG | diff -q - $results /files_star_lG_100 || exit 1
COLUMNS = 150 $exa $testcases /files/* -lG | diff -q - $results /files_star_lG_150 || exit 1
COLUMNS = 200 $exa $testcases /files/* -lG | diff -q - $results /files_star_lG_200 || exit 1
2017-04-28 18:34:23 +00:00
2017-08-10 17:45:26 +00:00
# File size tests
$exa $testcases /files -l --binary | diff -q - $results /files_l_binary || exit 1
$exa $testcases /files -l --bytes | diff -q - $results /files_l_bytes || exit 1
EXA_STRICT = $exa $testcases /files -l --bytes --binary | diff -q - $results /files_l_binary || exit 1
EXA_STRICT = $exa $testcases /files -l --binary --bytes | diff -q - $results /files_l_bytes || exit 1
2016-10-07 18:31:03 +00:00
# Attributes
2017-08-06 11:02:17 +00:00
# (there are many tests, but they’ re all done in one go)
$exa $testcases /attributes -l@T | diff -q - $results /attributes || exit 1
$exa $testcases /attributes -@T | diff -q - $results /attributes_dir || exit 1
$exa $testcases /attributes/* -@T | diff -q - $results /attributes_files || exit 1
2016-10-07 18:31:03 +00:00
2017-04-28 18:34:23 +00:00
2016-10-07 18:31:03 +00:00
# UIDs and GIDs
$exa $testcases /passwd -lgh | diff -q - $results /passwd || exit 1
2017-04-28 18:34:23 +00:00
# Permissions, and current users and groups
sudo -u cassowary $exa $testcases /permissions -lghR 2>& 1 | diff -q - $results /permissions_sudo || exit 1
$exa $testcases /permissions -lghR 2>& 1 | diff -q - $results /permissions || exit 1
2017-05-01 14:06:37 +00:00
# File names
2017-05-01 20:54:53 +00:00
# (Mostly escaping control characters in file names)
2017-08-11 11:36:14 +00:00
COLUMNS = 80 $exa $testcases /file-names 2>& 1 | diff -q - $results /file_names || exit 1
COLUMNS = 80 $exa $testcases /file-names -x 2>& 1 | diff -q - $results /file_names_x || exit 1
COLUMNS = 80 $exa $testcases /file-names -R 2>& 1 | diff -q - $results /file_names_R || exit 1
$exa $testcases /file-names -1 2>& 1 | diff -q - $results /file_names_1 || exit 1
$exa $testcases /file-names -T 2>& 1 | diff -q - $results /file_names_T || exit 1
$exa $testcases /file-names -T@ 2>& 1 | diff -q - $results /file_names_T@ || exit 1
2016-10-07 18:31:03 +00:00
2017-05-18 23:08:13 +00:00
# At least make sure it handles invalid UTF-8 arguments without crashing
2017-07-26 16:48:18 +00:00
$exa $testcases /file-names/* >/dev/null || exit 1
2017-05-18 23:08:13 +00:00
2017-06-29 13:03:17 +00:00
# Sorting and extension file types
2017-08-20 16:33:39 +00:00
$exa $testcases /file-names-exts -1 2>& 1 --sort= name | diff -q - $results /file-names-exts || exit 1
$exa $testcases /file-names-exts -1 2>& 1 --sort= Name | diff -q - $results /file-names-exts-case || exit 1
$exa $testcases /file-names-exts -1 2>& 1 --sort= ext | diff -q - $results /file-names-exts-ext || exit 1
$exa $testcases /file-names-exts -1 2>& 1 --sort= Ext | diff -q - $results /file-names-exts-ext-case || exit 1
2017-06-29 13:03:17 +00:00
2017-06-29 13:50:39 +00:00
# Pass multiple input arguments because there aren’ t enough of different types
# in one directory already
$exa $testcases /links -1 --sort= type 2>& 1 | diff -q - $results /sort-by-type || exit 1
2017-06-29 13:06:59 +00:00
# We can’ t guarantee inode numbers, but we can at least check that they’ re in
# order. The inode column is the leftmost one, so sort works for this.
$exa $testcases /file-names-exts --long --inode --sort= inode | sort --check || exit 1
2017-06-29 13:03:17 +00:00
# Other file types
2017-06-29 13:50:39 +00:00
$exa $testcases /specials -l 2>& 1 | diff -q - $results /specials || exit 1
$exa $testcases /specials -F -l 2>& 1 | diff -q - $results /specials_F || exit 1
$exa $testcases /specials --sort= type -1 2>& 1 | diff -q - $results /specials_sort || exit 1
2016-10-29 18:25:07 +00:00
2017-04-28 18:34:23 +00:00
2016-10-30 14:43:33 +00:00
# Ignores
2017-06-29 12:57:31 +00:00
$exa $testcases /file-names-exts/music.* -I "*.OGG" -1 2>& 1 | diff -q - $results /ignores_ogg || exit 1
$exa $testcases /file-names-exts/music.* -I "*.OGG|*.mp3" -1 2>& 1 | diff -q - $results /empty || exit 1
2016-10-30 14:43:33 +00:00
2016-10-29 18:58:34 +00:00
2017-07-05 21:07:03 +00:00
# Dates and times
$exa $testcases /dates -lh --accessed --sort= accessed 2>& 1 | diff -q - $results /dates_accessed || exit 1
$exa $testcases /dates -lh --sort= modified 2>& 1 | diff -q - $results /dates_modified || exit 1
2017-07-05 23:01:45 +00:00
$exa $testcases /dates -l --time-style= long-iso 2>& 1 | diff -q - $results /dates_long_iso || exit 1
2017-07-05 23:21:38 +00:00
$exa $testcases /dates -l --time-style= full-iso 2>& 1 | diff -q - $results /dates_full_iso || exit 1
2017-07-05 23:39:54 +00:00
$exa $testcases /dates -l --time-style= iso 2>& 1 | diff -q - $results /dates_iso || exit 1
2017-07-05 21:07:03 +00:00
2017-08-06 21:25:00 +00:00
# Locales
# These two are used in particular because they have 5-long and 4-long
# month names respectively
env LANG = fr_FR.UTF-8 $exa $testcases /dates -l | diff -q - $results /dates_fr || exit 1
env LANG = ja_JP.UTF-8 $exa $testcases /dates -l | diff -q - $results /dates_jp || exit 1
2017-07-05 21:07:03 +00:00
2017-04-29 09:56:17 +00:00
# Paths and directories
# These directories are created in the VM user’ s home directory (the default
# location) when a Cargo build is done.
2017-08-20 17:19:58 +00:00
( cd; mkdir -p target/debug/build
$exa -1d target target/debug target/debug/build | diff -q - $results /dir_paths) || exit 1
2017-04-29 10:52:44 +00:00
$exa -1d . .. / | diff -q - $results /dirs || exit 1
2017-04-29 09:56:17 +00:00
2017-04-28 18:34:23 +00:00
# Links
2017-08-11 11:36:14 +00:00
COLUMNS = 80 $exa $testcases /links 2>& 1 | diff -q - $results /links || exit 1
$exa $testcases /links -1 2>& 1 | diff -q - $results /links_1 || exit 1
$exa $testcases /links -T 2>& 1 | diff -q - $results /links_T || exit 1
$exa $testcases /links -T@ 2>& 1 | diff -q - $results /links_T@ || exit 1
$exa /proc/1/root -T 2>& 1 | diff -q - $results /proc_1_root || exit 1
$exa /proc/1/root -T@ 2>& 1 | diff -q - $results /proc_1_root_@ || exit 1
2016-10-29 19:27:23 +00:00
2017-05-15 21:38:23 +00:00
# There’ ve been bugs where the target file wasn’ t printed properly when the
# symlink file was specified on the command-line directly.
$exa $testcases /links/* -1 | diff -q - $results /links_1_files || exit 1
2016-10-07 18:31:03 +00:00
2017-06-25 13:51:44 +00:00
# Colours and terminals
# Just because COLUMNS is present, doesn’ t mean output is to a terminal
COLUMNS = 80 $exa_binary $testcases /files -l | diff -q - $results /files_l_bw || exit 1
COLUMNS = 80 $exa_binary --colour= always $testcases /files -l | diff -q - $results /files_l || exit 1
COLUMNS = 80 $exa_binary --colour= never $testcases /files -l | diff -q - $results /files_l_bw || exit 1
COLUMNS = 80 $exa_binary --colour= automatic $testcases /files -l | diff -q - $results /files_l_bw || exit 1
2017-05-17 08:17:12 +00:00
# Git
$exa $testcases /git/additions -l --git 2>& 1 | diff -q - $results /git_additions || exit 1
$exa $testcases /git/edits -l --git 2>& 1 | diff -q - $results /git_edits || exit 1
Override the names of . and ..
There was a problem when displaying . and .. in directory listings: their names would normalise to actual names! So instead of literally seeing `.`, you’d see the current directory’s name, inserted in sort order into the list of results. Obviously this is not what we want.
In unrelated news, putting `.` and `..` into the list of paths read from a directory just takes up more heap space for something that’s basically constant.
We can solve both these problems at once by moving the DotFilter to the files iterator in Dir, rather than at the Dir’s creation. Having the iterator know whether it should display `.` and `..` means it can emit those files first, and because it knows what those files really represent, it can override their file names to actually be those sequences of dots.
This is not a perfect solution: the main casualty is that a File can now be constructed with a name, some metadata, both, or neither. This is currently handled with a bunch of Options, and returns IOResult even without doing any IO operations.
But at least all the tests pass!
2017-06-28 17:41:31 +00:00
# Hidden files
COLUMNS = 80 $exa $testcases /hiddens 2>& 1 | diff -q - $results /hiddens || exit 1
COLUMNS = 80 $exa $testcases /hiddens -a 2>& 1 | diff -q - $results /hiddens_a || exit 1
COLUMNS = 80 $exa $testcases /hiddens -aa 2>& 1 | diff -q - $results /hiddens_aa || exit 1
$exa $testcases /hiddens -l 2>& 1 | diff -q - $results /hiddens_l || exit 1
$exa $testcases /hiddens -l -a 2>& 1 | diff -q - $results /hiddens_la || exit 1
$exa $testcases /hiddens -l -aa 2>& 1 | diff -q - $results /hiddens_laa || exit 1
2017-08-10 17:45:26 +00:00
# Errors
2017-08-10 22:34:39 +00:00
$exa --binary 2>& 1 | diff -q - $results /error_useless || exit 1
$exa --ternary 2>& 1 | diff -q - $results /error_long || exit 1
$exa -4 2>& 1 | diff -q - $results /error_short || exit 1
$exa --time 2>& 1 | diff -q - $results /error_value || exit 1
$exa --long= time 2>& 1 | diff -q - $results /error_overvalued || exit 1
2017-08-19 21:17:53 +00:00
$exa -l --long 2>& 1 | diff -q - $results /error_duplicate || exit 1
$exa -ll 2>& 1 | diff -q - $results /error_twice || exit 1
2017-08-10 17:45:26 +00:00
2017-08-19 12:57:56 +00:00
# Debug mode
# (uses an empty directory so it prints nothing to stdout)
2017-08-19 21:39:34 +00:00
EXA_DEBUG = "1" $exa $testcases /attributes/dirs/no-xattrs_empty -lh 2>& 1 | tail -n 2 | diff -q - $results /debug || exit 1
2017-08-19 12:57:56 +00:00
2017-06-23 20:22:48 +00:00
# And finally...
2017-06-23 21:03:58 +00:00
$exa --help | diff -q - $results /help || exit 1
$exa --help --long | diff -q - $results /help_long || exit 1
2017-05-17 08:17:12 +00:00
Override the names of . and ..
There was a problem when displaying . and .. in directory listings: their names would normalise to actual names! So instead of literally seeing `.`, you’d see the current directory’s name, inserted in sort order into the list of results. Obviously this is not what we want.
In unrelated news, putting `.` and `..` into the list of paths read from a directory just takes up more heap space for something that’s basically constant.
We can solve both these problems at once by moving the DotFilter to the files iterator in Dir, rather than at the Dir’s creation. Having the iterator know whether it should display `.` and `..` means it can emit those files first, and because it knows what those files really represent, it can override their file names to actually be those sequences of dots.
This is not a perfect solution: the main casualty is that a File can now be constructed with a name, some metadata, both, or neither. This is currently handled with a bunch of Options, and returns IOResult even without doing any IO operations.
But at least all the tests pass!
2017-06-28 17:41:31 +00:00
2016-10-07 18:31:03 +00:00
echo "All the tests passed!"