nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ARMmbed/yotta
Pull request #484 (2015-10-13 08:47:33)

fix default ignore pattern for vim swap files; add test for this


Patch:
diff --git a/yotta/lib/pack.py b/yotta/lib/pack.py
index 0dc1922..3b5045b 100644
--- a/yotta/lib/pack.py
+++ b/yotta/lib/pack.py
@@ -43,7 +43,7 @@ Default_Publish_Ignore = [
     '/yotta_targets',
     '/build',
     '.DS_Store',
-    '.sw[ponml]',
+    '*.sw[ponml]',
     '*~',
     '._.*',
     '.yotta.json'


Test patch:
diff --git a/yotta/test/ignores.py b/yotta/test/ignores.py
index 4f640f0..3a5f8e9 100644
--- a/yotta/test/ignores.py
+++ b/yotta/test/ignores.py
@@ -102,23 +102,37 @@ int main(){
 '''
 }
 
+Default_Test_Files = {
+    'module.json': '''
+{
+  "name": "test-testdep-f",
+  "version": "0.0.6",
+  "license": "Apache-2.0"
+}'''
+}
+
 def isWindows():
     # can't run tests that hit github without an authn token
     return os.name == 'nt'
 
-class TestPackIgnores(unittest.TestCase):
-    def setUp(self):
-        self.test_dir = tempfile.mkdtemp()
+def writeTestFiles(files):
+    test_dir = tempfile.mkdtemp()
+    for path, contents in files.items():
+        path_dir, file_name =  os.path.split(path)
+        path_dir = os.path.join(test_dir, path_dir)
+        mkDirP(path_dir)
+        with open(os.path.join(path_dir, file_name), 'w') as f:
+            f.write(contents)
+    return test_dir
 
-        for path, contents in Test_Files.items():
-            path_dir, file_name =  os.path.split(path)
-            path_dir = os.path.join(self.test_dir, path_dir)
-            mkDirP(path_dir)
-            with open(os.path.join(path_dir, file_name), 'w') as f:
-                f.write(contents)
+class TestPackIgnores(unittest.TestCase):
+    @classmethod
+    def setUpClass(cls):
+        cls.test_dir = writeTestFiles(Test_Files)
 
-    def tearDown(self):
-        rmRf(self.test_dir)
+    @classmethod
+    def tearDownClass(cls):
+        rmRf(cls.test_dir)
 
     def test_absolute_ignores(self):
         c = component.Component(self.test_dir)
@@ -143,6 +157,24 @@ class TestPackIgnores(unittest.TestCase):
         self.assertTrue(c.ignores('test/anothertest/ignoredbyfname.c'))
         self.assertTrue(c.ignores('test/someothertest/alsoignored.c'))
 
+    def test_default_ignores(self):
+        default_test_dir = writeTestFiles(Default_Test_Files)
+        c = component.Component(default_test_dir)
+        self.assertTrue(c.ignores('.something.c.swp'))
+        self.assertTrue(c.ignores('.something.c~'))
+        self.assertTrue(c.ignores('path/to/.something.c.swm'))
+        self.assertTrue(c.ignores('path/to/.something.c~'))
+        self.assertTrue(c.ignores('.DS_Store'))
+        self.assertTrue(c.ignores('.git'))
+        self.assertTrue(c.ignores('.hg'))
+        self.assertTrue(c.ignores('.svn'))
+        self.assertTrue(c.ignores('yotta_modules'))
+        self.assertTrue(c.ignores('yotta_targets'))
+        self.assertTrue(c.ignores('build'))
+        self.assertTrue(c.ignores('.yotta.json'))
+
+        rmRf(default_test_dir)
+
     def test_comments(self):
         c = component.Component(self.test_dir)
         self.assertFalse(c.ignores('comment'))