From be3cb6ecadec1bcb75c0701098cd9c754c48c55b Mon Sep 17 00:00:00 2001 From: David Gnedt Date: Sat, 31 Jul 2021 15:52:09 +0200 Subject: [PATCH 1/5] Add macOS 10.15 runner to CI pipeline --- .github/workflows/ci-python3.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-python3.yml b/.github/workflows/ci-python3.yml index 5bc14ab..486ad84 100644 --- a/.github/workflows/ci-python3.yml +++ b/.github/workflows/ci-python3.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: - os: [ ubuntu-20.04, ubuntu-18.04 ] + os: [ ubuntu-20.04, ubuntu-18.04, macos-10.15 ] python-version: [ '3.5', '3.6', '3.7', '3.8', '3.9' ] # Steps represent a sequence of tasks that will be executed as part of the job @@ -32,9 +32,13 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install test dependencies + - name: Install Linux test dependencies + if: runner.os == 'Linux' run: | sudo apt install coreutils cksfv + + - name: Install Python test dependencies + run: | pip install pyroma pip install check-manifest pip install twine From e24334bbed45fc7cd05b856c620948c53922aace Mon Sep 17 00:00:00 2001 From: David Gnedt Date: Sun, 1 Aug 2021 00:25:59 +0200 Subject: [PATCH 2/5] Skip some incompatible tests on case-insenstive filesystems --- test/test_caching.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/test/test_caching.py b/test/test_caching.py index 628e00a..d694355 100644 --- a/test/test_caching.py +++ b/test/test_caching.py @@ -68,6 +68,10 @@ def mkfile(self, name, contents): f.write(contents) return name + def readfile(self, name): + with open(name, 'rt') as f: + return f.read() + class AbsPathKeyTest(AbsTestCase): def test_get_path_key(self): @@ -136,6 +140,12 @@ def test_nocase_findfile(self): self.mkfile('aAaA/Aaa2', '2') self.mkfile('aAaA/AAa2', '3') + a2_content = self.readfile('aAaA/Aaa2') + self.assertIn(a2_content, ('2', '3')) + fs_case_sensitive = a2_content == '2' + if not fs_case_sensitive: + print('Skipping some tests due to case-insensitive filesystem') + self.assertEquals(a1, cache.nocase_findfile(self.mkpath('aaAA/aaa1'))) with self.assertRaises(IOError) as cm: cache.nocase_findfile(self.mkpath('aaAb/aaa1')) @@ -145,18 +155,24 @@ def test_nocase_findfile(self): cache.nocase_findfile(self.mkpath('aaAA/aab1')) self.assertEquals(errno.ENOENT, cm.exception.errno) - with self.assertRaises(IOError) as cm: - cache.nocase_findfile(self.mkpath('aaAA/aaa2')) - self.assertEquals(errno.EEXIST, cm.exception.errno) + if fs_case_sensitive: + with self.assertRaises(IOError) as cm: + cache.nocase_findfile(self.mkpath('aaAA/aaa2')) + self.assertEquals(errno.EEXIST, cm.exception.errno) def test_nocase_findfile_parent(self): cache = FileInfoCache() self.mkfile('aaaA/aaA1', '1') + fs_case_sensitive = not os.path.exists('aAaA') self.mkfile('aAaA/aaa2', '2') + if not fs_case_sensitive: + print('Skipping some tests due to case-insensitive filesystem') + # right now we don't handle this case, though it would be possible # to generate all possible matches and see if the number is exactly # one. - with self.assertRaises(IOError) as cm: - cache.nocase_findfile(self.mkpath('aaAA/aaa2')) - self.assertEquals(errno.EEXIST, cm.exception.errno) + if fs_case_sensitive: + with self.assertRaises(IOError) as cm: + cache.nocase_findfile(self.mkpath('aaAA/aaa2')) + self.assertEquals(errno.EEXIST, cm.exception.errno) From dd4a488e429b0e80b30a4825ed9dc8693c2af91a Mon Sep 17 00:00:00 2001 From: David Gnedt Date: Sat, 31 Jul 2021 01:34:45 +0200 Subject: [PATCH 3/5] Chdir outside temp directory before removing it to make Windows happy --- test/test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test.py b/test/test.py index 2d230ae..c406184 100755 --- a/test/test.py +++ b/test/test.py @@ -1874,6 +1874,7 @@ def copytree(src, dst, ignore=None): # copy the testdata into a temp dir in order to avoid .svn dirs breaking some tests tmpdatapath = tempfile.mkdtemp() +orig_path = os.getcwd() try: copytree(cfvtest.datapath, tmpdatapath, ignore=['.svn']) os.chdir(tmpdatapath) # do this after the setcfv, since the user may have specified a relative path @@ -1889,4 +1890,5 @@ def copytree(src, dst, ignore=None): failed += all_tests() sys.exit(failed) finally: + os.chdir(orig_path) shutil.rmtree(tmpdatapath) From 60879f0e521fbea61c8256e5a4d1d097c70635b4 Mon Sep 17 00:00:00 2001 From: David Gnedt Date: Sat, 31 Jul 2021 01:36:00 +0200 Subject: [PATCH 4/5] Fix caching unit tests to not assume a specific directory separator --- test/test_caching.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/test_caching.py b/test/test_caching.py index d694355..56efddf 100644 --- a/test/test_caching.py +++ b/test/test_caching.py @@ -136,35 +136,35 @@ def test_rename(self): class RelPathKeyTest(RelTestCase): def test_nocase_findfile(self): cache = FileInfoCache() - a1 = self.mkfile('aAaA/AaA1', '1') - self.mkfile('aAaA/Aaa2', '2') - self.mkfile('aAaA/AAa2', '3') + a1 = self.mkfile(os.path.join('aAaA', 'AaA1'), '1') + self.mkfile(os.path.join('aAaA', 'Aaa2'), '2') + self.mkfile(os.path.join('aAaA', 'AAa2'), '3') - a2_content = self.readfile('aAaA/Aaa2') + a2_content = self.readfile(os.path.join('aAaA', 'Aaa2')) self.assertIn(a2_content, ('2', '3')) fs_case_sensitive = a2_content == '2' if not fs_case_sensitive: print('Skipping some tests due to case-insensitive filesystem') - self.assertEquals(a1, cache.nocase_findfile(self.mkpath('aaAA/aaa1'))) + self.assertEquals(a1, cache.nocase_findfile(self.mkpath(os.path.join('aaAA', 'aaa1')))) with self.assertRaises(IOError) as cm: - cache.nocase_findfile(self.mkpath('aaAb/aaa1')) + cache.nocase_findfile(self.mkpath(os.path.join('aaAb', 'aaa1'))) self.assertEquals(errno.ENOENT, cm.exception.errno) with self.assertRaises(IOError) as cm: - cache.nocase_findfile(self.mkpath('aaAA/aab1')) + cache.nocase_findfile(self.mkpath(os.path.join('aaAA', 'aab1'))) self.assertEquals(errno.ENOENT, cm.exception.errno) if fs_case_sensitive: with self.assertRaises(IOError) as cm: - cache.nocase_findfile(self.mkpath('aaAA/aaa2')) + cache.nocase_findfile(self.mkpath(os.path.join('aaAA', 'aaa2'))) self.assertEquals(errno.EEXIST, cm.exception.errno) def test_nocase_findfile_parent(self): cache = FileInfoCache() - self.mkfile('aaaA/aaA1', '1') + self.mkfile(os.path.join('aaaA', 'aaA1'), '1') fs_case_sensitive = not os.path.exists('aAaA') - self.mkfile('aAaA/aaa2', '2') + self.mkfile(os.path.join('aAaA', 'aaa2'), '2') if not fs_case_sensitive: print('Skipping some tests due to case-insensitive filesystem') @@ -174,5 +174,5 @@ def test_nocase_findfile_parent(self): # one. if fs_case_sensitive: with self.assertRaises(IOError) as cm: - cache.nocase_findfile(self.mkpath('aaAA/aaa2')) + cache.nocase_findfile(self.mkpath(os.path.join('aaAA', 'aaa2'))) self.assertEquals(errno.EEXIST, cm.exception.errno) From fdec15fb281ca996a2d6ee62a663c63188866a0e Mon Sep 17 00:00:00 2001 From: David Gnedt Date: Sat, 31 Jul 2021 01:58:10 +0200 Subject: [PATCH 5/5] Fix unit tests for strippath to also use absolute instead of relative paths on Windows --- lib/cfv/osutil.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/cfv/osutil.py b/lib/cfv/osutil.py index f99b030..1d38fde 100644 --- a/lib/cfv/osutil.py +++ b/lib/cfv/osutil.py @@ -88,19 +88,19 @@ def path_split(filename): def strippath(filename, num='a', _splitdrivere=re.compile(r'[a-z]:[/\\]', re.I)): """Strip off path components from the left side of the filename. - >>> strippath(os.path.join('c:','foo','bar','baz')) + >>> strippath(os.path.join('c:' + os.sep,'foo','bar','baz')) 'baz' - >>> path_split(strippath(os.path.join('c:','foo','bar','baz'), 'n')) + >>> path_split(strippath(os.path.join('c:' + os.sep,'foo','bar','baz'), 'n')) ['c:', 'foo', 'bar', 'baz'] - >>> path_split(strippath(os.path.join('c:','foo','bar','baz'), 0)) + >>> path_split(strippath(os.path.join('c:' + os.sep,'foo','bar','baz'), 0)) ['foo', 'bar', 'baz'] >>> path_split(strippath(os.path.join(os.sep,'foo','bar','baz'), 0)) ['foo', 'bar', 'baz'] - >>> path_split(strippath(os.path.join('c:','foo','bar','baz'), 1)) + >>> path_split(strippath(os.path.join('c:' + os.sep,'foo','bar','baz'), 1)) ['bar', 'baz'] - >>> strippath(os.path.join('c:','foo','bar','baz'), 2) + >>> strippath(os.path.join('c:' + os.sep,'foo','bar','baz'), 2) 'baz' - >>> strippath(os.path.join('c:','foo','bar','baz'), 3) + >>> strippath(os.path.join('c:' + os.sep,'foo','bar','baz'), 3) 'baz' """ if num == 'a': # split all the path off