-
Notifications
You must be signed in to change notification settings - Fork 112
feat: custom build folder #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
61ae110
add build-dir CLI option
perazz 516c54f
replace hardcoded `build` paths
perazz fd52fe2
run in custom build folder
perazz 2662742
add CLI help
perazz 93e943f
ensure build_dir does not overlap with reserved keywords
perazz 41caee7
introduce CI test
perazz 4056e17
shorter line lengths
perazz 7064eff
fix call site
perazz f646a99
fix folder
perazz 231ad9c
fix folder 2
perazz 4ed012a
Merge branch 'fortran-lang:main' into custom_build_folder
perazz 86c4d67
Merge branch 'main' into custom_build_folder
perazz d50e8a0
restore `validate_build_dir`
perazz db4b2e4
move routines out (non-trampoline)
perazz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
# Test script for custom build directory functionality | ||
# Usage: ./test_custom_build_dir.sh [fpm_executable] [example_package_dir] | ||
|
||
if [ "$1" ]; then | ||
fpm="$1" | ||
else | ||
fpm=fpm | ||
fi | ||
|
||
if [ "$2" ]; then | ||
test_package="$2" | ||
else | ||
test_package="hello_world" | ||
fi | ||
|
||
echo "Testing custom build directory functionality with package: $test_package" | ||
|
||
# Test 1: Custom build directory with CLI option | ||
pushd "$test_package" | ||
echo "Test 1: CLI option --build-dir" | ||
rm -rf ./build custom_build_test | ||
"$fpm" build --build-dir custom_build_test | ||
test -d custom_build_test | ||
test -f custom_build_test/.gitignore | ||
"$fpm" run --build-dir custom_build_test --target "$test_package" | ||
# Verify standard build directory was not created | ||
test ! -d build | ||
echo "✓ CLI option --build-dir works" | ||
|
||
# Test 2: Environment variable | ||
echo "Test 2: Environment variable FPM_BUILD_DIR" | ||
rm -rf custom_build_test env_build_test | ||
FPM_BUILD_DIR=env_build_test "$fpm" build | ||
test -d env_build_test | ||
test -f env_build_test/.gitignore | ||
FPM_BUILD_DIR=env_build_test "$fpm" run --target "$test_package" | ||
echo "✓ Environment variable FPM_BUILD_DIR works" | ||
|
||
# Test 3: CLI option overrides environment variable | ||
echo "Test 3: CLI option overrides environment variable" | ||
rm -rf env_build_test cli_override_test | ||
FPM_BUILD_DIR=env_build_test "$fpm" build --build-dir cli_override_test | ||
test -d cli_override_test | ||
test ! -d env_build_test | ||
echo "✓ CLI option correctly overrides environment variable" | ||
|
||
# Test 4: Build directory validation - reserved names | ||
echo "Test 4: Build directory validation" | ||
# These should fail with specific error messages | ||
if "$fpm" build --build-dir src 2>&1 | grep -q "conflicts with source directory"; then | ||
echo "✓ Correctly rejected 'src'" | ||
else | ||
echo "ERROR: Should reject 'src'" && exit 1 | ||
fi | ||
|
||
if "$fpm" build --build-dir app 2>&1 | grep -q "conflicts with source directory"; then | ||
echo "✓ Correctly rejected 'app'" | ||
else | ||
echo "ERROR: Should reject 'app'" && exit 1 | ||
fi | ||
|
||
if "$fpm" build --build-dir test 2>&1 | grep -q "conflicts with source directory"; then | ||
echo "✓ Correctly rejected 'test'" | ||
else | ||
echo "ERROR: Should reject 'test'" && exit 1 | ||
fi | ||
|
||
if "$fpm" build --build-dir . 2>&1 | grep -q "would overwrite the current"; then | ||
echo "✓ Correctly rejected '.'" | ||
else | ||
echo "ERROR: Should reject '.'" && exit 1 | ||
fi | ||
|
||
# Test 5: Path normalization | ||
echo "Test 5: Path normalization" | ||
if "$fpm" build --build-dir ./src 2>&1 | grep -q "conflicts with source directory"; then | ||
echo "✓ Correctly rejected './src' (path normalization works)" | ||
else | ||
echo "ERROR: Should reject './src'" && exit 1 | ||
fi | ||
|
||
# Test 6: Different commands with custom build directory | ||
echo "Test 6: Different commands with custom build directory" | ||
rm -rf test_build_all | ||
"$fpm" build --build-dir test_build_all | ||
"$fpm" run --build-dir test_build_all --target "$test_package" | ||
# Some packages may not have tests, so this might fail but that's expected | ||
"$fpm" test --build-dir test_build_all 2>/dev/null || echo "No tests in $test_package (expected)" | ||
echo "✓ All commands work with custom build directory" | ||
|
||
# Cleanup test directories | ||
rm -rf custom_build_test env_build_test cli_override_test test_build_all | ||
popd | ||
|
||
echo "All custom build directory tests passed!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.