Exemple #1
0
 def test_exclude_files_glob(self):
     roots = ["dir/subdir1/*.js", "dir/subdir2/test21.*"]
     test_list = selector._TestList(self.test_file_explorer, roots)
     test_list.exclude_files(["dir/subdir2/*.js"])
     selected, excluded = test_list.get_tests()
     self.assertEqual(["dir/subdir1/test11.js", "dir/subdir1/test12.js"], selected)
     self.assertEqual(["dir/subdir2/test21.js"], excluded)
Exemple #2
0
 def test_tests_are_not_files(self):
     roots = ["a", "b"]
     test_list = selector._TestList(self.test_file_explorer, roots, tests_are_files=False)
     with self.assertRaises(TypeError):
         test_list.include_files([])
     with self.assertRaises(TypeError):
         test_list.exclude_files([])
Exemple #3
0
 def test_roots_with_glob(self):
     glob_roots = ["dir/subdir1/*.js"]
     expected_roots = ["dir/subdir1/test11.js", "dir/subdir1/test12.js"]
     test_list = selector._TestList(self.test_file_explorer, glob_roots)
     selected, excluded = test_list.get_tests()
     self.assertEqual(expected_roots, selected)
     self.assertEqual([], excluded)
Exemple #4
0
 def test_roots_normpath(self):
     roots = ["dir/a/abc.js", "dir/b/xyz.js"]
     test_list = selector._TestList(self.test_file_explorer, roots, tests_are_files=False)
     selected, excluded = test_list.get_tests()
     for root_file, selected_file in zip(roots, selected):
         self.assertEqual(os.path.normpath(root_file), selected_file)
     self.assertEqual([], excluded)
Exemple #5
0
 def test_include_tests_no_force(self):
     roots = ["dir/subdir1/*.js", "dir/subdir2/test21.*"]
     test_list = selector._TestList(self.test_file_explorer, roots)
     test_list.exclude_files(["dir/subdir1/test11.js"])
     test_list.include_files(["dir/subdir1/test11.js"], force=False)
     selected, excluded = test_list.get_tests()
     self.assertEqual([], selected)
     self.assertEqual(
         ["dir/subdir1/test11.js", "dir/subdir1/test12.js", "dir/subdir2/test21.js"], excluded)
Exemple #6
0
 def test_include_any_pattern(self):
     roots = ["dir/subdir1/*.js", "dir/subdir2/test21.*", "dir/subdir3/a/test3a1.js"]
     # 1 pattern and 1 matching
     test_list = selector._TestList(self.test_file_explorer, roots)
     test_list.include_any_pattern(["dir/*3/a/*"])
     selected, excluded = test_list.get_tests()
     self.assertEqual(["dir/subdir3/a/test3a1.js"], selected)
     self.assertEqual(["dir/subdir1/test11.js",
                       "dir/subdir1/test12.js",
                       "dir/subdir2/test21.js"], excluded)
     # 1 pattern and 0 matching
     test_list = selector._TestList(self.test_file_explorer, roots)
     test_list.include_any_pattern(["dir/*4/a/*"])
     selected, excluded = test_list.get_tests()
     self.assertEqual([], selected)
     self.assertEqual(["dir/subdir1/test11.js",
                       "dir/subdir1/test12.js",
                       "dir/subdir2/test21.js",
                       "dir/subdir3/a/test3a1.js"], excluded)
     # 3 patterns and 1 matching
     test_list = selector._TestList(self.test_file_explorer, roots)
     test_list.include_any_pattern(["dir/*3/a/*", "notmaching/*", "notmatching2/*.js"])
     selected, excluded = test_list.get_tests()
     self.assertEqual(["dir/subdir3/a/test3a1.js"], selected)
     self.assertEqual(["dir/subdir1/test11.js",
                       "dir/subdir1/test12.js",
                       "dir/subdir2/test21.js"], excluded)
     # 3 patterns and 0 matching
     test_list = selector._TestList(self.test_file_explorer, roots)
     test_list.include_any_pattern(["dir2/*3/a/*", "notmaching/*", "notmatching2/*.js"])
     selected, excluded = test_list.get_tests()
     self.assertEqual([], selected)
     self.assertEqual(["dir/subdir1/test11.js",
                       "dir/subdir1/test12.js",
                       "dir/subdir2/test21.js",
                       "dir/subdir3/a/test3a1.js"], excluded)
     # 3 patterns and 3 matching
     test_list = selector._TestList(self.test_file_explorer, roots)
     test_list.include_any_pattern(["dir/*1/*11*", "dir/subdir3/**", "dir/subdir2/*.js"])
     selected, excluded = test_list.get_tests()
     self.assertEqual(["dir/subdir1/test11.js", "dir/subdir2/test21.js",
                       "dir/subdir3/a/test3a1.js"],
                      selected)
     self.assertEqual(["dir/subdir1/test12.js"], excluded)
