summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #5098 from pks-t/pks/clar-data-drivenEdward Thomson2019-06-112-82/+86
|\ | | | | Data-driven tests
| * tests: object: consolidate cache testsPatrick Steinhardt2019-06-071-68/+57
| | | | | | | | | | | | | | | | | | | | | | The object::cache test module has two tests that do nearly the same thing: given a cache limit, load a certain set of objects and verify if those objects have been cached or not. Convert those tests to the new data-driven initializers to demonstrate how these are to be used. Furthermore, add some additional test data. This conversion is mainly done to show this new facility.
| * tests: allow for simple data-driven testsPatrick Steinhardt2019-06-071-14/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, we're not able to use data-driven tests at all. E.g. given a set of tests which we'd like to repeat with different test data, one has to hand-write any outer loop that iterates over the test data and then call each of the test functions. Next to being bothersome, this also has the downside that error reporting is quite lacking, as one never knows which test data actually produced failures. So let's implement the ability to re-run complete test modules with changing test data. To retain backwards compatibility and enable trivial addition of new runs with changed test data, we simply extend clar's generate.py. Instead of scanning for a single `_initialize` function, each test module may now implement multiple `_initialize_foo` functions. The generated test harness will then run all test functions for each of the provided initializer functions, making it possible to provide different test data inside of each of the initializer functions. Example: ``` void test_git_example__initialize_with_nonbare_repo(void) { g_repo = cl_git_sandbox_init("testrepo"); } void test_git_example__initialize_with_bare_repo(void) { g_repo = cl_git_sandbox_init("testrepo.git"); } void test_git_example__cleanup(void) { cl_git_sandbox_cleanup(); } void test_git_example__test1(void) { test1(); } void test_git_example__test2(void) { test2(); } ``` Executing this test module will cause the following output: ``` $ ./libgit2_clar -sgit::example git::example (with nonbare repo).. git::example (with bare repo).. ```
* | ci: enable all proxy testsEdward Thomson2019-06-101-1/+1
| |
* | winhttp: support default credentials for proxiesEdward Thomson2019-06-101-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We did not properly support default credentials for proxies, only for destination servers. Refactor the credential handling to support sending either username/password _or_ default credentials to either the proxy or the destination server. This actually shares the authentication logic between proxy servers and destination servers. Due to copy/pasta drift over time, they had diverged. Now they share a common logic which is: first, use credentials specified in the URL (if there were any), treating empty username and password (ie, "http://:@foo.com/") as default credentials, for compatibility with git. Next, call the credential callbacks. Finally, fallback to WinHTTP compatibility layers using built-in authentication like we always have. Allowing default credentials for proxies requires moving the security level downgrade into the credential setting routines themselves. We will update our security level to "high" by default which means that we will never send default credentials without prompting. (A lower setting, like the WinHTTP default of "medium" would allow WinHTTP to handle credentials for us, despite what a user may have requested with their structures.) Now we start with "high" and downgrade to "low" only after a user has explicitly requested default credentials.
* | network: don't add arbitrary url rulesEdward Thomson2019-06-101-6/+0
| | | | | | | | | | There's no reason a git repository couldn't be at the root of a server, and URLs should have an implicit path of '/' when one is not specified.
* | net: rename gitno_connection_data to git_net_urlEdward Thomson2019-06-102-169/+206
| | | | | | | | | | | | | | | | | | | | "Connection data" is an imprecise and largely incorrect name; these structures are actually parsed URLs. Provide a parser that takes a URL string and produces a URL structure (if it is valid). Separate the HTTP redirect handling logic from URL parsing, keeping a `gitno_connection_data_handle_redirect` whose only job is redirect handling logic and does not parse URLs itself.
* | tests: checkout: fix symlink.git being created outside of sandboxPatrick Steinhardt2019-06-071-1/+5
|/ | | | | | | | | The function `populate_symlink_workdir` creates a new "symlink.git" repository with a relative path "../symlink.git". As the current working directory is the sandbox, the new repository will be created just outside of the sandbox. Fix this by using `clar_sandbox_path`.
* Merge pull request #5095 from pks-t/pks/ignore-escaped-trailing-spaceEdward Thomson2019-06-061-0/+46
|\ | | | | ignore: handle escaped trailing whitespace
| * ignore: handle escaped trailing whitespacePatrick Steinhardt2019-06-061-0/+46
| | | | | | | | | | | | | | | | | | | | The gitignore's pattern format specifies that "Trailing spaces are ignored unless they are quoted with backslash ("\")". We do not honor this currently and will treat a pattern "foo\ " as if it was "foo\" only and a pattern "foo\ \ " as "foo\ \". Fix our code to handle those special cases and add tests to avoid regressions.
* | Merge pull request #5074 from libgit2/ethomson/ignore_leading_slashEdward Thomson2019-06-061-0/+24
|\ \ | |/ |/| Ignore: only treat one leading slash as a root identifier
| * ignore: test multiple leading slashesEdward Thomson2019-05-191-0/+24
| |
* | online tests: use gitlab for auth failuresethomson/auth_failureEdward Thomson2019-06-051-1/+1
| | | | | | | | | | | | | | | | GitHub recently changed their behavior from returning 401s for private or nonexistent repositories on a clone to returning 404s. For our tests that require an auth failure (and 401), move to GitLab to request a missing repository. This lets us continue to test our auth failure case, at least until they decide to mimic that decision.
* | attr: ensure regular attr files can have whitespaceethomson/ignore_spacesEdward Thomson2019-05-243-7/+33
| | | | | | | | | | | | Unlike ignore files, gitattribute files can have flexible whitespace at the beginning of the line. Ensure that by adding new ignore rules that we have not impeded correct parsing of attribute files.
* | ignore: test that comments begin at position 0Edward Thomson2019-05-241-0/+4
| | | | | | | | | | | | Comments must have a '#' at the beginning of the line. For compatibility with git, '#' after a whitespace is a literal part of the filename.
* | ignore: test that leading whitespace is significantEdward Thomson2019-05-242-0/+1294
| | | | | | | | | | | | Ensure that leading whitespace is treated as being part of the filename, eg ` foo` in an ignore file indicates that a file literally named ` foo` is ignored.
* | cache: fix cache eviction using deallocated keyPatrick Steinhardt2019-05-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When evicting cache entries, we first retrieve the object that is to be evicted, delete the object and then finally delete the key from the cache. In case where the cache eviction caused us to free the cached object, though, its key will point to invalid memory now when trying to remove it from the cache map. On my system, this causes us to not properly remove the key from the map, as its memory has been overwritten already and thus the key lookup it will fail and we cannot delete it. Fix this by only decrementing the refcount of the evictee after we have removed it from our cache map. Add a test that caused a segfault previous to that change.
* | config: validate quoted section valueEdward Thomson2019-05-221-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | When we reach a whitespace after a section name, we assume that what will follow will be a quoted subsection name. Pass the current position of the line being parsed to the subsection parser, so that it can validate that subsequent characters are additional whitespace or a single quote. Previously we would begin parsing after the section name, looking for the first quotation mark. This allows invalid characters to embed themselves between the end of the section name and the first quotation mark, eg `[section foo "subsection"]`, which is illegal.
* | Merge pull request #5060 from pks-t/pks/refspec-nested-globsEdward Thomson2019-05-222-11/+25
|\ \ | | | | | | Loosen restriction on wildcard "*" refspecs
| * | refspec: fix transforming nested starsPatrick Steinhardt2019-04-261-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we transform a refspec with a component containing a glob, then we simply copy over the component until the next separator from the matching ref. E.g. if we have a ref "refs/heads/foo/bar" and a refspec "refs/heads/*/bar:refs/remotes/origin/*/bar", we: 1. Copy over everything until hitting the glob from the <dst> part: "refs/remotes/origin/". 2. Strip the common prefix of ref and <src> part until the glob, which is "refs/heads/". This leaves us with a ref of "foo/bar". 3. Copy from the ref until the next "/" separator, resulting in "refs/remotes/origin/foo". 4. Copy over the remaining part of the <dst> spec, which is "bar": "refs/remotes/origin/foo/bar". This worked just fine in a world where globs in refspecs were restricted such that a globbing component may only contain a single "*", only. But this restriction has been lifted, so that a glob component may be nested between other characters, causing the above algorithm to fail. Most notably the third step, where we copy until hitting the next "/" separator, might result in a wrong transformation. Given e.g. a ref "refs/gbranchg/head" and a refspec "refs/g*g/head:refs/remotes/origin/*", we'd also be copying the "g" between "branch" and "/" and end up with the wrong transformed ref "refs/remotes/origin/branchg". Instead of copying until the next component separator, we should copy until we hit the pattern after the "*". So in the above example, we'd copy until hitting the string "g/head".
| * | refs: loosen restriction on wildcard "*" refspecsPatrick Steinhardt2019-04-262-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In commit cd377f45c9 (refs: loosen restriction on wildcard "*" refspecs, 2015-07-22) in git.git, the restrictions on wildcard "*" refspecs has been loosened. While wildcards were previously only allowed if the component is a single "*", this was changed to also accept other patterns as part of the component. We never adapted to that change and still reject any wildcard patterns that aren't a single "*" only. Update our tests to reflect the upstream change and adjust our own code accordingly.
| * | tests: network::refspecs: add missing assert when parsing refspecPatrick Steinhardt2019-04-261-1/+1
| | |
* | | Merge pull request #4935 from libgit2/ethomson/pcreEdward Thomson2019-05-212-22/+95
|\ \ \ | | | | | | | | Use PCRE for our fallback regex engine when regcomp_l is unavailable
| * | | core::posix: skip some locale tests on win32Edward Thomson2019-05-191-7/+18
| | | |
| * | | tests: regcomp: use proper character classesEdward Thomson2019-05-191-2/+2
| | | | | | | | | | | | | | | | | | | | The '[[:digit:]]' and '[[:alpha:]]' classes require double brackets, not single.
| * | | tests: regcomp: test that regex functions succeedEdward Thomson2019-05-191-9/+9
| | | | | | | | | | | | | | | | | | | | The regex functions return nonzero (not necessarily negative values) on failure.
| * | | tests: regcomp: assert character groups do match normal alphabetPatrick Steinhardt2019-05-191-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | In order to avoid us being unable to match characters which are part of the normal US alphabet in certain weird languages, add two tests to catch this behavior.
| * | | tests: regex: restructure setup of localesPatrick Steinhardt2019-05-191-34/+29
| | | | | | | | | | | | | | | | | | | | | | | | In order to make it easier adding more locale-related tests, add a generalized framework handling initial setup of languages as well as the cleanup of them afterwards.
| * | | tests: regex: add test with LC_COLLATE being setEdward Thomson2019-05-191-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While we already have a test for `p_regexec` with `LC_CTYPE` being modified, `regexec` also alters behavior as soon as `LC_COLLATE` is being modified. Most importantly, `LC_COLLATE` changes the way how ranges are interpreted to just not handling them at all. Thus, ensure that either we use `regcomp_l` to avoid this, or that we've fallen back to our builtin regex functionality which also behaves properly.
| * | | tests: fix p_regcomp test not checking return typePatrick Steinhardt2019-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | While the test asserts that the error value indcates a non-value, it is actually never getting assigned to. Fix this.
| * | | regexec: prefix all regexec function calls with p_Edward Thomson2019-05-192-9/+9
| | |/ | |/| | | | | | | | | | | | | | | | Prefix all the calls to the the regexec family of functions with `p_`. This allows us to swap out all the regular expression functions with our own implementation. Move the declarations to `posix_regex.h` for simpler inclusion.
* | | remote: add callback to resolve URLs before connectingErik Aigner2019-05-212-9/+78
| | | | | | | | | | | | | | | | | | Since libssh2 doesn't read host configuration from the config file, this callback can be used to hand over URL resolving to the client without touching the SSH implementation itself.
* | | ignore: test we can handle an ignore file with BOMEdward Thomson2019-05-191-0/+23
|/ / | | | | | | Ensure that we can read and parse an ignore file with a UTF8 BOM.
* | Merge branch 'pr/5061'Edward Thomson2019-05-121-0/+18
|\ \
| * | revwalk: fix memory leak in error handlingHeiko Voigt2019-05-101-0/+9
| | | | | | | | | | | | | | | This is not implemented and should fail, but it should also not leak. To allow the memory debugger to find leaks and fix this one we test this.
| * | git_revwalk_push_range: do not crash if range is missingHeiko Voigt2019-05-031-0/+9
| |/ | | | | | | | | If someone passes just one ref (i.e. "master") and misses passing the range we should be nice and return an error code instead of crashing.
* | Merge pull request #5057 from eaigner/merge-rebase-onto-nameEdward Thomson2019-05-121-0/+10
|\ \ | | | | | | rebase: orig_head and onto accessors
| * | rebase: orig_head and onto accessorsErik Aigner2019-04-211-0/+10
| |/ | | | | | | | | | | | | | | The rebase struct stores fields with information about the current rebase process, which were not accessible via a public interface. Accessors for getting the `orig_head` and `onto` branch names and object ids have been added.
* | Correctly write to missing locked global configIan Hattendorf2019-04-291-0/+30
|/ | | | | | | Opening a default config when ~/.gitconfig doesn't exist, locking it, and attempting to write to it causes an assertion failure. Treat non-existent global config file content as an empty string.
* Merge pull request #5050 from libgit2/ethomson/windows_init_traversalEdward Thomson2019-04-171-0/+12
|\ | | | | git_repository_init: stop traversing at windows root
| * git_repository_init: stop traversing at windows rootethomson/windows_init_traversalEdward Thomson2019-04-171-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stop traversing the filesystem at the Windows directory root. We were calculating the filesystem root for the given directory to create, and walking up the filesystem hierarchy. We intended to stop when the traversal path length is equal to the root path length (ie, stopping at the root, since no path may be shorter than the root path). However, on Windows, the root path may be specified in two different ways, as either `Z:` or `Z:\`, where `Z:` is the current drive letter. `git_path_dirname_r` returns the path _without_ a trailing slash, even for the Windows root. As a result, during traversal, we need to test that the traversal path is _less than or equal to_ the root path length to determine if we've hit the root to ensure that we stop when our traversal path is `Z:` and our calculated root path was `Z:\`.
* | Merge pull request #5027 from ddevault/masterPatrick Steinhardt2019-04-162-0/+28
|\ \ | |/ |/| patch_parse.c: Handle CRLF in parse_header_start
| * patch_parse.c: Handle CRLF in parse_header_startDrew DeVault2019-04-052-0/+28
| |
* | ignore: treat paths with trailing "/" as directoriesPatrick Steinhardt2019-04-051-0/+16
|/ | | | | | | | | | | | | | | | | | | | | | | | The function `git_ignore_path_is_ignored` is there to test the ignore status of paths that need not necessarily exist inside of a repository. This has the implication that for a given path, we cannot always decide whether it references a directory or a file, and we need to distinguish those cases because ignore rules may treat those differently. E.g. given the following gitignore file: * !/**/ we'd only want to unignore directories, while keeping files ignored. But still, calling `git_ignore_path_is_ignored("dir/")` will say that this directory is ignored because it treats "dir/" as a file path. As said, the `is_ignored` function cannot always decide whether the given path is a file or directory, and thus it may produce wrong results in some cases. While this is unfixable in the general case, we can do better when we are being passed a path name with a trailing path separator (e.g. "dir/") and always treat them as directories.
* Merge pull request #4874 from tiennou/test/4615Edward Thomson2019-04-042-0/+90
|\ | | | | Test that largefiles can be read through the tree API
| * tests: test largefiles on win32Edward Thomson2019-04-041-4/+0
| |
| * p_fallocate: add a test for our implementationEdward Thomson2019-02-221-0/+41
| |
| * tests: test that largefiles can be read through the tree APIEtienne Samson2019-01-301-0/+53
| |
* | Merge pull request #5034 from pks-t/pks/symlinked-user-configEdward Thomson2019-04-042-0/+62
|\ \ | | | | | | Tests for symlinked user config
| * | tests: config: assure that we can read symlinked global configurationPatrick Steinhardt2019-03-291-0/+17
| | | | | | | | | | | | | | | | | | According to reports, libgit2 is unable to read a global configuration file that is simply a symlink to the real configuration. Write a (succeeding) test that shows that libgit2 _is_ correctly able to do so.