{"thread":{"id":"60906","subject":"[GSOC][RFC] microproject: use test_path_is_* functions in test scripts","startedAt":"2024-02-13T15:44:55Z","lastAt":"2024-02-14T10:20:18Z","messageCount":5,"participants":["Vincenzo MEZZELA","Christian Couder","Eric Sunshine","Junio C Hamano","vincenzo mezzela"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"488530","messageId":"cbb450b3-b333-4391-ac83-66c2daf0ae4d@gmail.com","threadId":"60906","inReplyTo":null,"subject":"[GSOC][RFC] microproject: use test_path_is_* functions in test scripts","fromName":"Vincenzo MEZZELA","fromEmail":"vincenzo.mezzela@gmail.com","sentAt":"2024-02-13T15:44:52Z","receivedAt":"2024-02-13T15:44:55Z","isPatch":false,"sender":{"key":"vincenzo.mezzela@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58368395?v=4"},"body":"Hello everyone,\n\nI'm Vincenzo, a Master's degree student in Computer Engineering and \nCybersecurity.\n\nAs I'm approaching the end of my academic journey, I'm eager to \ncontribute to the Git project\nand the GSoC represents a good opportunity to do so. Upon exploring the \nonline documentation\nof git for the application to the GSoC I'm keen to begin the required \nmicroproject.\n\nAmong the microproject proposed here \nhttps://git.github.io/SoC-2024-Microprojects/ , I would like to\nwork on replacing 'test -(e|f|g|...)' with test_path_is* .\n\nCan you confirm if this task has already been taken by someone else?\n\n\nApproach:\n\nAs far as I understood, The work consists in replacing the shell 'test' \ncommand in the test\nscript under 't/' directory with the ones present in the \nt/test_lib_functions.sh as follows:\n\n- test -f --> test_path_is_file\n\n- test -d --> test_path_is_dir\n\n- test -e --> test_path_exists\n\n\nTo approximately measure the number of required replacement, I run the \nfollowing commands from the\n't/' directory (branch master):\n\n> # Files  that requires a replacement\n > git grep -r 'test -[efdx]' 2>/dev/null| awk '{print $1}' | uniq -c | \nsort -n -r\n>>    190 t7301-clean-interactive.sh:\n>>     147 t7300-clean.sh:\n>>      21 t2004-checkout-cache-temp.sh:\n>>      17 t2401-worktree-prune.sh:\n>>      16 t2003-checkout-cache-mkdir.sh:\n>>      14 t0601-reffiles-pack-refs.sh:\n>>      13 t4200-rerere.sh:\n>>      12 t9146-git-svn-empty-dirs.sh:\n>>      12 t7603-merge-reduce-heads.sh:\n>>      12 lib-submodule-update.sh:\n>>    ...\n >>\n > # Number of replacements\n > git grep -r 'test -[efdx]' 2>/dev/null| awk '{print $1}' | uniq -c | \nsort -n -r | awk '{sum += $1} END {print sum}'\n >> 853\n > # Number of files that requires a patch\n > git grep -r 'test -[efdx]' 2>/dev/null| awk '{print $1}' | uniq -c | \nwc -l\n >> 169\n\nAlthough the replacement work might not be difficult, it spans over many \ndifferent test files.\nDo you want me to submit a patch for each of them as part of the \nmicroproject?\nIf not, How many patches do you expect me to submit?\n\nThanks,\nVincenzo\n\n\n"},{"id":"488551","messageId":"CAP8UFD2ypikjKEVMmHMg7=jwv8J0y5xhx6PxsiLsGdhz2+S3PQ@mail.gmail.com","threadId":"60906","inReplyTo":"cbb450b3-b333-4391-ac83-66c2daf0ae4d@gmail.com","subject":"Re: [GSOC][RFC] microproject: use test_path_is_* functions in test scripts","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2024-02-13T17:35:37Z","receivedAt":"2024-02-13T17:35:51Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi,\n\nOn Tue, Feb 13, 2024 at 5:10 PM Vincenzo MEZZELA\n<vincenzo.mezzela@gmail.com> wrote:\n>\n> Hello everyone,\n>\n> I'm Vincenzo, a Master's degree student in Computer Engineering and\n> Cybersecurity.\n>\n> As I'm approaching the end of my academic journey, I'm eager to\n> contribute to the Git project\n> and the GSoC represents a good opportunity to do so. Upon exploring the\n> online documentation\n> of git for the application to the GSoC I'm keen to begin the required\n> microproject.\n\nThanks for your interest in working on Git!\n\n> Among the microproject proposed here\n> https://git.github.io/SoC-2024-Microprojects/ , I would like to\n> work on replacing 'test -(e|f|g|...)' with test_path_is* .\n>\n> Can you confirm if this task has already been taken by someone else?\n\nThis is a generic microproject so even if someone else is working on\nthis microproject, you can also work on it as long as you don't work\non the same file as that person.\n\n> Approach:\n>\n> As far as I understood, The work consists in replacing the shell 'test'\n> command in the test\n> script under 't/' directory with the ones present in the\n> t/test_lib_functions.sh as follows:\n>\n> - test -f --> test_path_is_file\n>\n> - test -d --> test_path_is_dir\n>\n> - test -e --> test_path_exists\n\nNote that you only need to do that replacement in one test script\nunder the 't/' directory.\n\n> To approximately measure the number of required replacement, I run the\n> following commands from the\n> 't/' directory (branch master):\n>\n> > # Files  that requires a replacement\n>  > git grep -r 'test -[efdx]' 2>/dev/null| awk '{print $1}' | uniq -c |\n> sort -n -r\n> >>    190 t7301-clean-interactive.sh:\n> >>     147 t7300-clean.sh:\n> >>      21 t2004-checkout-cache-temp.sh:\n> >>      17 t2401-worktree-prune.sh:\n> >>      16 t2003-checkout-cache-mkdir.sh:\n> >>      14 t0601-reffiles-pack-refs.sh:\n> >>      13 t4200-rerere.sh:\n> >>      12 t9146-git-svn-empty-dirs.sh:\n> >>      12 t7603-merge-reduce-heads.sh:\n> >>      12 lib-submodule-update.sh:\n> >>    ...\n>  >>\n>  > # Number of replacements\n>  > git grep -r 'test -[efdx]' 2>/dev/null| awk '{print $1}' | uniq -c |\n> sort -n -r | awk '{sum += $1} END {print sum}'\n>  >> 853\n>  > # Number of files that requires a patch\n>  > git grep -r 'test -[efdx]' 2>/dev/null| awk '{print $1}' | uniq -c |\n> wc -l\n>  >> 169\n>\n> Although the replacement work might not be difficult, it spans over many\n> different test files.\n> Do you want me to submit a patch for each of them as part of the\n> microproject?\n> If not, How many patches do you expect me to submit?\n\nWe would like a single patch that performs the necessary replacements\nin a single file.\n\nFor reference in https://git.github.io/General-Microproject-Information/ we say:\n\n\"Change only a few files\"\n\nand\n\n\"This means that for a microproject that consists in refactoring or\nrewriting a small amount of code, your patch should change only ONE\nfile, or perhaps 2 files if they are closely related, like “foo.c” and\n“foo.h”.\"\n\nThanks,\nChristian.\n"},{"id":"488553","messageId":"CAPig+cROxB7shLZ0VMf=4pP2h_EuEG35X+Zf6ncfXv7Rk5yBHg@mail.gmail.com","threadId":"60906","inReplyTo":"CAP8UFD2ypikjKEVMmHMg7=jwv8J0y5xhx6PxsiLsGdhz2+S3PQ@mail.gmail.com","subject":"Re: [GSOC][RFC] microproject: use test_path_is_* functions in test scripts","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2024-02-13T17:39:53Z","receivedAt":"2024-02-13T17:40:05Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Feb 13, 2024 at 12:36 PM Christian Couder\n<christian.couder@gmail.com> wrote:\n> On Tue, Feb 13, 2024 at 5:10 PM Vincenzo MEZZELA\n> <vincenzo.mezzela@gmail.com> wrote:\n> > Can you confirm if this task has already been taken by someone else?\n>\n> This is a generic microproject so even if someone else is working on\n> this microproject, you can also work on it as long as you don't work\n> on the same file as that person.\n>\n> > >>      12 t9146-git-svn-empty-dirs.sh:\n\nThis particular test script is being tackled by someone else on the\nlist presently, so probably best to choose one of the others.\n"},{"id":"488556","messageId":"xmqqy1bo5k5h.fsf@gitster.g","threadId":"60906","inReplyTo":"cbb450b3-b333-4391-ac83-66c2daf0ae4d@gmail.com","subject":"Re: [GSOC][RFC] microproject: use test_path_is_* functions in test scripts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-13T17:49:46Z","receivedAt":"2024-02-13T17:49:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Vincenzo MEZZELA <vincenzo.mezzela@gmail.com> writes:\n\n> Approach:\n>\n> As far as I understood, The work consists in replacing the shell\n> 'test' command in the test\n> script under 't/' directory with the ones present in the\n> t/test_lib_functions.sh as follows:\n>\n> - test -f --> test_path_is_file\n>\n> - test -d --> test_path_is_dir\n>\n> - test -e --> test_path_exists\n\nOne thing to note is that you'd need to make sure if \"test -e\" for\nexample originally written really means \"we want to see something\nthere and it does not matter if it is a file or a directory\" while\nturning it into test_path_exists.  The operations that such a test\nfollows may be expected to create a file and never a directory, in\nwhich case the condition the original code is testing may need to\nbe corrected first to expect a more specific type (e.g. \"test -f\").\nThe same comment applies for the other two.\n\nSome tests check with \"! test -f <path>\", which often would want to\nbe turned into \"test_path_is_missing\", but you'd need to make sure\nthat is what the original test really meant to do.\n\nA microproject is not about \"doing the real work to help the\nproject\".  It is a practice session to come up with a set of small\nchanges and explain them well, to send the result to the list to get\nreviewed, to respond to reviews and possibly send updates, and to\nrepeat the cycle until completion.  So most likely you'd pick a\nsingle file or two and do the above conversion, while leaving the\nothers as practice material for other GSoC participants.\n\nEnjoy.\n\n"},{"id":"488631","messageId":"CAF2+nma0HZUPevhT7A4vM0rFYF07eF_u9Sg2wRAQ8E2+qBj5uQ@mail.gmail.com","threadId":"60906","inReplyTo":"xmqqy1bo5k5h.fsf@gitster.g","subject":"Re: [GSOC][RFC] microproject: use test_path_is_* functions in test scripts","fromName":"vincenzo mezzela","fromEmail":"vincenzo.mezzela@gmail.com","sentAt":"2024-02-14T10:20:06Z","receivedAt":"2024-02-14T10:20:18Z","isPatch":false,"sender":{"key":"vincenzo.mezzela@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58368395?v=4"},"body":"> One thing to note is that you'd need to make sure if \"test -e\" for\n> example originally written really means \"we want to see something\n> there and it does not matter if it is a file or a directory\" while\n> turning it into test_path_exists.  The operations that such a test\n> follows may be expected to create a file and never a directory, in\n> which case the condition the original code is testing may need to\n> be corrected first to expect a more specific type (e.g. \"test -f\").\n> The same comment applies for the other two.\n\nThanks for this clarification!\n\n> Some tests check with \"! test -f <path>\", which often would want to\n> be turned into \"test_path_is_missing\", but you'd need to make sure\n> that is what the original test really meant to do.\n\nI'd have changed them into:\n-  ! test -f <path> --> ! test_path_is_file <path>\n-  ! test -e <path> --> test_path_is_missing <path>\nSince '! test -f <path>' and 'test_path_is_missing <path>' can return\ndifferent values.\n\nBut as you said, I'll check what they are really meant to do and\nmodify them accordingly :)\n\n>\n> A microproject is not about \"doing the real work to help the\n> project\".  It is a practice session to come up with a set of small\n> changes and explain them well, to send the result to the list to get\n> reviewed, to respond to reviews and possibly send updates, and to\n> repeat the cycle until completion.  So most likely you'd pick a\n> single file or two and do the above conversion, while leaving the\n> others as practice material for other GSoC participants.\n>\n> Enjoy.\n>\n\nThanks for this clarification too. :)\n\nVincenzo\n"}]}