Exemple #7
0
    def test_match_tag_expression(self):
        roots = ["dir/subdir1/*.js", "dir/subdir2/test21.*"]
        test_list = selector._TestList(self.test_file_explorer, roots)
        expression = selector.make_expression(
            {"$anyOf": [{"$allOf": ["tag1", "tag2"]}, "tag3", {"$allOf": ["tag5", "tag6"]}]})

        def get_tags(test_file):
            return self.test_file_explorer.jstest_tags(test_file)

        test_list.match_tag_expression(expression, get_tags)
        selected, excluded = test_list.get_tests()
        self.assertEqual(["dir/subdir1/test11.js", "dir/subdir1/test12.js"], selected)
        self.assertEqual(["dir/subdir2/test21.js"], excluded)
Exemple #8
0
 def test_exclude_files_no_match(self):
     roots = ["dir/subdir1/*.js", "dir/subdir2/test21.*"]
     test_list = selector._TestList(self.test_file_explorer, roots)
     with self.assertRaisesRegexp(ValueError, "Unrecognized test file: .*$"):
         test_list.exclude_files(["dir/subdir2/test26.js"])
Exemple #9
0
 def test_roots_unknown_file(self):
     roots = ["dir/subdir1/unknown"]
     with self.assertRaisesRegexp(ValueError, "Unrecognized test file: dir/subdir1/unknown"):
         selector._TestList(self.test_file_explorer, roots, tests_are_files=True)
Exemple #10
0
 def test_roots_with_unmatching_glob(self):
     glob_roots = ["unknown/subdir1/*.js"]
     test_list = selector._TestList(self.test_file_explorer, glob_roots)
     selected, excluded = test_list.get_tests()
     self.assertEqual([], selected)
     self.assertEqual([], excluded)
Exemple #11
0
 def test_roots(self):
     roots = ["a", "b"]
     test_list = selector._TestList(self.test_file_explorer, roots, tests_are_files=False)
     selected, excluded = test_list.get_tests()
     self.assertEqual(roots, selected)
     self.assertEqual([], excluded)
Exemple #12
0
 def test_exclude_files_no_match(self):
     roots = ["dir/subdir1/*.js", "dir/subdir2/test21.*"]
     test_list = selector._TestList(self.test_file_explorer, roots)
     with self.assertRaisesRegex(ValueError, "Unrecognized test file: .*$"):
         test_list.exclude_files(["dir/subdir2/test26.js"])
Exemple #13
0
 def test_roots_with_unmatching_glob(self):
     glob_roots = ["unknown/subdir1/*.js"]
     test_list = selector._TestList(self.test_file_explorer, glob_roots)
     selected, excluded = test_list.get_tests()
     self.assertEqual([], selected)
     self.assertEqual([], excluded)
Exemple #14
0
 def test_roots_unknown_file(self):
     roots = ["dir/subdir1/unknown"]
     with self.assertRaisesRegex(ValueError, "Unrecognized test file: dir/subdir1/unknown"):
         selector._TestList(self.test_file_explorer, roots, tests_are_files=True)
Exemple #15
0
 def test_roots(self):
     roots = ["a", "b"]
     test_list = selector._TestList(self.test_file_explorer, roots, tests_are_files=False)
     selected, excluded = test_list.get_tests()
     self.assertEqual(roots, selected)
     self.assertEqual([], excluded)