Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
8ec2da6a
Commit
8ec2da6a
authored
6 years ago
by
Loic Hausammann
Browse files
Options
Downloads
Patches
Plain Diff
Add testFormat
parent
91bb16c2
No related branches found
No related tags found
1 merge request
!599
Add testFormat
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
configure.ac
+1
-0
1 addition, 0 deletions
configure.ac
format.sh
+67
-1
67 additions, 1 deletion
format.sh
tests/Makefile.am
+1
-1
1 addition, 1 deletion
tests/Makefile.am
tests/testFormat.sh.in
+6
-0
6 additions, 0 deletions
tests/testFormat.sh.in
with
75 additions
and
2 deletions
configure.ac
+
1
−
0
View file @
8ec2da6a
...
...
@@ -1360,6 +1360,7 @@ AC_CONFIG_FILES([tests/testPeriodicBCPerturbed.sh], [chmod +x tests/testPeriodic
AC_CONFIG_FILES([tests/testInteractions.sh], [chmod +x tests/testInteractions.sh])
AC_CONFIG_FILES([tests/testParser.sh], [chmod +x tests/testParser.sh])
AC_CONFIG_FILES([tests/testSelectOutput.sh], [chmod +x tests/testSelectOutput.sh])
AC_CONFIG_FILES([tests/testFormat.sh], [chmod +x tests/testFormat.sh])
# Save the compilation options
AC_DEFINE_UNQUOTED([SWIFT_CONFIG_FLAGS],["$swift_config_flags"],[Flags passed to configure])
...
...
This diff is collapsed.
Click to expand it.
format.sh
+
67
−
1
View file @
8ec2da6a
#!/bin/bash
clang-format-5.0
-style
=
file
-i
src/
*
.[ch] src/
*
/
*
.[ch] src/
*
/
*
/
*
.[ch] examples/main.c tests/
*
.[ch]
# Clang software name
clang
=
"clang-format-5.0"
# Formatting command
cmd
=
"
$clang
-style=file src/*.[ch] src/*/*.[ch] src/*/*/*.[ch] examples/main.c tests/*.[ch]"
# Test if `clang-format-5.0` works
command
-v
$clang
>
/dev/null
if
[[
$?
-ne
0
]]
then
echo
"Cannot find
$clang
"
exit
1
fi
set
-e
# Print the help
function
show_help
{
echo
-e
"This script formats Swift according to Google style"
echo
-e
" -h, --help
\t
Show this help"
echo
-e
" -t, --test
\t
Test if Swift is well formatted"
}
# Parse arguments (based on https://stackoverflow.com/questions/192249)
TEST
=
0
while
[[
$#
-gt
0
]]
do
key
=
"
$1
"
case
$key
in
# print the help and exit
-h
|
--help
)
show_help
exit
;;
# check if the code is well formatted
-t
|
--test
)
TEST
=
1
shift
;;
# unknown option
*
)
echo
"Argument '
$1
' not implemented"
show_help
exit
;;
esac
done
# Run the required commands
if
[[
$TEST
-eq
1
]]
then
echo
"Testing Swift formatting"
$cmd
-output-replacements-xml
|
grep
-c
"<replacement "
>
/dev/null
res
=
$?
# Check formatting
if
[[
$res
-ne
1
]]
then
echo
"Swift needs to be formatted"
exit
1
fi
else
echo
"Formatting Swift"
$cmd
-i
fi
This diff is collapsed.
Click to expand it.
tests/Makefile.am
+
1
−
1
View file @
8ec2da6a
...
...
@@ -28,7 +28,7 @@ TESTS = testGreetings testMaths testReading.sh testSingle testKernel testSymmetr
testVoronoi1D testVoronoi2D testVoronoi3D testGravityDerivatives
\
testPeriodicBC.sh testPeriodicBCPerturbed.sh testPotentialSelf
\
testPotentialPair testEOS testUtilities testSelectOutput.sh
\
testCbrt testCosmology testOutputList
testCbrt testCosmology testOutputList
testFormat.sh
# List of test programs to compile
check_PROGRAMS
=
testGreetings testReading testSingle testTimeIntegration
\
...
...
This diff is collapsed.
Click to expand it.
tests/testFormat.sh.in
0 → 100644
+
6
−
0
View file @
8ec2da6a
#!/bin/bash
set
-e
cd
@srcdir@/..
./format.sh
--test
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment