aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile.in
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-02-06 18:08:22 -0800
committerGravatar Kurtis Rader <krader@skepticism.us>2016-02-25 17:16:36 -0800
commit8b67a1b26f2525f7de1e2a64dee6ab48b72b0e33 (patch)
tree5e0a33d532f47c5b1909b46116247f16f9707d52 /Makefile.in
parentc79ade9627b116a0dc4aecd27d1ff61e68fe595b (diff)
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
Diffstat (limited to 'Makefile.in')
-rw-r--r--Makefile.in125
1 files changed, 65 insertions, 60 deletions
diff --git a/Makefile.in b/Makefile.in
index 1f2265da..88155b2d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -23,6 +23,11 @@
# 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
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
#
-
FISH_TESTS_OBJS := $(FISH_OBJS) obj/fish_tests.o
@@ -291,12 +295,29 @@ doc/refman.pdf: doc
mv refman.pdf ..;
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.
-#
-
-test: test_low_level test_high_level
+# Note that doing `make DESTDIR=/some/path/ test` overrides this assignment.
+test: DESTDIR = $(PWD)/test/root/
+test: prefix = .
+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
# 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
.PHONY: test_high_level
-test_fishscript: $(PROGRAMS) $(call filter_up_to,test_fishscript,$(active_test_goals))
- cd tests && ../fish test.fish
+test_fishscript: $(call filter_up_to,test_fishscript,$(active_test_goals))
+ cd tests; ../test/root/bin/fish test.fish
.PHONY: test_fishscript
-test_interactive: $(PROGRAMS) $(call filter_up_to,test_interactive,$(active_test_goals))
- cd tests && ../fish interactive.fish
+test_interactive: $(call filter_up_to,test_interactive,$(active_test_goals))
+ cd tests; ../test/root/bin/fish interactive.fish
.PHONY: test_interactive
#
@@ -582,7 +603,6 @@ check-legacy-binaries:
@true;
.PHONY: check-legacy-binaries
-
#
# 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
@@ -593,12 +613,30 @@ install-sh:
if test -x $@; then true; else chmod 755 $@; fi
.PHONY: install-sh
-
#
# Try to install after checking for incompatible installed versions.
#
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
#
@@ -611,11 +649,10 @@ xcode-install:
.PHONY: xcode-install
#
-# Force installation, even in presense of incompatible previous
-# version. This may fail.
-# These 'true' lines are to prevent installs from failing for (e.g.) missing man pages.
+# Force installation, even in presense of incompatible previous version. This
+# may fail. These 'true' lines are to prevent installs from failing for (e.g.)
+# missing man pages.
#
-
install-force: all install-translations
$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
for i in $(PROGRAMS); do\
@@ -685,25 +722,6 @@ install-force: all install-translations
$(INSTALL) -m 644 $$i $(DESTDIR)$(mandir)/man1/; \
true; \
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
@@ -781,7 +799,7 @@ uninstall-translations:
#
obj/%.o: src/%.cpp | obj
$(CXX) $(CXXFLAGS) -c $< -o $@
-
+
#
# obj directory
#
@@ -801,27 +819,21 @@ $(PCRE2_LIB): $(PCRE2_H)
$(PCRE2_H):
(cd $(PCRE2_DIR) && ./config.status --enable-maintainer-mode)
-
#
# Build the fish_tests program.
#
-
fish_tests: $(FISH_TESTS_OBJS) $(EXTRA_PCRE2)
$(CXX) $(CXXFLAGS) $(LDFLAGS_FISH) $(FISH_TESTS_OBJS) $(LIBS) -o $@
-
#
# Build the fish_indent program.
#
-
fish_indent: $(FISH_INDENT_OBJS) $(EXTRA_PCRE2)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(FISH_INDENT_OBJS) $(LIBS) -o $@
-
#
# Neat little program to show output from terminal
#
-
key_reader: $(FISH_OBJS) $(EXTRA_PCRE2) obj/key_reader.o
$(CXX) $(CXXFLAGS) $(LDFLAGS_FISH) $^ $(LIBS) -o $@
@@ -860,41 +872,34 @@ _iwyu: clean $(PROGRAMS)
# Cleanup targets
#
-#
-# distclean should restore the tree to the state right after extracting a tarball.
-#
-
+# Restore the source tree to the state right after extracting a tarball.
distclean: clean
- $(MAKE) -C $(PCRE2_DIR) distclean
+ $(MAKE) -C $(PCRE2_DIR) distclean || true
rm -f config.status config.log config.h Makefile
.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
-# are created by the configure script.
-#
-
-# 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
-
+# 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:
-ifdef EXTRA_PCRE2
- $(MAKE) -C $(PCRE2_DIR) clean
-endif
- rm -f obj/*.o *.o doc.h doc.tmp doc_src/*.doxygen doc_src/*.cpp doc_src/*.o doc_src/commands.hdr
+ $(MAKE) -C $(PCRE2_DIR) clean || true
+ rm -f obj/*.o *.o doc.h doc.tmp
+ rm -f 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 $(PROGRAMS) fish_tests key_reader
rm -f command_list.txt command_list_toc.txt toc.txt
rm -f doc_src/index.hdr doc_src/commands.hdr
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 \
rm -rf doc user_doc share/man; \
fi
rm -f po/*.gmo
- rm -rf obj
+ rm -rf obj build test
.PHONY: clean