From: Karthik Nayak Date: Thu, 12 Nov 2026 17:34:16 GMT Subject: [PATCH v2 16/20] t9300: make the feature and option tests self-contained Message-ID: <20261112-kn-fast-import-tests-1-v2-16-b8c3a0ab27e8@gmail.com> In-Reply-To: <20261112-kn-fast-import-tests-1-v2-0-b8c3a0ab27e8@gmail.com> Similar to the previous commits, modify the tests in 'series R' which check the 'feature' command and the command line options to make them independent of state from previous tests. Signed-off-by: Karthik Nayak --- t/t9300-fast-import.sh | 260 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 187 insertions(+), 73 deletions(-) diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 0dc71648ca..5f84c66ac4 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -2636,54 +2636,90 @@ test_expect_success 'Q: deny note on empty branch' ' ### test_expect_success 'R: abort on unsupported feature' ' - cat >input <<-EOF && - feature no-such-feature-exists - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_must_fail git fast-import input <<-EOF && + feature no-such-feature-exists + EOF + + test_must_fail git fast-import input <<-EOF && - feature date-format=now - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - git fast-import input <<-EOF && + feature date-format=now + EOF + + git fast-import input <<-EOF && - blob - data 3 - hi - feature date-format=now - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_must_fail git fast-import input <<-EOF && + blob + data 3 + hi + feature date-format=now + EOF + + test_must_fail git fast-import git.marks && - echo "feature import-marks=git.marks" >input && - test_must_fail git fast-import input && - test_must_fail git fast-import git.marks && + echo "feature import-marks=git.marks" >input && + test_must_fail git fast-import input && + test_must_fail git fast-import git.marks && - >git2.marks && - cat >input <<-EOF && - feature import-marks=git.marks - feature import-marks=git2.marks - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_must_fail git fast-import --allow-unsafe-features git.marks && + >git2.marks && + cat >input <<-EOF && + feature import-marks=git.marks + feature import-marks=git2.marks + EOF + + test_must_fail git fast-import --allow-unsafe-features input && - test_must_fail git fast-import input && + test_must_fail git fast-import input && - git fast-import --allow-unsafe-features input && + git fast-import --allow-unsafe-features input && - GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \ - git fast-import --allow-unsafe input && + GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \ + git fast-import --allow-unsafe input && - test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true \ - git fast-import --allow-unsafe err && - test_grep "forbidden in input without --allow-unsafe-features" err + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature import-marks-if-exists=nonexistent.marks" >input && + test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true \ + git fast-import --allow-unsafe err && + test_grep "forbidden in input without --allow-unsafe-features" err + ) ' test_expect_success 'R: --allow-unsafe-features as the value of an abbreviation' ' - echo "feature import-marks-if-exists=nonexistent.marks" >input && - test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \ - git fast-import --quiet --export-pack \ - --allow-unsafe-features err && - test_grep "forbidden in input without --allow-unsafe-features" err + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature import-marks-if-exists=nonexistent.marks" >input && + test_must_fail env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \ + git fast-import --quiet --export-pack \ + --allow-unsafe-features err && + test_grep "forbidden in input without --allow-unsafe-features" err + ) ' test_expect_success 'R: --allow-unsafe-features after a non-option' ' - echo "feature import-marks-if-exists=nonexistent.marks" >input && - test_must_fail git fast-import --depth 5 extra \ - --allow-unsafe-features err && - test_grep "forbidden in input without --allow-unsafe-features" err + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature import-marks-if-exists=nonexistent.marks" >input && + test_must_fail git fast-import --depth 5 extra \ + --allow-unsafe-features err && + test_grep "forbidden in input without --allow-unsafe-features" err + ) ' test_expect_success 'R: catch typo in marks file name' ' @@ -3034,17 +3100,35 @@ test_expect_success 'R: feature no-relative-marks should be honoured' ' test_expect_success 'R: feature ls supported' ' - echo "feature ls" | - git fast-import + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature ls" | + git fast-import + ) ' test_expect_success 'R: feature cat-blob supported' ' - echo "feature cat-blob" | - git fast-import + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + echo "feature cat-blob" | + git fast-import + ) ' test_expect_success 'R: cat-blob-fd must be a nonnegative integer' ' - test_must_fail git fast-import --cat-blob-fd=-1 input <<-EOF && - option git non-existing-option - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - test_must_fail git fast-import input <<-EOF && + option git non-existing-option + EOF + + test_must_fail git fast-import input <<-EOF && - option non-existing-vcs non-existing-option - EOF + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && - git fast-import input <<-EOF && + option non-existing-vcs non-existing-option + EOF + + git fast-import