-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
builtin_initialize IO.println "Ran builtin initializer" |
This file contains 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,2 @@ | ||
rm -rf .lake/build | ||
rm -f lake-manifest.json |
This file contains 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,6 @@ | ||
name = "user_plugin" | ||
defaultTargets = ["UserPlugin"] | ||
|
||
[[lean_lib]] | ||
name = "UserPlugin" | ||
defaultFacets = ["shared"] |
This file contains 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,8 @@ | ||
import Lean.LoadDynlib | ||
|
||
def main (args : List String) : IO UInt32 := do | ||
let plugin :: [] := args | ||
| IO.println "Usage: lean --run test.lean <plugin>" | ||
return 1 | ||
Lean.loadPlugin plugin | ||
return 0 |
This file contains 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,42 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# Deermine shared library extension | ||
if [ "${OS:-}" = Windows_NT ]; then | ||
LIB_PREFIX= | ||
SHLIB_EXT=dll | ||
elif [ "`uname`" = Darwin ]; then | ||
LIB_PREFIX=lib | ||
SHLIB_EXT=dylib | ||
else | ||
LIB_PREFIX=lib | ||
SHLIB_EXT=so | ||
fi | ||
|
||
# Reset test | ||
./clean.sh | ||
lake update -q | ||
|
||
# Build plugin | ||
lake build | ||
LIB_DIR=.lake/build/lib | ||
SHLIB=$LIB_DIR/${LIB_PREFIX}UserPlugin.$SHLIB_EXT | ||
test -f $SHLIB || { | ||
echo "Plugin library not found; $LIB_DIR contains:" | ||
ls $LIB_DIR | ||
exit 1 | ||
} | ||
PLUGIN=$LIB_DIR/UserPlugin.$SHLIB_EXT | ||
mv $SHLIB $PLUGIN | ||
|
||
# Expected test output | ||
EXPECTED_OUT="Ran builtin initializer" | ||
|
||
# Test plugin via `lean` | ||
echo | lean --plugin=$PLUGIN --stdin | diff <(echo "$EXPECTED_OUT") - | ||
|
||
# Test plugin via `Lean.loadPlugin` | ||
lean --run test.lean $PLUGIN | diff <(echo "$EXPECTED_OUT") - | ||
|
||
# Print success | ||
echo "Tests completed successfully." |