mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 04:58:57 +00:00
make testing on local servers hermetic
I noticed while fixing issue #2702 that the fish program being tested was sourcing config.fish files outside of the current build. This also happens when Travis CI runs the tests but isn't an issue there because of how Travis is configured to execute the tests. I also noticed that running `make test` was polluting my personal fish history; which will become a bigger problem if and when the fishd universal var file is moved from $XDG_CONFIG_HOME to $XDG_DATA_HOME. This change makes it possible for an individual to run the tests on their local machine secure in the knowledge that only the config.fish and related files from their git repository will be used and doing so won't pollute their personal fish history. Resolves #469
This commit is contained in:
parent
c79ade9627
commit
8b67a1b26f
15 changed files with 155 additions and 142 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -31,8 +31,7 @@ share/man/
|
||||||
toc.txt
|
toc.txt
|
||||||
user_doc/
|
user_doc/
|
||||||
xcuserdata
|
xcuserdata
|
||||||
tests/*tmp.*
|
test/
|
||||||
tests/foo.txt
|
|
||||||
FISH-BUILD-VERSION-FILE
|
FISH-BUILD-VERSION-FILE
|
||||||
version
|
version
|
||||||
messages.pot
|
messages.pot
|
||||||
|
@ -40,4 +39,3 @@ lexicon.txt
|
||||||
lexicon_filter
|
lexicon_filter
|
||||||
lexicon.log
|
lexicon.log
|
||||||
DerivedData/
|
DerivedData/
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ script:
|
||||||
- ./configure --prefix=$HOME/prefix || cat config.log
|
- ./configure --prefix=$HOME/prefix || cat config.log
|
||||||
- make -j2
|
- make -j2
|
||||||
- make install
|
- make install
|
||||||
- make test SHOW_INTERACTIVE_LOG=1
|
- make test DESTDIR=$HOME/prefix/ SHOW_INTERACTIVE_LOG=1
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
# Some items are encrypted so that notifications from other repositories
|
# Some items are encrypted so that notifications from other repositories
|
||||||
|
|
125
Makefile.in
125
Makefile.in
|
@ -23,6 +23,11 @@
|
||||||
# applications, install them, and recalculate dependencies.
|
# applications, install them, and recalculate dependencies.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# This is the default value for SHELL but I like to be explicit about such
|
||||||
|
# things. Especially in a project like fish where someone might otherwise
|
||||||
|
# think fish will be used to execute make recipes.
|
||||||
|
SHELL = /bin/sh
|
||||||
|
|
||||||
# Used by docdir
|
# Used by docdir
|
||||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||||
|
|
||||||
|
@ -113,7 +118,6 @@ BUILTIN_FILES := src/builtin_set.cpp src/builtin_commandline.cpp \
|
||||||
#
|
#
|
||||||
# All objects that the system needs to build fish_tests
|
# All objects that the system needs to build fish_tests
|
||||||
#
|
#
|
||||||
|
|
||||||
FISH_TESTS_OBJS := $(FISH_OBJS) obj/fish_tests.o
|
FISH_TESTS_OBJS := $(FISH_OBJS) obj/fish_tests.o
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,12 +295,29 @@ doc/refman.pdf: doc
|
||||||
mv refman.pdf ..;
|
mv refman.pdf ..;
|
||||||
rm -r doc/latex;
|
rm -r doc/latex;
|
||||||
|
|
||||||
|
# Prep the environment for running the unit tests. When specifying DESTDIR on
|
||||||
|
# the command line (e.g., `make DESTDIR=/usr/local/`) you must have previously
|
||||||
|
# installed fish using the same prefix; e.g., `./configure --prefix=/usr/local`
|
||||||
|
# followed by `make install`.
|
||||||
|
test-prep:
|
||||||
|
rm -rf test
|
||||||
|
mkdir test test/data test/home test/temp
|
||||||
|
ifdef DESTDIR
|
||||||
|
ln -s $(DESTDIR) test/root
|
||||||
|
else
|
||||||
|
mkdir test/root
|
||||||
|
endif
|
||||||
|
.PHONY: test-prep
|
||||||
|
|
||||||
|
# The test target runs both the low level code tests and the high level script
|
||||||
|
# tests.
|
||||||
#
|
#
|
||||||
# This target runs both the low level code tests and the high level script tests.
|
# Note that doing `make DESTDIR=/some/path/ test` overrides this assignment.
|
||||||
#
|
test: DESTDIR = $(PWD)/test/root/
|
||||||
|
test: prefix = .
|
||||||
test: test_low_level test_high_level
|
test: test-prep install-force test_low_level test_high_level
|
||||||
|
@rm -f /tmp/file_truncation_test.txt /tmp/tee_test.txt /tmp/fish_foo.txt
|
||||||
|
@rm -rf /tmp/is_potential_path_test
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
|
|
||||||
# We want the various tests to run serially so their output doesn't mix
|
# We want the various tests to run serially so their output doesn't mix
|
||||||
|
@ -319,12 +340,12 @@ test_low_level: fish_tests $(call filter_up_to,test_low_level,$(active_test_goal
|
||||||
test_high_level: test_fishscript test_interactive
|
test_high_level: test_fishscript test_interactive
|
||||||
.PHONY: test_high_level
|
.PHONY: test_high_level
|
||||||
|
|
||||||
test_fishscript: $(PROGRAMS) $(call filter_up_to,test_fishscript,$(active_test_goals))
|
test_fishscript: $(call filter_up_to,test_fishscript,$(active_test_goals))
|
||||||
cd tests && ../fish test.fish
|
cd tests; ../test/root/bin/fish test.fish
|
||||||
.PHONY: test_fishscript
|
.PHONY: test_fishscript
|
||||||
|
|
||||||
test_interactive: $(PROGRAMS) $(call filter_up_to,test_interactive,$(active_test_goals))
|
test_interactive: $(call filter_up_to,test_interactive,$(active_test_goals))
|
||||||
cd tests && ../fish interactive.fish
|
cd tests; ../test/root/bin/fish interactive.fish
|
||||||
.PHONY: test_interactive
|
.PHONY: test_interactive
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -582,7 +603,6 @@ check-legacy-binaries:
|
||||||
@true;
|
@true;
|
||||||
.PHONY: check-legacy-binaries
|
.PHONY: check-legacy-binaries
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# This check makes sure that the install-sh script is executable. The
|
# This check makes sure that the install-sh script is executable. The
|
||||||
# darcs repo doesn't preserve the executable bit, so this needs to be
|
# darcs repo doesn't preserve the executable bit, so this needs to be
|
||||||
|
@ -593,12 +613,30 @@ install-sh:
|
||||||
if test -x $@; then true; else chmod 755 $@; fi
|
if test -x $@; then true; else chmod 755 $@; fi
|
||||||
.PHONY: install-sh
|
.PHONY: install-sh
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Try to install after checking for incompatible installed versions.
|
# Try to install after checking for incompatible installed versions.
|
||||||
#
|
#
|
||||||
|
|
||||||
install: all install-sh check-uninstall install-force check-legacy-binaries
|
install: all install-sh check-uninstall install-force check-legacy-binaries
|
||||||
|
@echo fish is now installed on your system.
|
||||||
|
@echo To run fish, type \'fish\' in your terminal.
|
||||||
|
@echo
|
||||||
|
@if type chsh >/dev/null 2>&1; then \
|
||||||
|
echo To use fish as your login shell:; \
|
||||||
|
grep -q -- "$(DESTDIR)$(bindir)/fish" /etc/shells || echo \* add the line \'$(DESTDIR)$(bindir)/fish\' to the file \'/etc/shells\'.; \
|
||||||
|
echo \* use the command \'chsh -s $(DESTDIR)$(bindir)/fish\'.; \
|
||||||
|
echo; \
|
||||||
|
fi;
|
||||||
|
@if type chcon >/dev/null 2>&1; then \
|
||||||
|
echo If you have SELinux enabled, you may need to manually update the security policy:; \
|
||||||
|
echo \* use the command \'chcon -t shell_exec_t $(DESTDIR)$(bindir)/fish\'.; \
|
||||||
|
echo; \
|
||||||
|
fi;
|
||||||
|
@echo To set your colors, run \'fish_config\'
|
||||||
|
@echo To scan your man pages for completions, run \'fish_update_completions\'
|
||||||
|
@echo To autocomplete command suggestions press Ctrl + F or right arrow key.
|
||||||
|
@echo
|
||||||
|
@echo Have fun!
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -611,11 +649,10 @@ xcode-install:
|
||||||
.PHONY: xcode-install
|
.PHONY: xcode-install
|
||||||
|
|
||||||
#
|
#
|
||||||
# Force installation, even in presense of incompatible previous
|
# Force installation, even in presense of incompatible previous version. This
|
||||||
# version. This may fail.
|
# may fail. These 'true' lines are to prevent installs from failing for (e.g.)
|
||||||
# These 'true' lines are to prevent installs from failing for (e.g.) missing man pages.
|
# missing man pages.
|
||||||
#
|
#
|
||||||
|
|
||||||
install-force: all install-translations
|
install-force: all install-translations
|
||||||
$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
|
$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
|
||||||
for i in $(PROGRAMS); do\
|
for i in $(PROGRAMS); do\
|
||||||
|
@ -685,25 +722,6 @@ install-force: all install-translations
|
||||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(mandir)/man1/; \
|
$(INSTALL) -m 644 $$i $(DESTDIR)$(mandir)/man1/; \
|
||||||
true; \
|
true; \
|
||||||
done;
|
done;
|
||||||
@echo fish is now installed on your system.
|
|
||||||
@echo To run fish, type \'fish\' in your terminal.
|
|
||||||
@echo
|
|
||||||
@if type chsh >/dev/null 2>&1; then \
|
|
||||||
echo To use fish as your login shell:; \
|
|
||||||
grep -q -- "$(DESTDIR)$(bindir)/fish" /etc/shells || echo \* add the line \'$(DESTDIR)$(bindir)/fish\' to the file \'/etc/shells\'.; \
|
|
||||||
echo \* use the command \'chsh -s $(DESTDIR)$(bindir)/fish\'.; \
|
|
||||||
echo; \
|
|
||||||
fi;
|
|
||||||
@if type chcon >/dev/null 2>&1; then \
|
|
||||||
echo If you have SELinux enabled, you may need to manually update the security policy:; \
|
|
||||||
echo \* use the command \'chcon -t shell_exec_t $(DESTDIR)$(bindir)/fish\'.; \
|
|
||||||
echo; \
|
|
||||||
fi;
|
|
||||||
@echo To set your colors, run \'fish_config\'
|
|
||||||
@echo To scan your man pages for completions, run \'fish_update_completions\'
|
|
||||||
@echo To autocomplete command suggestions press Ctrl + F or right arrow key.
|
|
||||||
@echo
|
|
||||||
@echo Have fun!
|
|
||||||
.PHONY: install-force
|
.PHONY: install-force
|
||||||
|
|
||||||
|
|
||||||
|
@ -781,7 +799,7 @@ uninstall-translations:
|
||||||
#
|
#
|
||||||
obj/%.o: src/%.cpp | obj
|
obj/%.o: src/%.cpp | obj
|
||||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
#
|
#
|
||||||
# obj directory
|
# obj directory
|
||||||
#
|
#
|
||||||
|
@ -801,27 +819,21 @@ $(PCRE2_LIB): $(PCRE2_H)
|
||||||
$(PCRE2_H):
|
$(PCRE2_H):
|
||||||
(cd $(PCRE2_DIR) && ./config.status --enable-maintainer-mode)
|
(cd $(PCRE2_DIR) && ./config.status --enable-maintainer-mode)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build the fish_tests program.
|
# Build the fish_tests program.
|
||||||
#
|
#
|
||||||
|
|
||||||
fish_tests: $(FISH_TESTS_OBJS) $(EXTRA_PCRE2)
|
fish_tests: $(FISH_TESTS_OBJS) $(EXTRA_PCRE2)
|
||||||
$(CXX) $(CXXFLAGS) $(LDFLAGS_FISH) $(FISH_TESTS_OBJS) $(LIBS) -o $@
|
$(CXX) $(CXXFLAGS) $(LDFLAGS_FISH) $(FISH_TESTS_OBJS) $(LIBS) -o $@
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build the fish_indent program.
|
# Build the fish_indent program.
|
||||||
#
|
#
|
||||||
|
|
||||||
fish_indent: $(FISH_INDENT_OBJS) $(EXTRA_PCRE2)
|
fish_indent: $(FISH_INDENT_OBJS) $(EXTRA_PCRE2)
|
||||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(FISH_INDENT_OBJS) $(LIBS) -o $@
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(FISH_INDENT_OBJS) $(LIBS) -o $@
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Neat little program to show output from terminal
|
# Neat little program to show output from terminal
|
||||||
#
|
#
|
||||||
|
|
||||||
key_reader: $(FISH_OBJS) $(EXTRA_PCRE2) obj/key_reader.o
|
key_reader: $(FISH_OBJS) $(EXTRA_PCRE2) obj/key_reader.o
|
||||||
$(CXX) $(CXXFLAGS) $(LDFLAGS_FISH) $^ $(LIBS) -o $@
|
$(CXX) $(CXXFLAGS) $(LDFLAGS_FISH) $^ $(LIBS) -o $@
|
||||||
|
|
||||||
|
@ -860,41 +872,34 @@ _iwyu: clean $(PROGRAMS)
|
||||||
# Cleanup targets
|
# Cleanup targets
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
# Restore the source tree to the state right after extracting a tarball.
|
||||||
# distclean should restore the tree to the state right after extracting a tarball.
|
|
||||||
#
|
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(MAKE) -C $(PCRE2_DIR) distclean
|
$(MAKE) -C $(PCRE2_DIR) distclean || true
|
||||||
rm -f config.status config.log config.h Makefile
|
rm -f config.status config.log config.h Makefile
|
||||||
.PHONY: distclean
|
.PHONY: distclean
|
||||||
|
|
||||||
|
|
||||||
|
# Remove everything built by the Makefile, but not things that are created by
|
||||||
|
# the configure script.
|
||||||
#
|
#
|
||||||
# clean removes everything built by the makefile, but not things that
|
# Don't delete the docs unless we have Doxygen installed We provide pre-built
|
||||||
# are created by the configure script.
|
# docs in the tarball, and if they get deleted we won't be able to regenerate
|
||||||
#
|
# them.
|
||||||
|
|
||||||
# Don't delete the docs unless we have Doxygen installed
|
|
||||||
# We provide pre-built docs in the tarball, and if they get
|
|
||||||
# deleted we won't be able to regenerate them
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
ifdef EXTRA_PCRE2
|
$(MAKE) -C $(PCRE2_DIR) clean || true
|
||||||
$(MAKE) -C $(PCRE2_DIR) clean
|
rm -f obj/*.o *.o doc.h doc.tmp
|
||||||
endif
|
rm -f doc_src/*.doxygen doc_src/*.cpp doc_src/*.o doc_src/commands.hdr
|
||||||
rm -f obj/*.o *.o doc.h doc.tmp doc_src/*.doxygen doc_src/*.cpp doc_src/*.o doc_src/commands.hdr
|
|
||||||
rm -f tests/tmp.err tests/tmp.out tests/tmp.status tests/foo.txt
|
rm -f tests/tmp.err tests/tmp.out tests/tmp.status tests/foo.txt
|
||||||
rm -f $(PROGRAMS) fish_tests key_reader
|
rm -f $(PROGRAMS) fish_tests key_reader
|
||||||
rm -f command_list.txt command_list_toc.txt toc.txt
|
rm -f command_list.txt command_list_toc.txt toc.txt
|
||||||
rm -f doc_src/index.hdr doc_src/commands.hdr
|
rm -f doc_src/index.hdr doc_src/commands.hdr
|
||||||
rm -f lexicon_filter lexicon.txt lexicon.log
|
rm -f lexicon_filter lexicon.txt lexicon.log
|
||||||
rm -f FISH-BUILD-VERSION-FILE
|
rm -f FISH-BUILD-VERSION-FILE fish.pc
|
||||||
if test "$(HAVE_DOXYGEN)" = 1; then \
|
if test "$(HAVE_DOXYGEN)" = 1; then \
|
||||||
rm -rf doc user_doc share/man; \
|
rm -rf doc user_doc share/man; \
|
||||||
fi
|
fi
|
||||||
rm -f po/*.gmo
|
rm -f po/*.gmo
|
||||||
rm -rf obj
|
rm -rf obj build test
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
|
|
||||||
|
|
25
README.md
25
README.md
|
@ -52,6 +52,31 @@ On RedHat, CentOS, or Amazon EC2:
|
||||||
|
|
||||||
sudo yum install ncurses-devel
|
sudo yum install ncurses-devel
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
### Travis CI Build and Test
|
||||||
|
|
||||||
|
You can have the Travis continuous integration tool automatically build and test your changes. This requires you to fork the project on GitHub or have pushed your local fish-shell repository to GitHub.
|
||||||
|
|
||||||
|
Login to [Travis CI](https://travis-ci.org/) with your GitHub account and enable your fish-shell clone. To reach that page click the plus-sign to the right of "My Repositories" on the main page for your account or go to your [profile page](https://travis-ci.org/profile/). After you do that every time you push changes to GitHub Travis will automatically build and test those changes. You'll receive an email when the tests are complete telling you whether or not any tests failed. This helps avoid being embarrassed by making a pull-request only to find you introduced a bug or failed to update a unit test. This also ensures that even if you can build and run fish on your system that it can also be built and run on other types of systems.
|
||||||
|
|
||||||
|
You'll find the configuration used to control Travis in the `.travis.yml` file.
|
||||||
|
|
||||||
|
### Running the Tests On Your Local Server
|
||||||
|
|
||||||
|
You should not build and install fish using the instructions above after
|
||||||
|
making changs until you've run the tests. You may or may not need to create an
|
||||||
|
appropriate `Makefile` by running the following one time:
|
||||||
|
|
||||||
|
autoconf
|
||||||
|
./configure
|
||||||
|
|
||||||
|
To run the unit tests:
|
||||||
|
|
||||||
|
make test
|
||||||
|
|
||||||
|
Note: These instructions will work on Mac OS X as well as Linux but do require that you've used something like [Homebrew](http://brew.sh/) to install autoconf and related tools.
|
||||||
|
|
||||||
## Runtime Dependencies
|
## Runtime Dependencies
|
||||||
|
|
||||||
fish requires a curses implementation, such as ncurses, to run.
|
fish requires a curses implementation, such as ncurses, to run.
|
||||||
|
|
|
@ -94,7 +94,7 @@ set tmpdir $PWD
|
||||||
cd $saved
|
cd $saved
|
||||||
mkdir $tmpdir/realhome
|
mkdir $tmpdir/realhome
|
||||||
ln -s $tmpdir/realhome $tmpdir/linkhome
|
ln -s $tmpdir/realhome $tmpdir/linkhome
|
||||||
set expandedtilde (env HOME=$tmpdir/linkhome ../fish -c 'echo ~')
|
set expandedtilde (env HOME=$tmpdir/linkhome ../test/root/bin/fish -c 'echo ~')
|
||||||
if test $expandedtilde != $tmpdir/realhome
|
if test $expandedtilde != $tmpdir/realhome
|
||||||
echo '~ expands to' $expandedtilde ' - expected ' $tmpdir/realhome
|
echo '~ expands to' $expandedtilde ' - expected ' $tmpdir/realhome
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ echo hi
|
||||||
|
|
||||||
|
|
||||||
end | cat | cat | begin ; echo hi ; end | begin ; begin ; echo hi ; end ; end arg
|
end | cat | cat | begin ; echo hi ; end | begin ; begin ; echo hi ; end ; end arg
|
||||||
' | ../fish_indent
|
' | ../test/root/bin/fish_indent
|
||||||
|
|
||||||
echo \nTest2
|
echo \nTest2
|
||||||
echo -n '
|
echo -n '
|
||||||
|
@ -18,7 +18,7 @@ switch aloha
|
||||||
echo hi
|
echo hi
|
||||||
|
|
||||||
end
|
end
|
||||||
' | ../fish_indent
|
' | ../test/root/bin/fish_indent
|
||||||
|
|
||||||
echo \nTest3
|
echo \nTest3
|
||||||
echo -n '
|
echo -n '
|
||||||
|
@ -32,8 +32,8 @@ function hello_world
|
||||||
echo hello;
|
echo hello;
|
||||||
|
|
||||||
echo hello
|
echo hello
|
||||||
end
|
end
|
||||||
' | ../fish_indent
|
' | ../test/root/bin/fish_indent
|
||||||
|
|
||||||
echo \nTest4
|
echo \nTest4
|
||||||
echo -n '
|
echo -n '
|
||||||
|
@ -53,7 +53,7 @@ switch foo #abc
|
||||||
qqq
|
qqq
|
||||||
case "*"
|
case "*"
|
||||||
echo sup
|
echo sup
|
||||||
end' | ../fish_indent
|
end' | ../test/root/bin/fish_indent
|
||||||
|
|
||||||
echo \nTest5
|
echo \nTest5
|
||||||
echo -n '
|
echo -n '
|
||||||
|
@ -65,7 +65,7 @@ switch beta
|
||||||
echo delta
|
echo delta
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
' | ../fish_indent -i
|
' | ../test/root/bin/fish_indent -i
|
||||||
|
|
||||||
echo \nTest6
|
echo \nTest6
|
||||||
# Test errors
|
# Test errors
|
||||||
|
@ -75,11 +75,11 @@ echo hi
|
||||||
else
|
else
|
||||||
echo bye
|
echo bye
|
||||||
end; echo alpha "
|
end; echo alpha "
|
||||||
' | ../fish_indent
|
' | ../test/root/bin/fish_indent
|
||||||
|
|
||||||
echo \nTest7
|
echo \nTest7
|
||||||
# issue 1665
|
# issue 1665
|
||||||
echo -n '
|
echo -n '
|
||||||
if begin ; false; end; echo hi ; end
|
if begin ; false; end; echo hi ; end
|
||||||
while begin ; false; end; echo hi ; end
|
while begin ; false; end; echo hi ; end
|
||||||
' | ../fish_indent
|
' | ../test/root/bin/fish_indent
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
log_user 0
|
log_user 0
|
||||||
log_file -noappend interactive.tmp.log
|
log_file -noappend interactive.tmp.log
|
||||||
|
|
||||||
set fish ../fish
|
set fish ../test/root/bin/fish
|
||||||
|
|
||||||
set timeout 5
|
set timeout 5
|
||||||
|
|
||||||
|
|
15
tests/interactive.fish
Executable file → Normal file
15
tests/interactive.fish
Executable file → Normal file
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/local/bin/fish
|
|
||||||
#
|
|
||||||
# Interactive tests using `expect`
|
# Interactive tests using `expect`
|
||||||
|
#
|
||||||
|
# There is no shebang line because you shouldn't be running this by hand. You
|
||||||
|
# should be running it via `make test` to ensure the environment is properly
|
||||||
|
# setup.
|
||||||
|
|
||||||
# Change to directory containing this script
|
# Change to directory containing this script
|
||||||
cd (dirname (status -f))
|
cd (dirname (status -f))
|
||||||
|
@ -13,6 +15,7 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
source test_util.fish (status -f) $argv; or exit
|
source test_util.fish (status -f) $argv; or exit
|
||||||
|
cat interactive.config >> $XDG_CONFIG_HOME/fish/config.fish
|
||||||
|
|
||||||
say -o cyan "Testing interactive functionality"
|
say -o cyan "Testing interactive functionality"
|
||||||
if not type -q expect
|
if not type -q expect
|
||||||
|
@ -21,17 +24,9 @@ if not type -q expect
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_file
|
function test_file
|
||||||
rm -Rf tmp.interactive.config; or die "Couldn't remove tmp.interactive.config"
|
|
||||||
mkdir -p tmp.interactive.config/fish; or die "Couldn't create tmp.interactive.config/fish"
|
|
||||||
cat $XDG_CONFIG_HOME/fish/config.fish interactive.config > tmp.interactive.config/fish/config.fish
|
|
||||||
or die "Couldn't create tmp.interactive.config/fish/config.fish"
|
|
||||||
|
|
||||||
set -l file $argv[1]
|
set -l file $argv[1]
|
||||||
|
|
||||||
echo -n "Testing file $file ... "
|
echo -n "Testing file $file ... "
|
||||||
|
|
||||||
begin
|
begin
|
||||||
set -lx XDG_CONFIG_HOME $PWD/tmp.interactive.config
|
|
||||||
set -lx TERM dumb
|
set -lx TERM dumb
|
||||||
expect -n -c 'source interactive.expect.rc' -f $file >$file.tmp.out ^$file.tmp.err
|
expect -n -c 'source interactive.expect.rc' -f $file >$file.tmp.out ^$file.tmp.err
|
||||||
end
|
end
|
||||||
|
|
8
tests/test.fish
Executable file → Normal file
8
tests/test.fish
Executable file → Normal file
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/local/bin/fish
|
|
||||||
#
|
|
||||||
# Fishscript tests
|
# Fishscript tests
|
||||||
|
#
|
||||||
|
# There is no shebang line because you shouldn't be running this by hand. You
|
||||||
|
# should be running it via `make test` to ensure the environment is properly
|
||||||
|
# setup.
|
||||||
|
|
||||||
# Change to directory containing this script
|
# Change to directory containing this script
|
||||||
cd (dirname (status -f))
|
cd (dirname (status -f))
|
||||||
|
@ -22,7 +24,7 @@ function test_file
|
||||||
|
|
||||||
echo -n "Testing file $file ... "
|
echo -n "Testing file $file ... "
|
||||||
|
|
||||||
../fish <$file >$base.tmp.out ^$base.tmp.err
|
../test/root/bin/fish <$file >$base.tmp.out ^$base.tmp.err
|
||||||
set -l tmp_status $status
|
set -l tmp_status $status
|
||||||
set -l res ok
|
set -l res ok
|
||||||
|
|
||||||
|
|
|
@ -33,12 +33,12 @@ end
|
||||||
# Simple alias tests
|
# Simple alias tests
|
||||||
|
|
||||||
function foo
|
function foo
|
||||||
echo >foo.txt $argv
|
echo >../test/temp/fish_foo.txt $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
foo hello
|
foo hello
|
||||||
|
|
||||||
cat foo.txt |read foo
|
cat ../test/temp/fish_foo.txt |read foo
|
||||||
|
|
||||||
if test $foo = hello;
|
if test $foo = hello;
|
||||||
echo Test 2 pass
|
echo Test 2 pass
|
||||||
|
@ -102,7 +102,7 @@ echo Test 5 $sta
|
||||||
# Verify that we can turn stderr into stdout and then pipe it.
|
# Verify that we can turn stderr into stdout and then pipe it.
|
||||||
# Note that the order here seems unspecified - 'errput' appears before 'output', why?
|
# Note that the order here seems unspecified - 'errput' appears before 'output', why?
|
||||||
echo Test redirections
|
echo Test redirections
|
||||||
begin ; echo output ; echo errput 1>&2 ; end 2>&1 | tee /tmp/tee_test.txt ; cat /tmp/tee_test.txt
|
begin ; echo output ; echo errput 1>&2 ; end 2>&1 | tee ../test/temp/tee_test.txt ; cat ../test/temp/tee_test.txt
|
||||||
|
|
||||||
# Verify that we can pipe something other than stdout
|
# Verify that we can pipe something other than stdout
|
||||||
# The first line should be printed, since we output to stdout but pipe stderr to /dev/null
|
# The first line should be printed, since we output to stdout but pipe stderr to /dev/null
|
||||||
|
@ -148,7 +148,7 @@ echo "/bin/echo pipe 12 <&12 12<&-" | source 12<&0
|
||||||
|
|
||||||
# Make sure while loops don't run forever with no-exec (#1543)
|
# Make sure while loops don't run forever with no-exec (#1543)
|
||||||
echo "Checking for infinite loops in no-execute"
|
echo "Checking for infinite loops in no-execute"
|
||||||
echo "while true; end" | ../fish --no-execute
|
echo "while true; end" | ../test/root/bin/fish --no-execute
|
||||||
|
|
||||||
# Comments allowed in between lines (#1987)
|
# Comments allowed in between lines (#1987)
|
||||||
echo before comment \
|
echo before comment \
|
||||||
|
|
|
@ -96,7 +96,7 @@ echo Test 7 $res
|
||||||
set -e t8
|
set -e t8
|
||||||
if true
|
if true
|
||||||
set -lx t8 foo
|
set -lx t8 foo
|
||||||
if test (../fish -c "echo $t8") = foo
|
if test (../test/root/bin/fish -c "echo $t8") = foo
|
||||||
echo Test 8 pass
|
echo Test 8 pass
|
||||||
else
|
else
|
||||||
echo Test 8 fail
|
echo Test 8 fail
|
||||||
|
@ -105,7 +105,7 @@ end
|
||||||
|
|
||||||
# Test if exported variables go out of scope
|
# Test if exported variables go out of scope
|
||||||
|
|
||||||
if test (../fish -c "echo $t8")
|
if test (../test/root/bin/fish -c "echo $t8")
|
||||||
echo Test 9 fail
|
echo Test 9 fail
|
||||||
else
|
else
|
||||||
echo Test 9 pass
|
echo Test 9 pass
|
||||||
|
@ -142,7 +142,7 @@ set -ge __fish_test_universal_variables_variable_foo
|
||||||
set -Ue __fish_test_universal_variables_variable_foo
|
set -Ue __fish_test_universal_variables_variable_foo
|
||||||
set -Ux __fish_test_universal_variables_variable_foo bar
|
set -Ux __fish_test_universal_variables_variable_foo bar
|
||||||
set __fish_test_universal_variables_variable_foo baz
|
set __fish_test_universal_variables_variable_foo baz
|
||||||
if test (/bin/sh -c 'echo $__fish_test_universal_variables_variable_foo') = baz -a (../fish -c 'echo $__fish_test_universal_variables_variable_foo') = baz
|
if test (/bin/sh -c 'echo $__fish_test_universal_variables_variable_foo') = baz -a (../test/root/bin/fish -c 'echo $__fish_test_universal_variables_variable_foo') = baz
|
||||||
echo Test 12 pass
|
echo Test 12 pass
|
||||||
else
|
else
|
||||||
echo Test 12 fail
|
echo Test 12 fail
|
||||||
|
@ -155,7 +155,7 @@ env | __fish_sgrep __fish_test_universal_variables_variable_foo
|
||||||
|
|
||||||
set -Ux __fish_test_universal_variables_variable_foo bar
|
set -Ux __fish_test_universal_variables_variable_foo bar
|
||||||
set -U __fish_test_universal_variables_variable_foo baz
|
set -U __fish_test_universal_variables_variable_foo baz
|
||||||
if test (/bin/sh -c 'echo $__fish_test_universal_variables_variable_foo') = baz -a (../fish -c 'echo $__fish_test_universal_variables_variable_foo') = baz
|
if test (/bin/sh -c 'echo $__fish_test_universal_variables_variable_foo') = baz -a (../test/root/bin/fish -c 'echo $__fish_test_universal_variables_variable_foo') = baz
|
||||||
echo Test 13 pass
|
echo Test 13 pass
|
||||||
else
|
else
|
||||||
echo Test 13 fail
|
echo Test 13 fail
|
||||||
|
@ -163,7 +163,7 @@ end
|
||||||
|
|
||||||
set -Ux __fish_test_universal_variables_variable_foo bar
|
set -Ux __fish_test_universal_variables_variable_foo bar
|
||||||
set -u __fish_test_universal_variables_variable_foo bar
|
set -u __fish_test_universal_variables_variable_foo bar
|
||||||
if test (/bin/sh -c 'echo $__fish_test_universal_variables_variable_foo') = '' -a (../fish -c 'echo $__fish_test_universal_variables_variable_foo') = bar
|
if test (/bin/sh -c 'echo $__fish_test_universal_variables_variable_foo') = '' -a (../test/root/bin/fish -c 'echo $__fish_test_universal_variables_variable_foo') = bar
|
||||||
echo Test 14 pass
|
echo Test 14 pass
|
||||||
else
|
else
|
||||||
echo Test 14 fail
|
echo Test 14 fail
|
||||||
|
@ -171,7 +171,7 @@ end
|
||||||
|
|
||||||
set -Ux __fish_test_universal_variables_variable_foo bar
|
set -Ux __fish_test_universal_variables_variable_foo bar
|
||||||
set -Uu __fish_test_universal_variables_variable_foo baz
|
set -Uu __fish_test_universal_variables_variable_foo baz
|
||||||
if test (/bin/sh -c 'echo $__fish_test_universal_variables_variable_foo') = '' -a (../fish -c 'echo $__fish_test_universal_variables_variable_foo') = baz
|
if test (/bin/sh -c 'echo $__fish_test_universal_variables_variable_foo') = '' -a (../test/root/bin/fish -c 'echo $__fish_test_universal_variables_variable_foo') = baz
|
||||||
echo Test 15 pass
|
echo Test 15 pass
|
||||||
else
|
else
|
||||||
echo Test 15 fail
|
echo Test 15 fail
|
||||||
|
@ -242,35 +242,35 @@ set -eU __fish_test_universal_variables_variable_foo
|
||||||
# Test behavior of universals on startup (#1526)
|
# Test behavior of universals on startup (#1526)
|
||||||
echo Testing Universal Startup
|
echo Testing Universal Startup
|
||||||
set -U testu 0
|
set -U testu 0
|
||||||
../fish -c 'set -U testu 1'
|
../test/root/bin/fish -c 'set -U testu 1'
|
||||||
echo $testu
|
echo $testu
|
||||||
../fish -c 'echo $testu'
|
../test/root/bin/fish -c 'echo $testu'
|
||||||
|
|
||||||
../fish -c 'set -U testu 2'
|
../test/root/bin/fish -c 'set -U testu 2'
|
||||||
echo $testu
|
echo $testu
|
||||||
../fish -c 'echo $testu'
|
../test/root/bin/fish -c 'echo $testu'
|
||||||
|
|
||||||
../fish -c 'set -e testu';
|
../test/root/bin/fish -c 'set -e testu';
|
||||||
echo Missing: $testu
|
echo Missing: $testu
|
||||||
../fish -c 'echo Missing: $testu'
|
../test/root/bin/fish -c 'echo Missing: $testu'
|
||||||
|
|
||||||
# test SHLVL
|
# test SHLVL
|
||||||
# use a subshell to ensure a clean slate
|
# use a subshell to ensure a clean slate
|
||||||
env SHLVL= ../fish -c 'echo SHLVL: $SHLVL; ../fish -c \'echo SHLVL: $SHLVL\''
|
env SHLVL= ../test/root/bin/fish -c 'echo SHLVL: $SHLVL; ../test/root/bin/fish -c \'echo SHLVL: $SHLVL\''
|
||||||
# exec should decrement SHLVL
|
# exec should decrement SHLVL
|
||||||
env SHLVL= ../fish -c 'echo SHLVL: $SHLVL; exec ../fish -c \'echo SHLVL: $SHLVL\''
|
env SHLVL= ../test/root/bin/fish -c 'echo SHLVL: $SHLVL; exec ../test/root/bin/fish -c \'echo SHLVL: $SHLVL\''
|
||||||
# garbage SHLVLs should be treated as garbage
|
# garbage SHLVLs should be treated as garbage
|
||||||
env SHLVL=3foo ../fish -c 'echo SHLVL: $SHLVL'
|
env SHLVL=3foo ../test/root/bin/fish -c 'echo SHLVL: $SHLVL'
|
||||||
# whitespace is allowed though (for bash compatibility)
|
# whitespace is allowed though (for bash compatibility)
|
||||||
env SHLVL="3 " ../fish -c 'echo SHLVL: $SHLVL'
|
env SHLVL="3 " ../test/root/bin/fish -c 'echo SHLVL: $SHLVL'
|
||||||
env SHLVL=" 3" ../fish -c 'echo SHLVL: $SHLVL'
|
env SHLVL=" 3" ../test/root/bin/fish -c 'echo SHLVL: $SHLVL'
|
||||||
|
|
||||||
# Test transformation of inherited variables
|
# Test transformation of inherited variables
|
||||||
env DISPLAY="localhost:0.0" ../fish -c 'echo Elements in DISPLAY: (count $DISPLAY)'
|
env DISPLAY="localhost:0.0" ../test/root/bin/fish -c 'echo Elements in DISPLAY: (count $DISPLAY)'
|
||||||
# We can't use PATH for this because the global configuration will modify PATH
|
# We can't use PATH for this because the global configuration will modify PATH
|
||||||
# based on /etc/paths and /etc/paths.d.
|
# based on /etc/paths and /etc/paths.d.
|
||||||
# Exported arrays should use record separator, with a few exceptions. So we can use an arbitrary variable for this.
|
# Exported arrays should use record separator, with a few exceptions. So we can use an arbitrary variable for this.
|
||||||
env FOO=one\x1etwo\x1ethree\x1efour ../fish -c 'echo Elements in FOO: (count $FOO)'
|
env FOO=one\x1etwo\x1ethree\x1efour ../test/root/bin/fish -c 'echo Elements in FOO: (count $FOO)'
|
||||||
# some must use colon separators!
|
# some must use colon separators!
|
||||||
set -lx MANPATH man1 man2 man3 ; env | grep MANPATH
|
set -lx MANPATH man1 man2 man3 ; env | grep MANPATH
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,11 @@ end
|
||||||
# Verify that we can do wildcard expansion when we
|
# Verify that we can do wildcard expansion when we
|
||||||
# don't have read access to some path components
|
# don't have read access to some path components
|
||||||
# See #2099
|
# See #2099
|
||||||
set -l where /tmp/fish_wildcard_permissions_test/noaccess/yesaccess
|
set -l where ../test/temp/fish_wildcard_permissions_test/noaccess/yesaccess
|
||||||
mkdir -p $where
|
mkdir -p $where
|
||||||
chmod 300 (dirname $where) # no read permissions
|
chmod 300 (dirname $where) # no read permissions
|
||||||
mkdir -p $where
|
mkdir -p $where
|
||||||
touch $where/alpha.txt $where/beta.txt $where/delta.txt
|
touch $where/alpha.txt $where/beta.txt $where/delta.txt
|
||||||
echo $where/*
|
echo $where/*
|
||||||
chmod 700 (dirname $where) # so we can delete it
|
chmod 700 (dirname $where) # so we can delete it
|
||||||
rm -rf /tmp/fish_wildcard_permissions_test
|
rm -rf ../test/temp/fish_wildcard_permissions_test
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Test 1 pass
|
Test 1 pass
|
||||||
Test 2 pass
|
Test 2 pass
|
||||||
Test 3 pass
|
Test 3 pass
|
||||||
/tmp/fish_wildcard_permissions_test/noaccess/yesaccess/alpha.txt /tmp/fish_wildcard_permissions_test/noaccess/yesaccess/beta.txt /tmp/fish_wildcard_permissions_test/noaccess/yesaccess/delta.txt
|
../test/temp/fish_wildcard_permissions_test/noaccess/yesaccess/alpha.txt ../test/temp/fish_wildcard_permissions_test/noaccess/yesaccess/beta.txt ../test/temp/fish_wildcard_permissions_test/noaccess/yesaccess/delta.txt
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
# ensure that builtins that produce no output can still truncate files
|
# ensure that builtins that produce no output can still truncate files
|
||||||
# (bug PCA almost reintroduced!)
|
# (bug PCA almost reintroduced!)
|
||||||
echo "Testing that builtins can truncate files"
|
echo "Testing that builtins can truncate files"
|
||||||
echo abc > /tmp/file_truncation_test.txt
|
echo abc > ../test/temp/file_truncation_test.txt
|
||||||
cat /tmp/file_truncation_test.txt
|
cat ../test/temp/file_truncation_test.txt
|
||||||
echo -n > /tmp/file_truncation_test.txt
|
echo -n > ../test/temp/file_truncation_test.txt
|
||||||
cat /tmp/file_truncation_test.txt
|
cat ../test/temp/file_truncation_test.txt
|
||||||
|
|
||||||
# Test events.
|
# Test events.
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ diff -q (__fish_print_help psub | psub) (psub -hs banana | psub)
|
||||||
|
|
||||||
# Test support for unbalanced blocks
|
# Test support for unbalanced blocks
|
||||||
function try_unbalanced_block
|
function try_unbalanced_block
|
||||||
../fish -c "echo $argv | source " 2>&1 | grep "Missing end" 1>&2
|
../test/root/bin/fish -c "echo $argv | source " 2>&1 | grep "Missing end" 1>&2
|
||||||
end
|
end
|
||||||
try_unbalanced_block 'begin'
|
try_unbalanced_block 'begin'
|
||||||
try_unbalanced_block 'while true'
|
try_unbalanced_block 'while true'
|
||||||
|
|
|
@ -19,8 +19,8 @@ function die
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# check if we're running in the test environment
|
# Check if we're running in the test environment.
|
||||||
# if not, set it up and rerun fish with exec.
|
# If not, set it up and rerun fish with exec.
|
||||||
# The test is whether the special var __fish_is_running_tests
|
# The test is whether the special var __fish_is_running_tests
|
||||||
# exists and contains the same value as XDG_CONFIG_HOME. It checks
|
# exists and contains the same value as XDG_CONFIG_HOME. It checks
|
||||||
# the value and not just the presence because we're going to delete
|
# the value and not just the presence because we're going to delete
|
||||||
|
@ -37,19 +37,21 @@ if not set -q __fish_is_running_tests
|
||||||
end
|
end
|
||||||
set -l IFS # clear IFS so cmd substitution doesn't split
|
set -l IFS # clear IFS so cmd substitution doesn't split
|
||||||
cd (dirname $script); or die
|
cd (dirname $script); or die
|
||||||
set -xl XDG_CONFIG_HOME (printf '%s/tmp.config/%s' $PWD %self); or die
|
|
||||||
if test -d $XDG_CONFIG_HOME
|
set -lx XDG_DATA_HOME ../test/data
|
||||||
# if the dir already exists, we've reused a pid
|
rm -rf $XDG_DATA_HOME/fish
|
||||||
# this would be surprising to reuse a fish pid that failed in the past,
|
mkdir -p $XDG_DATA_HOME/fish; or die
|
||||||
# but clear it anyway
|
|
||||||
rm -r $XDG_CONFIG_HOME; or die
|
set -lx XDG_CONFIG_HOME ../test/home
|
||||||
end
|
rm -rf $XDG_CONFIG_HOME/fish
|
||||||
mkdir -p $XDG_CONFIG_HOME/fish; or die
|
mkdir -p $XDG_CONFIG_HOME/fish; or die
|
||||||
ln -s $PWD/test_functions $XDG_CONFIG_HOME/fish/functions; or die
|
ln -s $PWD/test_functions $XDG_CONFIG_HOME/fish/functions; or die
|
||||||
|
|
||||||
set -l escaped_parent (dirname $PWD | sed -e 's/[\'\\\\]/\\\\&/g'); or die
|
set -l escaped_parent (dirname $PWD | sed -e 's/[\'\\\\]/\\\\&/g'); or die
|
||||||
set -l escaped_config (printf '%s/fish' $XDG_CONFIG_HOME | sed -e 's/[\'\\\\]/\\\\&/g'); or die
|
set -l escaped_config (printf '%s/fish' $XDG_CONFIG_HOME | sed -e 's/[\'\\\\]/\\\\&/g'); or die
|
||||||
printf 'set fish_function_path \'%s/functions\' \'%s/share/functions\'\n' $escaped_config $escaped_parent > $XDG_CONFIG_HOME/fish/config.fish; or die
|
printf 'set fish_function_path \'%s/functions\' \'%s/share/functions\'\n' $escaped_config $escaped_parent > $XDG_CONFIG_HOME/fish/config.fish; or die
|
||||||
set -xl __fish_is_running_tests $XDG_CONFIG_HOME
|
set -xl __fish_is_running_tests $XDG_CONFIG_HOME
|
||||||
|
|
||||||
# set locale information to be consistent
|
# set locale information to be consistent
|
||||||
set -lx LANG C
|
set -lx LANG C
|
||||||
set -lx LC_ALL ''
|
set -lx LC_ALL ''
|
||||||
|
@ -57,27 +59,13 @@ if not set -q __fish_is_running_tests
|
||||||
set -lx LC_$var ''
|
set -lx LC_$var ''
|
||||||
end
|
end
|
||||||
set -lx LC_CTYPE en_US.UTF-8
|
set -lx LC_CTYPE en_US.UTF-8
|
||||||
exec ../fish $script $args_for_test_script
|
exec ../test/root/bin/fish $script $args_for_test_script
|
||||||
die 'exec failed'
|
die 'exec failed'
|
||||||
else if test "$__fish_is_running_tests" != "$XDG_CONFIG_HOME"
|
else if test "$__fish_is_running_tests" != "$XDG_CONFIG_HOME"
|
||||||
echo 'Something went wrong with the test runner.' >&2
|
echo 'Something went wrong with the test runner.' >&2
|
||||||
echo "__fish_is_running_tests: $__fish_is_running_tests" >&2
|
echo "__fish_is_running_tests: $__fish_is_running_tests" >&2
|
||||||
echo "XDG_CONFIG_HOME: $XDG_CONFIG_HOME" >&2
|
echo "XDG_CONFIG_HOME: $XDG_CONFIG_HOME" >&2
|
||||||
exit 10
|
exit 10
|
||||||
else
|
|
||||||
# we're running tests with a temporary config directory
|
|
||||||
function test_util_on_exit --on-process-exit %self -V __fish_is_running_tests
|
|
||||||
if not set -q __fish_test_keep_tmp_config
|
|
||||||
# remove the temporary config directory
|
|
||||||
# unfortunately if this fails we can't alter the exit status of fish
|
|
||||||
if not rm -r "$__fish_is_running_tests"
|
|
||||||
echo "error: Couldn't remove temporary config directory '$__fish_is_running_tests'" >&2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# unset __fish_is_running_tests so any children that source
|
|
||||||
# test_util.fish will set up a new test environment.
|
|
||||||
set -e __fish_is_running_tests
|
|
||||||
end
|
end
|
||||||
|
|
||||||
set -l suppress_color
|
set -l suppress_color
|
||||||
|
|
Loading…
Reference in a new issue