summaryrefslogtreecommitdiff
path: root/t/lib-git-p4.sh
AgeCommit message (Collapse)AuthorFilesLines
2014-01-22git p4 test: do not pollute /tmpLibravatar Pete Wyckoff1-1/+7
Generating the submit template for p4 uses tempfile.mkstemp(), which by default puts files in /tmp. For a test that fails, possibly on purpose, this is not cleaned up. Run with TMPDIR pointing into the trash directory so the temp files go away with the test results. To do this required some other minor changes. First, the editor is launched using system(editor + " " + template_file), using shell expansion to build the command string. This doesn't work if editor has a space in it. And is generally unwise as it's easy to fool the shell into doing extra work. Exec the args directly, without shell expansion. Second, without shell expansion, the trick of "P4EDITOR=:" used in the tests doesn't work. Use a real command, true, as the non-interactive editor for testing. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-22git p4 test: run as user "author"Libravatar Pete Wyckoff1-1/+14
The tests use author@example.com as the canonical submitter, but he does not have an entry in the p4 users database. This causes the generated change description to complain that the git and p4 users disagree. The complaint message is still valid, but isn't useful in tests. It was introduced in 848de9c (git-p4: warn if git authorship won't be retained, 2011-05-13). Fix t9813 to use @example.com instead of @localhost due to change in p4_add_user(). Move the function into the git p4 test library so author can be added at initialization time. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-11git p4 test: sanitize P4CHARSETLibravatar kazuki saitoh1-1/+2
In the tests, p4d is started without using "internationalized mode". Make sure this environment variable is unset, otherwise a mis-matched user setting would break the tests. The error message would be "Unicode clients require a unicode enabled server." [pw: use unset, add commit text] Signed-off-by: Kazuki Saitoh <ksaitoh560@gmail.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-26git p4: cygwin p4 client does not mark read-onlyLibravatar Pete Wyckoff1-0/+13
There are some old versions of p4, compiled for cygwin, that treat read-only files differently. Normally, a file that is not open is read-only, meaning that "test -w" on the file is false. This works on unix, and it works on windows using the NT version of p4. The cygwin version of p4, though, changes the permissions, but does not set the windows read-only attribute, so "test -w" returns false. Notice this oddity and make the tests work, even on cygiwn. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-26git p4 test: use LineEnd unix in windows tests tooLibravatar Pete Wyckoff1-0/+1
In all clients, even those created on windows, use unix line endings. This makes it possible to verify file contents without doing OS-specific comparisons in all the tests. Tests in t9802-git-p4-filetype.sh are used to make sure that the other LineEnd options continue to work. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-26git p4 test: translate windows paths for cygwinLibravatar Pete Wyckoff1-2/+22
Native windows binaries do not understand posix-like path mapping offered by cygwin. Convert paths to native using "cygpath --windows" before presenting them to p4d. This is done using the AltRoots mechanism of p4. Both the posix and windows forms are put in the client specification, allowing p4 to find its location by native path even though the environment reports a different PWD. Shell operations in tests will use the normal form of $cli, which will look like a posix path in cygwin, while p4 will use AltRoots to match against the windows form of the working directory. This mechanism also handles the symlink issue that was fixed in 23bd0c9 (git p4 test: use real_path to resolve p4 client symlinks, 2012-06-27). Now that every p4 client view has an AltRoots with the real_path in it, explicitly calculating the real_path elsewhere is not necessary. Thanks-to: Sebastian Schuberth <sschuberth@gmail.com> Thanks-to: Johannes Sixt <j6t@kdbg.org> fixup! git p4 test: translate windows paths for cygwin Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-26git p4 test: start p4d inside its db dirLibravatar Pete Wyckoff1-2/+5
This will avoid having to do native path conversion for windows. Also may be a bit cleaner always to know that p4d has that working directory, instead of wherever the function was called from. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-26git p4 test: use client_view in t9806Libravatar Pete Wyckoff1-2/+2
Use the standard client_view function from lib-git-p4.sh instead of building one by hand. This requires a bit of rework, using the current value of $P4CLIENT for the client name. It also reorganizes the test to isolate changes to $P4CLIENT and $cli in a subshell. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-26git p4 test: avoid loop in client_viewLibravatar Pete Wyckoff1-3/+1
The printf command re-interprets the format string as long as there are arguments to consume. Use this to simplify a for loop in the client_view() library function. This requires a fix to one of the client_view callers. An errant \n in the string was converted into a harmless newline in the input to "p4 client -i", but now shows up as a literal \n as passed through by "%s". Remove the \n. Based-on-patch-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-26git p4 test: use client_view to build the initial clientLibravatar Pete Wyckoff1-9/+2
Simplify the code a bit by using an existing function. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-18Merge branch 'pw/p4-submit-conflicts'Libravatar Junio C Hamano1-3/+4
Add '--conflict' option to git-p4 subcommand to specify what action to take when conflicts are found during 'p4 submit'. * pw/p4-submit-conflicts: git-p4: add submit --conflict option and config varaiable git p4: add submit --prepare-p4-only option git p4: add submit --dry-run option git p4: accept -v for --verbose git p4: revert deleted files after submit cancel git p4: rearrange submit template construction git p4: test clean-up after failed submit, fix added files git p4: standardize submit cancel due to unchanged template git p4: move conflict prompt into run, add [q]uit input git p4: remove submit failure options [a]pply and [w]rite git p4: gracefully fail if some commits could not be applied git p4 test: remove bash-ism of combined export/assignment
2012-09-16git p4 test: remove bash-ism of combined export/assignmentLibravatar Pete Wyckoff1-3/+4
Signed-off-by: Pete Wyckoff <pw@padd.com> Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-11git p4 test: move client_view() function to libraryLibravatar Pete Wyckoff1-0/+17
This code will be useful in --detect-branches --use-client-spec tests. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-05git p4 test: refactor marshal_dumpLibravatar Pete Wyckoff1-0/+13
This function will be useful in future tests. Move it to the git-p4 test library. Let it accept an optional argument to pick a certain marshaled object out of the input stream. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-27git p4 test: cleanup_git should make a new $gitLibravatar Pete Wyckoff1-1/+2
For convenience, leave one in place at the end of each test so that it is not necessary to build a new one. This makes it consistent with $cli. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-27git p4 test: never create default test repoLibravatar Pete Wyckoff1-0/+4
Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-27git p4 test: use real_path to resolve p4 client symlinksLibravatar Pete Wyckoff1-1/+1
The p4 program is finicky about making sure the recorded client Root matches the current working directory. The way it discovers the latter seems to be to inspect shell variable $PWD. This could involve symlinks, that while leading to the same place as the client Root, look different, and cause p4 to fail. Resolve all client paths using "test-path-utils real_path $path". This removes ".." and resolves all symlinks. Discovered while running with --root=/dev/shm, which is a link to /run/shm. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-27git p4 test: wait longer for p4d to start and test its pidLibravatar Pete Wyckoff1-6/+32
Running tests at high parallelism on a slow machine, 5 sec is not enough to wait for p4d to start. Change it to 5 minutes, adding an environment variable P4D_START_PATIENCE to shrink that if needed in automated test environments. Also check if the pid of the p4d that we started is still around. If not, quit waiting for it immediately. Remove all the confusing && chaining and simplify the code. Thanks-to: Junio C Hamano <gitster@pobox.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-24git p4: Squash P4EDITOR in test harnessLibravatar Luke Diamand1-0/+1
If P4EDITOR is set in the environment, test behavior could be unpredictable. Set it explicitly. Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-09git p4: use "git p4" directly in testsLibravatar Pete Wyckoff1-5/+3
Drop the $GITP4 variable that was used to specify the script in contrib/fast-import/. The command is called "git p4" now, not "git-p4". Note that configuration variables will remain in a section called "git-p4". Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-09git-p4: move to toplevelLibravatar Pete Wyckoff1-1/+1
Move git-p4 out of contrib/fast-import into the main code base, aside other foreign SCM tools. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-17git-p4 tests: refactor and cleanupLibravatar Pete Wyckoff1-0/+74
Introduce a library for functions that are common to multiple git-p4 test files. Be a bit more clever about starting and stopping p4d. Specify a unique port number for each test, so that tests can run in parallel. Start p4d not in daemon mode, and save the pid, to be able to kill it cleanly later. Never kill p4d at startup; always shutdown cleanly. Handle directory changes better. Always chdir inside a subshell, and remove any post-test directory changes. Clean up whitespace, and use test_cmp and test_must_fail more consistently. Separate the tests related to detecting p4 branches into their own file, and add a few more. Acked-by: Luke Diamand <luke@diamand.org> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>