]> gitweb.factorcode.org Git - factor.git/blob - extra/git/git-tests.factor
git: Add repo that can do some git things in native Factor.
[factor.git] / extra / git / git-tests.factor
1 ! Copyright (C) 2015 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: fry git io io.directories io.encodings.utf8 io.files.temp
4 io.files.unique io.launcher kernel sequences tools.test ;
5 IN: git.tests
6
7 : run-process-stdout ( process -- string )
8     >process utf8 [ contents ] with-process-reader ;
9
10 : with-empty-test-git-repo ( quot -- )
11     '[
12         [
13             { "git" "init" } run-process drop
14             @
15         ] cleanup-unique-directory
16     ] with-temp-directory ; inline
17
18 : with-zero-byte-file-repo ( quot -- )
19     '[
20         "empty-file" touch-file
21         { "git" "add" "empty-file" } run-process drop
22         { "git" "commit" "-m" "initial commit of empty file" } run-process drop
23         @
24     ] with-empty-test-git-repo ; inline
25
26 { "refs/heads/master" } [
27     [ git-head-ref ] with-empty-test-git-repo
28 ] unit-test
29
30
31 { } [
32     [
33         ! "." t recursive-directory-files
34         git-log [ commit. ] each
35     ] with-zero-byte-file-repo
36 ] unit-test
37
38 { } [
39     [
40         { "git" "log" } run-process-stdout print
41     ] with-zero-byte-file-repo
42 ] unit-test