diff options
author | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2015-11-04 15:37:15 +0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2015-11-27 16:20:54 -0800 |
commit | e5bfdcd9a47ed6e933f13944ae389c2add81fdf3 (patch) | |
tree | c22230283245f12bb8c0c5455a47deb8ea81cd46 /src/fish_tests.cpp | |
parent | b7f13b468566ba5f147d261fb2c9376bf9d431e6 (diff) |
fish_tests.cpp: use temporary path for completion tests
Closes #2322
Diffstat (limited to 'src/fish_tests.cpp')
-rw-r--r-- | src/fish_tests.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 41a0a90f..6acefbaa 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -2110,20 +2110,24 @@ static void test_complete(void) do_test(completions.at(0).completion == L"$Foo1"); do_test(completions.at(1).completion == L"$Bar1"); + if (system("mkdir -p '/tmp/complete_test/'")) err(L"mkdir failed"); + if (system("touch '/tmp/complete_test/testfile'")) err(L"touch failed"); + if (system("chmod 700 '/tmp/complete_test/testfile'")) err(L"chmod failed"); + completions.clear(); - complete(L"echo (/bin/mkdi", completions, COMPLETION_REQUEST_DEFAULT); + complete(L"echo (/tmp/complete_test/testfil", completions, COMPLETION_REQUEST_DEFAULT); do_test(completions.size() == 1); - do_test(completions.at(0).completion == L"r"); + do_test(completions.at(0).completion == L"e"); completions.clear(); - complete(L"echo (ls /bin/mkdi", completions, COMPLETION_REQUEST_DEFAULT); + complete(L"echo (ls /tmp/complete_test/testfil", completions, COMPLETION_REQUEST_DEFAULT); do_test(completions.size() == 1); - do_test(completions.at(0).completion == L"r"); + do_test(completions.at(0).completion == L"e"); completions.clear(); - complete(L"echo (command ls /bin/mkdi", completions, COMPLETION_REQUEST_DEFAULT); + complete(L"echo (command ls /tmp/complete_test/testfil", completions, COMPLETION_REQUEST_DEFAULT); do_test(completions.size() == 1); - do_test(completions.at(0).completion == L"r"); + do_test(completions.at(0).completion == L"e"); /* Add a function and test completing it in various ways */ struct function_data_t func_data = {}; @@ -2174,8 +2178,6 @@ static void test_complete(void) perror("getcwd"); exit(-1); } - if (system("mkdir -p '/tmp/complete_test/'")) err(L"mkdir failed"); - if (system("touch '/tmp/complete_test/testfile'")) err(L"touch failed"); if (chdir("/tmp/complete_test/")) err(L"chdir failed"); complete(L"cat te", completions, COMPLETION_REQUEST_DEFAULT); do_test(completions.size() == 1); |