[pacman-dev] [PATCH 1/2] Add tests for native and foreign flags
Add tests to check that pacman recognizes -Qm and -Qn as valid options and -Qmn as an invalid option Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> --- test/pacman/tests/TESTS | 3 +++ test/pacman/tests/pacman006.py | 14 ++++++++++++++ test/pacman/tests/pacman007.py | 10 ++++++++++ test/pacman/tests/pacman008.py | 5 +++++ 4 files changed, 32 insertions(+) create mode 100644 test/pacman/tests/pacman006.py create mode 100644 test/pacman/tests/pacman007.py create mode 100644 test/pacman/tests/pacman008.py diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS index fc6a7e8..0a0457a 100644 --- a/test/pacman/tests/TESTS +++ b/test/pacman/tests/TESTS @@ -68,6 +68,9 @@ TESTS += test/pacman/tests/pacman002.py TESTS += test/pacman/tests/pacman003.py TESTS += test/pacman/tests/pacman004.py TESTS += test/pacman/tests/pacman005.py +TESTS += test/pacman/tests/pacman006.py +TESTS += test/pacman/tests/pacman007.py +TESTS += test/pacman/tests/pacman008.py TESTS += test/pacman/tests/provision001.py TESTS += test/pacman/tests/provision002.py TESTS += test/pacman/tests/provision003.py diff --git a/test/pacman/tests/pacman006.py b/test/pacman/tests/pacman006.py new file mode 100644 index 0000000..9a2ea92 --- /dev/null +++ b/test/pacman/tests/pacman006.py @@ -0,0 +1,14 @@ +self.description = "Test command line option (-Qm)" + +p = pmpkg("foobar") +p.files = ["bin/foobar"] +self.addpkg2db("local", p) + +p2 = pmpkg("dummy") +p2.files = ["bin/dummy", + "usr/man/man1/dummy.1"] +self.addpkg2db("sync", p2) + +self.args = "-Qm" + +self.addrule("PACMAN_RETCODE=0") diff --git a/test/pacman/tests/pacman007.py b/test/pacman/tests/pacman007.py new file mode 100644 index 0000000..a8a2701 --- /dev/null +++ b/test/pacman/tests/pacman007.py @@ -0,0 +1,10 @@ +self.description = "Test command line option (-Qn)" + +p = pmpkg("foobar") +p.files = ["bin/foobar"] +self.addpkg2db("local", p) +self.addpkg2db("sync", p) + +self.args = "-Qn" + +self.addrule("PACMAN_RETCODE=0") diff --git a/test/pacman/tests/pacman008.py b/test/pacman/tests/pacman008.py new file mode 100644 index 0000000..589b2ba --- /dev/null +++ b/test/pacman/tests/pacman008.py @@ -0,0 +1,5 @@ +self.description = "Test invalid combination of command line options (-Qmn)" + +self.args = "-Qmn" + +self.addrule("PACMAN_RETCODE=1") -- 1.8.4.1
We should print an error if both --native and --foreign are passed as options to -Q. Instead we are currently printing an error even if only one of them is passed to -Q. Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> --- src/pacman/pacman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index f485692..5349517 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -600,7 +600,7 @@ static void checkargs_query(void) } invalid_opt(config->op_q_deps && config->op_q_explicit, "--deps", "--explicit"); - invalid_opt(config->op_q_locality & (PKG_LOCALITY_NATIVE | PKG_LOCALITY_FOREIGN), + invalid_opt(!(config->op_q_locality ^ (PKG_LOCALITY_NATIVE | PKG_LOCALITY_FOREIGN)), "--native", "--foreign"); } -- 1.8.4.1
On 21/10/13 17:11, Chirantan Ekbote wrote:
We should print an error if both --native and --foreign are passed as options to -Q. Instead we are currently printing an error even if only one of them is passed to -Q.
I'm going with the patch I submitted earlier [1] because I find it much easier to see what is being tested. [1] https://patchwork.archlinux.org/patch/1639/ Allan
Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> --- src/pacman/pacman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index f485692..5349517 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -600,7 +600,7 @@ static void checkargs_query(void) }
invalid_opt(config->op_q_deps && config->op_q_explicit, "--deps", "--explicit"); - invalid_opt(config->op_q_locality & (PKG_LOCALITY_NATIVE | PKG_LOCALITY_FOREIGN), + invalid_opt(!(config->op_q_locality ^ (PKG_LOCALITY_NATIVE | PKG_LOCALITY_FOREIGN)), "--native", "--foreign"); }
On 21/10/13 17:10, Chirantan Ekbote wrote:
Add tests to check that pacman recognizes -Qm and -Qn as valid options and -Qmn as an invalid option
Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com>
Signed-off-by: Allan
On 10/21/13 at 03:10am, Chirantan Ekbote wrote:
Add tests to check that pacman recognizes -Qm and -Qn as valid options and -Qmn as an invalid option
Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com> --- test/pacman/tests/TESTS | 3 +++ test/pacman/tests/pacman006.py | 14 ++++++++++++++ test/pacman/tests/pacman007.py | 10 ++++++++++ test/pacman/tests/pacman008.py | 5 +++++ 4 files changed, 32 insertions(+) create mode 100644 test/pacman/tests/pacman006.py create mode 100644 test/pacman/tests/pacman007.py create mode 100644 test/pacman/tests/pacman008.py
diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS index fc6a7e8..0a0457a 100644 --- a/test/pacman/tests/TESTS +++ b/test/pacman/tests/TESTS @@ -68,6 +68,9 @@ TESTS += test/pacman/tests/pacman002.py TESTS += test/pacman/tests/pacman003.py TESTS += test/pacman/tests/pacman004.py TESTS += test/pacman/tests/pacman005.py +TESTS += test/pacman/tests/pacman006.py +TESTS += test/pacman/tests/pacman007.py +TESTS += test/pacman/tests/pacman008.py TESTS += test/pacman/tests/provision001.py TESTS += test/pacman/tests/provision002.py TESTS += test/pacman/tests/provision003.py diff --git a/test/pacman/tests/pacman006.py b/test/pacman/tests/pacman006.py new file mode 100644 index 0000000..9a2ea92 --- /dev/null +++ b/test/pacman/tests/pacman006.py @@ -0,0 +1,14 @@ +self.description = "Test command line option (-Qm)" + +p = pmpkg("foobar") +p.files = ["bin/foobar"] +self.addpkg2db("local", p) + +p2 = pmpkg("dummy") +p2.files = ["bin/dummy", + "usr/man/man1/dummy.1"] +self.addpkg2db("sync", p2) + +self.args = "-Qm" + +self.addrule("PACMAN_RETCODE=0") diff --git a/test/pacman/tests/pacman007.py b/test/pacman/tests/pacman007.py new file mode 100644 index 0000000..a8a2701 --- /dev/null +++ b/test/pacman/tests/pacman007.py @@ -0,0 +1,10 @@ +self.description = "Test command line option (-Qn)" + +p = pmpkg("foobar") +p.files = ["bin/foobar"] +self.addpkg2db("local", p) +self.addpkg2db("sync", p) + +self.args = "-Qn" + +self.addrule("PACMAN_RETCODE=0")
The filelists for both of these are unnecessary and we should probably go ahead and test the output to make sure the correct package is being listed.
diff --git a/test/pacman/tests/pacman008.py b/test/pacman/tests/pacman008.py new file mode 100644 index 0000000..589b2ba --- /dev/null +++ b/test/pacman/tests/pacman008.py @@ -0,0 +1,5 @@ +self.description = "Test invalid combination of command line options (-Qmn)" + +self.args = "-Qmn" + +self.addrule("PACMAN_RETCODE=1")
You need to test the output here too to make sure we're getting the correct error. pacman also returns 1 if no packages match (which is guaranteed with -mn) or no sync repos are configured.
-- 1.8.4.1
participants (3)
-
Allan McRae
-
Andrew Gregory
-
Chirantan Ekbote