summaryrefslogtreecommitdiffstats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* test: Fix a race condition in merge.testĐoàn Trần Công Danh2023-02-281-2/+4
| | | | | | | | Just like commit 4dfe7f9, (test: Fix a race condition, 2023-01-20), this fix a test race when stdout and stderr in any order. Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Fix a race conditionJean Delvare2023-01-201-1/+2
| | | | | | | | | | | | | | The test suite does not differentiate between stdout and stderr. When messages are printed to both, the order in which they will reach us is apparently not guaranteed. Ideally this would be deterministic, but until then, explicitly test stdout and stderr separately in the test case itself. Otherwise the test suite fails randomly, which is a pain for distribution package maintainers. This fixes bug #63651 reported by Ross Burton: https://savannah.nongnu.org/bugs/index.php?63651 Signed-off-by: Jean Delvare <jdelvare@suse.de>
* import: Fix option -PJean Delvare2021-09-031-0/+16
| | | | | | | | | | | | | | | I broke "import -P" with my previous commit. Using this option now fails with the following error message: /usr/share/quilt/import: line 168: [: missing `]' This is caused by a missing space before the closing square bracket, which prevents bash from parsing the line. Fix that, and add a test case to cover this code path, so that no such bug can creep in in the future. Signed-off-by: Jean Delvare <jdelvare@suse.de> Fixes: c539338458e4 ("Delay sourcing patchfns until options have been processed")
* Delay sourcing patchfns until options have been processedJean Delvare2021-06-101-0/+91
| | | | | | | | | | | | | | | | Commit 8b39a960afcf ("Consistently complain early if no series file is found") unexpectedly broke commands like "quilt add -h", because the check for a series file happens before the command line options are processed. This, in turn, breaks the generation of the quilt manual page, which relies on the output of each command when called with option -h. Reorder the code so that options are always processed first, and then patchfns is sourced. That way, option "-h" will work again even if not in a quilt working tree. Fixes: 8b39a960afcf ("Consistently complain early if no series file is found") Signed-off-by: Jean Delvare <jdelvare@suse.de>
* backup-files: Restore symbolic linksJean Delvare2020-12-091-0/+33
| | | | | | | | | | | | | | | | As "patch" originally did not handle symbolic links, backup-files didn't have to care about them either. But now that git has introduced an extended syntax which allows manipulating symbolic links in patch files, "quilt push" may create or delete symbolic links, which means that backup-files must support such operations too. Also extend the backup-files test case to cover these operations. This fixes bug #59479: https://savannah.nongnu.org/bugs/index.php?59479 Signed-off-by: Jean Delvare <jdelvare@suse.de>
* Quote parameter to gen_tempfile as neededJean Delvare2020-10-051-0/+59
| | | | | | | | | | | | | | | | | When the parameter passed to gen_tempfile is based on the working directory, we need to quote it because it could contain spaces or other special characters. Also quote the string returned by this function for the same reason. Affected commands: * quilt diff -z * quilt fold * quilt refresh -z * quilt revert Also test these code paths in the test suite to avoid regressions. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* tests: De-duplicate no-series testsJean Delvare2020-06-093-36/+49
| | | | | | | | | | Test all commands, including annotate and patches, in the no-series test case, and check the error code returned too. Remove no-series checks from all other test cases, as testing the same code path twice is a waste of time. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* Consistently complain early if no series file is foundJean Delvare2020-06-092-4/+7
| | | | | | | | | | | | | | | | | | | If no series file is found, let all quilt commands which need it complain about it immediately. This aligns the behavior of the "pop", "series" and "snapshot" commands with how all other commands behave. The "import", "new", "setup" and "upgrade" commands are not affected by this change, as they are legitimately called without a series file. A side effect of this change is that the "pop", "push", "top" and "next" commands will now return with error code 1 instead of 2 when called outside of a quilt-managed tree. Inspired by Martin Quinson. This fixes Debian bug #369908: https://bugs.debian.org/369908 Signed-off-by: Jean Delvare <jdelvare@suse.de>
* Remove duplicate testJean Delvare2020-03-241-1/+1
|
* test: Test case for when no series file existsJean Delvare2020-03-241-0/+53
| | | | | | A pretty simple test case to avoid regressions in corner cases. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Don't hard-code .pcJean Delvare2019-03-148-34/+34
| | | | | | | | | | | Use a variable (QUILT_PC) instead of hard-coding ".pc" as the name of the directory where quilt stores the state of the working tree throughout the test suite. We still set that variable to ".pc" to make it easier to investigate failed test cases, but at least this allows us to promptly test that QUILT_PC can actually be set to any other value and quilt still works. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Prevent test cases from escapingJean Delvare2019-03-141-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | By default, we continue running tests even after a failure, to make diagnostics easier. If a chdir command fails, there is a chance that subsequent chdir commands could accidentally move outside the temporary directory where the test is being run, and then we start messing up with the host's files. In general, the consequence is to leave garbage files and directories behind. However, some of the files can have side effects (for example a "series" file or a "patches" directory could confuse quilt later), and in theory this could also lead to the corruption or deletion of existing files, which is pretty bad. So add a safety check after every chdir command that we are still inside the test case's working directory. If not, stop the test immediately. Note: this is not about being 100% safe and bullet-proof. The only way to achieve this would be to use chroot or even containers. We still need to trust the test cases to not do anything nasty on purpose. This is only protecting against good test cases going wild on failure. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* new: Fix series file corruption when trailing newline is missingJean Delvare2018-11-051-0/+22
| | | | | | | | | | | | | When editing the series file with certain editors, it is possible that no trailing newline character is present on the last line. In such case, adding a new patch at the end of the series would corrupt the series file. Prevent that by ensuring that a newline character is always present. This fixes the second issue reported in bug #54295: https://savannah.nongnu.org/bugs/?54295 Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Clean up when interruptedJean Delvare2018-03-261-0/+2
| | | | | | | If the user hits Ctrl+C while a test is running, don't leave our working directory behind. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Be verbose on directory errorJean Delvare2018-03-261-3/+3
| | | | | | Being a little more verbose when mkdir or chdir fails, can't hurt. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test/space-in-work-dir: Increase code path coverageJean Delvare2017-10-271-0/+5
| | | | | Increase the code path coverage of test case space-in-work-dir by running one command from a subdirectory.
* Quote series file name everywhereJean Delvare2017-06-061-0/+151
| | | | | | | | | Don't choke if the series file name contains a space or any other special character. "$SERIES" was already quoted in various places, do it consistently so that quilt will work in this situation. And add a basic test case to verify that it actually works. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Handle alternative QUILT_PATCHES valuesJean Delvare2017-05-093-8/+8
| | | | | | | | | | When using an alternative QUILT_PATCHES value, we can't use %{P} in the test case, because P is set in the Makefile before the test case has a chance to redefine QUILT_PATCHES. Instead we have to make the prefix optional in the output of the quilt commands, so that the test will succeed regardless of QUILT_PATCHES_PREFIX being set or not. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Consistently use %{P} and %{_P}Jean Delvare2017-05-0933-352/+352
| | | | | | | | | | | There is no point in defining P and _P in the Makefile to allow for QUILT_PATCHES_PREFIX to be set or unset if we do not use these variables consistently in the test suite. Replace hardcoded "patches/" with %{P} or %{_P} throughout the test suite wherever relevant so that unsetting QUILT_PATCHES_PREFIX in test.quiltrc actually works. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Drop incorrect uses of %{P}Jean Delvare2017-05-096-11/+11
| | | | | | | | | %{P} only makes sense when checking the output of a quilt command. The value of QUILT_PATCHES_PREFIX can obviously not affect what the user is writing on the command line, nor the output of other commands. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* diff/refresh: Add missing quotes in basename callJean Delvare2017-05-021-0/+55
| | | | | | | | | | The basename call in function diff_file would fail if any component of the path has a space in its name. This fixes bug #50862: https://savannah.nongnu.org/bugs/?50862 Signed-off-by: Jean Delvare <jdelvare@suse.de>
* header: Fix patch corruption when trailing newline is missingJean Delvare2017-05-021-0/+13
| | | | | | | | | | | | When editing a patch header with certain editors, it is possible that no trailing newline character is present on the last line. In such case, the patch would be corrupted. Prevent that by ensuring that a newline character is always present. This fixes bug #50841: https://savannah.nongnu.org/bugs/?50841 Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Fix /bin/sh filteringJean Delvare2017-04-251-1/+1
| | | | | | | /bin/sh may not include a line number in its error messages, fix the filtering when it does not. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Escape curly braces in regexJean Delvare2017-04-251-2/+2
| | | | | | | | | | Curly braces in perl regex are supposed to be escaped, recent versions of perl complain when they aren't: Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE (\w+)}/ at ./run line 114. Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE \?}/ at ./run line 290. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* test: Allow keeping the working directory on failureJean Delvare2017-04-141-2/+3
| | | | | | | | Add an option to keep the working directory after a test has failed. Also include the test name in the working directory name to make it easier to figure out which test failed later. Signed-off-by: Jean Delvare <jdelvare@suse.de>
* diff: Report diff failuresJean Delvare2016-10-191-0/+1
| | | | | "quilt refresh" reports diff failures to the user. "quilt diff" should do the same.
* Project settings have priorityJean Delvare2015-12-041-0/+22
| | | | | | | | If QUILT_PATCHES or QUILT_SERIES are set both in ~/.quiltrc and .pc/.quilt_patches (respectively .pc/.quilt_series), the former currently takes precedence. This pretty much voids the value of per-project settings. Project settings should have the highest priority.
* Let cat_to_new_file handle the file backupJean Delvare2015-03-191-0/+37
| | | | | | | | | | | | | Let function cat_to_new_file optionally backup the destination file before overwriting it. This has two advantages: * This avoids duplicating code on the caller's side. Functions header and refresh both need to perform a backup. * This guarantees the consistency of the backup logic. At the moment, the refresh command would handle the backup of a symlinked file just fine while the header command would misbehave in that case. Now that the header command handles symlinked patches properly, also test it so that we don't break it accidentally later.
* hard-linked-patch.test: Test the header commandJean Delvare2015-03-191-0/+24
| | | | | Extend the hard-linked patch test case to also check the behavior when updating the header of such a patch.
* Test backup failureJean Delvare2015-03-191-0/+23
| | | | Add a test case for backup failure to the test suite.
* symlink.test: Make the test more robustJean Delvare2015-02-251-0/+1
| | | | | | | "mv" may or may not overwrite a read-only file by default, depending on whether or not it is considered to be interactive. Removing the file explicitly before avoids that uncertainty and makes it easier to play the test case manually.
* refresh: Always preserve modification timeJean Delvare2015-02-251-0/+3
| | | | | | In the general case, when doing a backup copy of a patch on refresh, the modification time of the file is preserved. We should do the same when the patch is a symbolic link.
* refresh: Break links to read-only patch filesJean Delvare2015-02-251-0/+48
| | | | | | | | We just changed the behavior of the refresh command to no longer break symbolic links. While preserving the links is the right thing to do in the general case, this approach fails if the patch file is read-only. In that case we want to replace the link itself with the refreshed patch, as we used to.
* refresh: Do not remove symlinksJason Wessel2015-02-181-0/+53
| | | | | | | | | | | | | | | | | | | | | | Change the core behavior of quilt to not remove symlinks to the patch files. Historical notes: This is an 6 year old patch that is still actively used for the Yocto Project and others. http://lists.nongnu.org/archive/html/quilt-dev/2008-01/msg00004.html Revised again here: http://comments.gmane.org/gmane.comp.handhelds.openembedded/34224 [Edited by Jean Delvare: removed a compatibility option, we'll introduce it only if users ask for it. Also cleaned up the test case a bit.] Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
* edit: Fix a corner caseJean Delvare2015-02-181-1/+32
| | | | | | | | | | | | | | | | There is one corner case which is not properly handled by the "edit" command. If a patch deletes a file, and the user calls "quilt edit" on that file but does not actually add anything back to it, "quilt remove" is called on the file when the editor exits. This causes the file to be restored to its original state before the patch deleted it. The user never asked for that, so the file should be left to its deleted state in this case. The file must only be removed from the patch if it was not part of the patch originally. The same problem would occur if the editor deleted the file. In general text editors don't do that, they'd leave an empty file instead, but nothing prevents them from actually deleting the file so we should handle this case properly too.
* edit: Use command "remove" to remove filesJean Delvare2015-02-181-0/+11
| | | | | | | | | | | Commit f1c186ee renamed command "remove" to "revert". Commit bd1dfdab changed the semantics of command "revert". Commit 6d2501ac restored command "remove". However command "edit" is still calling command "revert" to remove files from the patch when it should be using command "remove". This case was not covered by the test suite, which is why the bug was not spotted earlier.
* edit: Improve the test caseJean Delvare2015-02-181-3/+24
| | | | | | | | | Cover one more use case of the "edit" command in the test case: file creation. Also reorder some of the commands to make the tests easier to follow. The intent is easier to understand when the result is tested after each command.
* Merge the two revert test casesJean Delvare2015-02-172-46/+26
| | | | | Merge the two revert test cases into a single, complete and commented test file.
* test/mail: Test multi-line headersJean Delvare2015-01-271-2/+6
| | | | Add coverage of the multi-line header case to the mail test case.
* Test refresh behavior on hard-linked patchesJean Delvare2015-01-141-0/+36
| | | | | | If a patch file has hard links, refreshing it should break the links so that the other copies are left unmodified. Test this behavior to avoid breaking it accidentally.
* push: Add --refresh optionJean Delvare2014-11-121-0/+25
| | | | | Add an option to automatically refresh each patch after is was successfully applied.
* pop: Add --refresh optionJean Delvare2014-11-121-0/+30
| | | | | Add an option to automatically refresh each patch before it gets unapplied.
* pop: Rearm consistency check if neededJean Delvare2014-10-301-6/+17
| | | | | | | | If the series file is inconsistent, "quilt pop" will disable the consistency check as it updates the timestamp of the database file. It's OK if all patches are popped. If not then the series file may still be inconsistent. In that case, we want to update the timestamp of the series file, to rearm the consistency check.
* push: Fix handling of "quilt push 0"Jean Delvare2014-10-291-0/+10
| | | | | | | | | "quilt push 0" returns the following cryptic message: Now at patch patches/quilt So add the same check we already have in command pop and detect when nothing needs to be done, returning the more sane message: No patch applied
* Check for series file consistencyJean Delvare2014-10-271-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Quilt allows manual changes to the series file to some degree. For example, adding comments or reordering patches in the unapplied section of the series file is OK. However, changing the order of applied patches breaks a number of assumptions and can cause quilt to produce unexpected or confusing results. For example, starting from this: + patches/01.patch = patches/02.patch patches/03.patch patches/04.patch and moving the last patch at the beginning of the series file, "quilt series -v" will print: + patches/04.patch + patches/01.patch = patches/02.patch patches/03.patch That is, it will claim that 04.patch is applied, while it it not. Likewise, 04.patch would be listed by neither "quilt applied" nor "quilt unapplied". While addressing all such cases would certainly be possible, that would require a significant amount of work, and would come with performance penalties. It would also be difficult to be certain that all issues have been found and addressed. So it seems more reasonable to simply spot such manual changes to the series file and ask the user to pop all patches to start from a clean state as needed.
* Test push and pop with numeric argumentsJean Delvare2014-10-151-0/+23
|
* files: Add support for unapplied patchesJean Delvare2014-07-231-0/+3
| | | | | | We already have a function to figure out which files are touched by unapplied patches. The only thing missing to let the user call "quilt files" on unapplied patches was two small spots of glue.
* Test context patchesJean Delvare2014-07-141-1/+43
| | | | | Now that the patches command works with context patches, we can test that.
* setup: Skip version checkJean Delvare2014-06-091-0/+7
| | | | | | | The version check is irrelevant when running "quilt setup", as it is creating a brand new working tree anyway. Reported by Petr Tesarik.
* faildiff.test: loosen error string constraintKent R. Spillner2014-06-031-1/+1
| | | | | | | | diff might be called by a different name if the configure script was invoked with the --with-diff argument. Make the permissions test in faildiff.test match other names as well. Signed-off-by: Kent R. Spillner <kspillner@acm.org>