pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/regress/infra-unittests
Module Name: pkgsrc
Committed By: rillig
Date: Sat Mar 21 12:47:13 UTC 2020
Modified Files:
pkgsrc/regress/infra-unittests: subst.sh
Log Message:
regress/infra-unittests: add more tests for subst.mk
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 pkgsrc/regress/infra-unittests/subst.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/regress/infra-unittests/subst.sh
diff -u pkgsrc/regress/infra-unittests/subst.sh:1.8 pkgsrc/regress/infra-unittests/subst.sh:1.9
--- pkgsrc/regress/infra-unittests/subst.sh:1.8 Sat Mar 21 12:22:31 2020
+++ pkgsrc/regress/infra-unittests/subst.sh Sat Mar 21 12:47:13 2020
@@ -14,6 +14,7 @@ test_case_set_up() {
# The tools that are used by subst.mk
CHMOD= chmod-is-not-used
CMP= cmp
+DIFF= diff
ECHO= echo
MKDIR= mkdir -p
MV= mv
@@ -538,3 +539,91 @@ EOF
test_case_end
fi
+
+
+if test_case_begin "several SUBST classes"; then
+
+ # It's ok to have several SUBST classes that apply to the same file.
+ # The order of execution is not guaranteed though.
+
+ create_file_lines "file" "zero one two three four"
+
+ create_file "testcase.mk" <<EOF
+SUBST_CLASSES+= one
+SUBST_STAGE.one= pre-configure
+SUBST_FILES.one= file
+SUBST_SED.one= -e 's,one,I,'
+
+SUBST_CLASSES+= two
+SUBST_STAGE.two= pre-configure
+SUBST_FILES.two= file
+SUBST_SED.two= -e 's,two,II,'
+
+SUBST_CLASSES+= three
+SUBST_STAGE.three= pre-configure
+SUBST_FILES.three= file
+SUBST_SED.three= -e 's,three,III,'
+
+.include "prepare-subst.mk"
+.include "mk/subst.mk"
+EOF
+
+ test_file "testcase.mk" "pre-configure" \
+ 1> "$tmpdir/stdout" \
+ 2> "$tmpdir/stderr" \
+ && exitcode=0 || exitcode=$?
+
+ # The order of the above output is not guaranteed.
+ LC_ALL=C sort < "$tmpdir/stdout" > "$tmpdir/stdout-sorted"
+
+ assert_that "file" --file-is-lines "zero I II III four"
+ assert_that "stdout-sorted" --file-is-lines \
+ "=> Substituting \"one\" in file" \
+ "=> Substituting \"three\" in file" \
+ "=> Substituting \"two\" in file"
+ assert_that "stderr" --file-is-empty
+ assert_that "$exitcode" --equals 0
+
+ test_case_end
+fi
+
+
+if test_case_begin "show diff"; then
+
+ create_file_lines "file" "one" "two" "three"
+
+ create_file "testcase.mk" <<EOF
+SUBST_CLASSES+= two
+SUBST_STAGE.two= pre-configure
+SUBST_FILES.two= file
+SUBST_SED.two= -e 's,two,II,'
+SUBST_SHOW_DIFF.two= yes
+
+.include "prepare-subst.mk"
+.include "mk/subst.mk"
+EOF
+
+ LC_ALL=C \
+ test_file "testcase.mk" "pre-configure" \
+ 1> "$tmpdir/stdout" \
+ 2> "$tmpdir/stderr" \
+ && exitcode=0 || exitcode=$?
+
+ awk '{ if (/^... \.\/.*/) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \
+ < "$tmpdir/stdout" > "$tmpdir/stdout-filtered"
+
+ assert_that "file" --file-is-lines "one" "II" "three"
+ assert_that "stdout-filtered" --file-is-lines \
+ "=> Substituting \"two\" in file" \
+ "--- ./file (filtered timestamp)" \
+ "+++ ./file.subst.sav (filtered timestamp)" \
+ "@@ -1,3 +1,3 @@" \
+ " one" \
+ "-two" \
+ "+II" \
+ " three"
+ assert_that "stderr" --file-is-empty
+ assert_that "$exitcode" --equals 0
+
+ test_case_end
+fi
Home |
Main Index |
Thread Index |
Old Index