Skip to content
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

Initial Rust support #488

Merged
merged 293 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
293 commits
Select commit Hold shift + click to select a range
06d1afb
Dont rename the runtime crate
oowekyala Jul 13, 2021
60ef32a
Change startup logic not to depend on special startup reaction
oowekyala Jul 13, 2021
021865c
Update to support termination without timeout
oowekyala Jul 13, 2021
b7eb2f3
Update submodule
oowekyala Jul 13, 2021
790a715
Remove hardcoded local path to rust lib
oowekyala Jul 13, 2021
4fb9857
Add other examples
oowekyala Jul 13, 2021
092a4dc
Cleanup
oowekyala Jul 13, 2021
b9b1e5d
More cleanups
oowekyala Jul 13, 2021
a9f8a07
Update submodule
oowekyala Jul 13, 2021
814a595
Use original name for executable
oowekyala Jul 13, 2021
ce795f9
Add composition test
oowekyala Jul 15, 2021
6203c26
Fix crate name
oowekyala Jul 15, 2021
87a916b
Make executable name snake case
oowekyala Jul 15, 2021
a9b6020
Cleanup an extension about FileConfig
oowekyala Jul 15, 2021
506c26e
Update rust lib
oowekyala Jul 15, 2021
2ecb575
Doc
oowekyala Jul 15, 2021
b2ad107
More cleanups of models
oowekyala Jul 15, 2021
8664452
Improve output for preambles
oowekyala Jul 15, 2021
e51b7af
Declare nested reactors
oowekyala Jul 15, 2021
c8e1021
Adapt to changes in runtime
oowekyala Jul 15, 2021
023fad0
Prepare declaring connections between children
oowekyala Jul 15, 2021
9f8c314
Support nested reactors
oowekyala Jul 15, 2021
0c7450a
Finish list of keywords
oowekyala Jul 15, 2021
3d9bb17
Fix syntax of PortComposition.lf
oowekyala Jul 15, 2021
84dbd43
Also expose 'use' dependencies to reactions
oowekyala Jul 15, 2021
6722bb9
Support env var to point to local runtime crate repo
oowekyala Jul 15, 2021
50e0175
Fix PortComposition syntax
oowekyala Jul 15, 2021
49b00e7
Format output, allow non_snake_case everywhere
oowekyala Jul 15, 2021
6c0adfb
Fix port visibility
oowekyala Jul 15, 2021
f6d2434
Support generating bind_ports
oowekyala Jul 16, 2021
6df5acf
Support nice comments with original lf code in generated sources
oowekyala Jul 16, 2021
d9b2953
Support it in more places
oowekyala Jul 16, 2021
7e93822
Cleanups
oowekyala Jul 16, 2021
d92e8e3
Add a couple of 'standard' generator exceptions
oowekyala Jul 16, 2021
ee84f28
Support logical actions
oowekyala Jul 16, 2021
4e6e5d4
Update submodule
oowekyala Jul 16, 2021
007bf3c
Cleanup
oowekyala Jul 16, 2021
27002cb
Report time as nanos
oowekyala Jul 19, 2021
95930bc
Support emitting timers
oowekyala Jul 19, 2021
f0bcb5c
Fix output indentation
oowekyala Jul 19, 2021
2d7fc08
Support for timers
oowekyala Jul 19, 2021
699005c
Support timeout and keepalive target properties
oowekyala Jul 19, 2021
b3bbcd7
Fix tests
oowekyala Jul 20, 2021
2829738
Add new test
oowekyala Jul 20, 2021
d1b6757
Support ctor parameters
oowekyala Jul 20, 2021
9831266
Support default ctor parameters
oowekyala Jul 20, 2021
31450ad
Update submodule
oowekyala Jul 20, 2021
d2035b3
Merge branch 'master' into rust-dev
oowekyala Jul 21, 2021
5a3b74d
Cleanup some other code
oowekyala Jul 22, 2021
ba88857
Fix merge
oowekyala Jul 22, 2021
9807342
Merge branch 'master' into rust-dev
oowekyala Jul 22, 2021
96f47da
Add timer test
oowekyala Jul 22, 2021
06a8d6c
Use struct instead of tuple for ctor params
oowekyala Jul 22, 2021
e730913
Make ctor params available everywhere
oowekyala Jul 22, 2021
7823a16
Better allow(unused) placement
oowekyala Jul 22, 2021
dab3636
Improve tests
oowekyala Jul 22, 2021
3c17f27
Add a C++ test
oowekyala Jul 23, 2021
253963d
WIP support for actions with values
oowekyala Jul 23, 2021
f1d4b69
Large update of rust runtime
oowekyala Jul 23, 2021
f8a94ec
Create output location if it does not exist
oowekyala Jul 23, 2021
0c44544
Use standard lfc options instead of that env variable
oowekyala Jul 23, 2021
ebafedb
Merge branch 'fixup-LFCommand' into rust-dev
oowekyala Jul 23, 2021
80115cc
Merge branch 'make-grammar-more-forgiving' into rust-dev
oowekyala Jul 23, 2021
eadf42b
Merge branch 'fixup-LFCommand' into rust-dev
oowekyala Jul 23, 2021
ba28993
Fix invalid TOML
oowekyala Jul 23, 2021
4ce958f
Change new_reaction macro to use int-enum
oowekyala Jul 25, 2021
cad16f0
Use enqueue for startup routine
oowekyala Jul 25, 2021
589e9f0
Add joinWithCommas, fix timer init
oowekyala Jul 25, 2021
e39c256
Revert changes to timers
oowekyala Jul 25, 2021
bdd9089
Rename test timer
oowekyala Jul 25, 2021
b398494
Cleanup
oowekyala Jul 25, 2021
bbe5982
Merge reactor assembler and dispatcher
oowekyala Jul 25, 2021
5097980
Update rust runtime
oowekyala Jul 25, 2021
0344c25
Add logging caps
oowekyala Jul 25, 2021
b02d665
Update rust runtime
oowekyala Jul 25, 2021
75e9dc7
Update rust runtime
oowekyala Jul 25, 2021
754f5b1
Update runtime to version without reactor locks
oowekyala Jul 26, 2021
a7418fb
Fix timers
oowekyala Jul 26, 2021
d49b031
Fix reactor composition
oowekyala Jul 26, 2021
d360f0d
Add single-file-project target property
oowekyala Jul 26, 2021
3199bb5
Make ctor params visible in children initializers
oowekyala Jul 26, 2021
6381942
Update trait names
oowekyala Jul 26, 2021
1139f59
Update submodule
oowekyala Jul 26, 2021
14a9b03
Fix test
oowekyala Jul 26, 2021
e9ab01e
Update runtime
oowekyala Jul 26, 2021
b01faac
Remove accidental dependency on C++, fix bugs in runtime
oowekyala Jul 27, 2021
25ca999
Fix time type not supported everywhere
oowekyala Jul 27, 2021
d7baf3c
Add comment with link to source to generated code
oowekyala Jul 27, 2021
70e8d85
Cleanup tests
oowekyala Jul 27, 2021
d05c2e0
Merge branch 'fixup-LFCommand' into rust-dev
oowekyala Jul 27, 2021
87e20ad
Cleanups of FileConfig
oowekyala Jul 27, 2021
d68bfe2
Update rust lib
oowekyala Jul 27, 2021
e84abc9
ReactionCtx has been renamed
oowekyala Jul 27, 2021
c65681b
Support newer port dependencies
oowekyala Jul 27, 2021
12d1129
Fix bug with parameter generated several times
oowekyala Jul 27, 2021
81c67f6
Fix tests
oowekyala Jul 27, 2021
79c9418
Add ActionValues.lf
oowekyala Jul 27, 2021
11b019e
Add MovingAverage.lf
oowekyala Jul 27, 2021
e87dd7a
Extract stuff out of generators with TargetTypes itf
oowekyala Jul 28, 2021
27078f6
Add NativeListsAndTimes.lf
oowekyala Jul 28, 2021
8e6b8b2
Merge branch 'master' into rust-dev
oowekyala Jul 30, 2021
bae6b4f
Merge branch 'single-quotes' into rust-dev
oowekyala Jul 30, 2021
a2b74e2
Merge branch 'master' into rust-dev
oowekyala Jul 30, 2021
d8c4696
Merge branch 'master' into rust-dev
oowekyala Aug 23, 2021
ecc1f12
add status report
oowekyala Aug 31, 2021
8acaee2
Merge branch 'master' into rust-dev
oowekyala Aug 31, 2021
4a64a32
Cleanups
oowekyala Sep 2, 2021
4ad9341
Merge branch 'master' into rust-dev
oowekyala Sep 2, 2021
61f37dc
Merge branch 'single-quotes' into rust-dev
oowekyala Sep 2, 2021
186dc20
FIXME silence failing tests
oowekyala Sep 2, 2021
ad8df5c
flesh out feature checklist
oowekyala Sep 2, 2021
8b7fb88
Add test for use-only dependencies
oowekyala Sep 2, 2021
bdcf6f9
Implement tag cleanup
oowekyala Sep 3, 2021
029de11
Merge branch 'master' into rust-dev
oowekyala Sep 7, 2021
3042482
Change runtime url to public repo
oowekyala Sep 7, 2021
3015e9e
update rust readiness list
oowekyala Sep 7, 2021
2d9bca0
add more details
oowekyala Sep 8, 2021
9fabb03
Use a cargo workspace for tests
oowekyala Sep 8, 2021
4ae72bd
Add test case for cleanup of shutdown tag
oowekyala Sep 8, 2021
0e1e790
Update rust submodule config
oowekyala Sep 8, 2021
017d141
Update rust checklist
oowekyala Sep 8, 2021
f506889
Add more tests around request_stop
oowekyala Sep 8, 2021
422ae9d
flesh out timer tests
oowekyala Sep 8, 2021
1457c86
update readme
oowekyala Sep 8, 2021
2a47c58
move readme
oowekyala Sep 8, 2021
f5115a3
Cleanup tests about actions
oowekyala Sep 9, 2021
a77df76
add more tests
oowekyala Sep 9, 2021
11be16c
Figure out some problems with connections
oowekyala Sep 9, 2021
3e5a398
Better trace logging
oowekyala Sep 9, 2021
7b14c57
Add failing test cases
oowekyala Sep 9, 2021
fcf64eb
more bullet points
oowekyala Sep 13, 2021
8b3c059
Update runtime
oowekyala Sep 14, 2021
00eb2a9
Make assembler build components itself
oowekyala Sep 15, 2021
b33d9f6
Fix wrong variable name
oowekyala Sep 21, 2021
2b174cf
Make assembly routine build graph
oowekyala Sep 21, 2021
a6ade81
Merge branch 'master' into rust-dev
oowekyala Sep 21, 2021
7b7ea1d
Declare reactions in bulk
oowekyala Sep 22, 2021
69bc768
Use patched index_vec crate
oowekyala Sep 22, 2021
59bd709
fix timers
oowekyala Sep 22, 2021
6cf567e
Make assembler bind ports itself
oowekyala Sep 22, 2021
a63e4f1
Update runtime
oowekyala Sep 22, 2021
5a41306
Merge branch 'master' into rust-dev
oowekyala Sep 23, 2021
af9ef89
Update runtime
oowekyala Sep 23, 2021
7962c5c
Cleanup type syntax
oowekyala Sep 24, 2021
68a3863
Use Result<_, AssemblyError>
oowekyala Sep 24, 2021
3285b1c
Update runtime
oowekyala Sep 24, 2021
c05f6ce
Change order of declaring reactions
oowekyala Sep 24, 2021
c6d8bf6
update runtime
oowekyala Sep 24, 2021
5c58f92
Merge branch 'master' into rust-dev
oowekyala Sep 24, 2021
04d0b8b
Fix q
oowekyala Sep 24, 2021
9097701
Allow using LOCAL_RUST_REACTOR_RT for the runtime path in tests
oowekyala Sep 24, 2021
b09bce0
Fix badly written tests
oowekyala Sep 24, 2021
2116a36
Support reaction dependencies on ports of children reactors
oowekyala Sep 25, 2021
c5beee6
update checklist
oowekyala Sep 25, 2021
7f86198
Improve feature checklist
oowekyala Sep 26, 2021
ccc22fe
Add debug names to reactors
oowekyala Sep 26, 2021
5b1092d
update runtime
oowekyala Sep 26, 2021
d34bafa
Support var length list properly
oowekyala Sep 26, 2021
9c034b1
Allow keywords almost everywhere
oowekyala Sep 26, 2021
4e8c42e
Draft generics support
oowekyala Sep 26, 2021
ad1d6ae
Fix a bug with child dependencies
oowekyala Sep 26, 2021
f04a871
GlobalId shenanigans
oowekyala Sep 26, 2021
5896d50
Support generics
oowekyala Sep 26, 2021
13257c6
Cleanup port ref generated code
oowekyala Sep 26, 2021
df3c052
Cleanup names of generated variables
oowekyala Sep 26, 2021
4746119
Add debug labels to reactions
oowekyala Sep 26, 2021
0f45a22
experiments
oowekyala Sep 26, 2021
c30d5f5
more todosé
oowekyala Sep 27, 2021
8a715c5
Merge branch 'master' into rust-dev
oowekyala Sep 27, 2021
991e86a
Fix C++ tests
oowekyala Sep 27, 2021
0a3756d
More c++ cleanups
oowekyala Sep 27, 2021
d843d83
Infer usize parameter
oowekyala Sep 27, 2021
7e16c99
Setup Rust CI for tests
oowekyala Sep 27, 2021
385f2f6
Check out runtime within CI
oowekyala Sep 27, 2021
0dcf8e5
Update runtime
oowekyala Sep 27, 2021
ac5564c
Fix TimerPeriodic.lf
oowekyala Sep 27, 2021
ce63003
Update submodule urls
oowekyala Sep 27, 2021
88a03a8
Fix unescaped reserved keywords
oowekyala Sep 27, 2021
2209886
Merge branch 'master' into rust-dev
oowekyala Sep 27, 2021
d3bf995
Merge branch 'make-grammar-more-forgiving' into rust-dev
oowekyala Sep 28, 2021
59535bf
Cleanup ident escaping logic
oowekyala Sep 28, 2021
a584c4e
Fix tests
oowekyala Sep 28, 2021
7bcedea
Also clean up port references
oowekyala Sep 28, 2021
4a49624
Fix tests
oowekyala Sep 28, 2021
2cc721f
Merge branch 'master' into rust-dev
oowekyala Sep 28, 2021
c7ea4f6
Update tests for changes in runtime
oowekyala Sep 28, 2021
b5a17c9
Inject timers in reactions
oowekyala Sep 29, 2021
8dc9c68
add todos
oowekyala Sep 29, 2021
7f97c96
Fix Cargo paths on windows
oowekyala Sep 29, 2021
b32fd72
Remove submodule, add documentation
oowekyala Sep 29, 2021
a787015
Remove submodule for real
oowekyala Sep 29, 2021
1d571cf
Fix tests
oowekyala Sep 29, 2021
10808a8
Merge branch 'master' into rust-dev
oowekyala Sep 29, 2021
6229b1d
Use http instead of ssh...
oowekyala Sep 29, 2021
3db12ab
Fix tests
oowekyala Sep 29, 2021
6586475
Merge branch 'master' into rust-dev
oowekyala Sep 29, 2021
8d94929
Merge branch 'master' into rust-dev
oowekyala Sep 30, 2021
3491079
Fix remaining bugs
oowekyala Sep 30, 2021
200bddd
Small improvements to #555 feature
oowekyala Sep 30, 2021
fb5418a
Another fix..
oowekyala Sep 30, 2021
08ff2d6
Fix package root in RunSingleTestMain
oowekyala Sep 30, 2021
f865977
Fix actual bug
oowekyala Sep 30, 2021
ab598d2
Add target property to enable cargo features
oowekyala Sep 30, 2021
8a31784
Add a cargo test feature
oowekyala Sep 30, 2021
7ba6097
First test for physical actions
oowekyala Sep 30, 2021
9cda501
Rewrite test
oowekyala Sep 30, 2021
a67ab79
Delete a test
oowekyala Sep 30, 2021
e47ed57
Fix tests
oowekyala Sep 30, 2021
8c3c3fb
Suppress unchecked warning
oowekyala Sep 30, 2021
7c9d6d2
Merge branch 'master' into rust-dev
oowekyala Sep 30, 2021
ff23eb1
Fix compil
oowekyala Sep 30, 2021
732a295
Fix validation tests
oowekyala Sep 30, 2021
e290f28
Fix executable path on Windows
oowekyala Sep 30, 2021
0d52505
Merge branch 'master' into rust-dev
oowekyala Oct 10, 2021
85066d0
Update to latest runtime
oowekyala Oct 10, 2021
8424f28
Update tests to newer runtime
oowekyala Oct 10, 2021
83358f6
Fix bug with stop during startup
oowekyala Oct 11, 2021
ed18202
wip fix stop.lf
oowekyala Oct 11, 2021
76b517e
Update assembly to use trigger id for startup/shutdown
oowekyala Oct 11, 2021
e4d70c6
Fix stop.lf
oowekyala Oct 11, 2021
829713d
Fix timers
oowekyala Oct 11, 2021
18fff0f
Merge branch 'master' into rust-dev
oowekyala Oct 11, 2021
9153c9d
Allow using type parameters in ctor params
oowekyala Oct 11, 2021
63d8c3f
Update to use new macros
oowekyala Oct 11, 2021
1aa8837
Fix compil with test-program feature
oowekyala Oct 11, 2021
e5bd987
Fix whacky output redirection in tests
oowekyala Oct 11, 2021
733773f
Fix rust tests
oowekyala Oct 11, 2021
1509efc
Remove forgotten file
oowekyala Oct 12, 2021
6bb3b4c
Remove unused method
oowekyala Oct 12, 2021
6aec7db
Revert "Fix whacky output redirection in tests"
oowekyala Oct 12, 2021
ada5393
Update runtime version
oowekyala Oct 12, 2021
af1cb67
Merge branch 'master' into rust-dev
oowekyala Oct 13, 2021
3c57eb6
Add comment in src-gen/Cargo.toml
oowekyala Oct 13, 2021
bacd109
Merge branch 'master' into rust-dev
oowekyala Oct 15, 2021
c5f1c4c
Merge branch 'test-cleanups' into rust-dev
oowekyala Oct 15, 2021
1429239
Resolved merge conflicts and create separate CCppTest class
lhstrh Oct 16, 2021
48fce39
Removing Windows from the ccpp job because it is not supported, anyway
lhstrh Oct 16, 2021
47ff1ed
Forgot to remove CCpp tests from CTest
lhstrh Oct 16, 2021
80f3a2c
Removed unused imports
lhstrh Oct 17, 2021
0fa3608
Update org.lflang/src/org/lflang/Target.java
lhstrh Oct 17, 2021
6217bfa
Fix type of dependencies
oowekyala Oct 17, 2021
ed29239
Remove spurious changes to eclipse files
oowekyala Oct 17, 2021
517d1c6
Convert most of GeneratorUtils to java, parts of AstUtils too
oowekyala Oct 17, 2021
a60f243
Convert generation exceptions to java
oowekyala Oct 17, 2021
714ac7a
Cleanups
oowekyala Oct 17, 2021
7011dbf
Create a generics test category
oowekyala Oct 17, 2021
ab0bd54
Remove test-program feature
oowekyala Oct 17, 2021
0ab7bb8
Fix runtime update
oowekyala Oct 17, 2021
d0ba95e
Document and move some utility functions
oowekyala Oct 17, 2021
d165032
Fix bugs
oowekyala Oct 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,28 @@ jobs:
- name: Run Python tests;
run: |
./gradlew test --tests org.lflang.tests.runtime.PythonTest.*


rust-tests:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
rust: [nightly]
runs-on: ${{ matrix.platform }}
steps:
- name: Setup Java JDK
uses: actions/setup-java@v1.4.3
with:
java-version: 11
- name: Setup Rust
uses: ATiltedTree/setup-rust@v1
with:
rust-version: ${{ matrix.rust }}
components: clippy
- uses: actions/checkout@v2
- name: Run Rust tests
run: |
./gradlew test --tests org.lflang.tests.runtime.RustTest.*

benchmark-tests:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "xtext/org.icyphy.linguafranca/src/lib/TS/reactor-ts"]
path = org.lflang/src/lib/TS/reactor-ts
url = https://github.com/icyphy/reactor-ts.git
url = https://github.com/lf-lang/reactor-ts.git
3 changes: 3 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions bin/update-rust-runtime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# This script updates the version of the Rust runtime used by
# LFC and tested in CI. See README.md in Rust code generator
# directory.

cd "$LOCAL_RUST_REACTOR_RT" || (echo "Set LOCAL_RUST_REACTOR_RT properly plz" && exit 1)
revision_no="$(git rev-parse HEAD)"
cd -

# the directory of the script (LF_ROOT/bin)
script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"


echo "$revision_no" > "$script_dir/../org.lflang/src/org/lflang/generator/rust/rust-runtime-version.txt"

echo "updated to $revision_no"
1 change: 1 addition & 0 deletions org.lflang.diagram/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="build/xtend/main"/>
oowekyala marked this conversation as resolved.
Show resolved Hide resolved
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
8 changes: 4 additions & 4 deletions org.lflang.lfc/src/org/lflang/lfc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class Main {
private static String MAIN_PATH_IN_JAR = String.join("/",
new String[] {"!", "org", "lflang", "lfc", "Main.class"});


/**
* Object for interpreting command line arguments.
*/
Expand Down Expand Up @@ -497,11 +497,11 @@ private void exitIfCollectedErrors() {
reporter.printFatalErrorAndExit("Aborting due to " + cause);
}
}

/**
* Given a path, obtain a resource and validate it. If issues arise during validation,
* these are recorded using the issue collector.
*
*
* @param path Path to the resource to validate.
* @return A validated resource
*/
Expand All @@ -517,7 +517,7 @@ private Resource getValidatedResource(Path path) {
}

List<Issue> issues = this.validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);

for (Issue issue : issues) {
URI uri = issue.getUriToProblem(); // Issues may also relate to imported resources.
try {
Expand Down
31 changes: 29 additions & 2 deletions org.lflang.tests/src/org/lflang/tests/RunSingleTestMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
import java.util.regex.Pattern;

import org.lflang.Target;
import org.lflang.tests.runtime.CTest;
import org.lflang.tests.runtime.CppTest;
import org.lflang.tests.runtime.PythonTest;
import org.lflang.tests.runtime.RustTest;
import org.lflang.tests.runtime.TestBase;
import org.lflang.tests.runtime.TypeScriptTest;

/**
* Execute a single test case. Use it with the gradle task
Expand All @@ -43,7 +48,7 @@
public class RunSingleTestMain {


private static final Pattern TEST_FILE_PATTERN = Pattern.compile("(test/(\\w+)/src)/([^/]++/)*(\\w+.lf)");
private static final Pattern TEST_FILE_PATTERN = Pattern.compile("(test/(\\w+))/src/([^/]++/)*(\\w+.lf)");

public static void main(String[] args) throws FileNotFoundException {
if (args.length != 1) {
Expand All @@ -62,6 +67,28 @@ public static void main(String[] args) throws FileNotFoundException {
Path packageRoot = Paths.get(matcher.group(1)).toAbsolutePath();
Target target = Target.forName(matcher.group(2)).get();

TestBase.runSingleTestAndPrintResults(new LFTest(target, path.toAbsolutePath(), packageRoot));
Class<? extends TestBase> testClass = getTestInstance(target);

LFTest testCase = new LFTest(target, path.toAbsolutePath(), packageRoot);

TestBase.runSingleTestAndPrintResults(testCase, testClass);
}

private static Class<? extends TestBase> getTestInstance(Target target) {
switch (target) {
case C:
case CCPP: // todo CCpp
oowekyala marked this conversation as resolved.
Show resolved Hide resolved
return CTest.class;
case CPP:
return CppTest.class;
case TS:
return TypeScriptTest.class;
case Python:
return PythonTest.class;
case Rust:
return RustTest.class;
default:
throw new IllegalArgumentException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,11 @@ class LinguaFrancaValidationTest {
* name, and the type that it should be.
*/
val compositeTypeToKnownBad = #{
ArrayType.STRING_ARRAY -> #[
#["[1 msec]", "[0]", PrimitiveType.STRING],
#["[foo, {bar: baz}]", "[1]", PrimitiveType.STRING],
#["{bar: baz}", "", ArrayType.STRING_ARRAY]
],
UnionType.STRING_OR_STRING_ARRAY -> #[
#["[1 msec]", "[0]", PrimitiveType.STRING],
#["[foo, {bar: baz}]", "[1]", PrimitiveType.STRING],
Expand Down
2 changes: 1 addition & 1 deletion org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
public class CppTest extends ThreadedBase {

CppTest() {
public CppTest() {
this.target = Target.CPP;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
public class PythonTest extends TestBase {

PythonTest() {
public PythonTest() {
this.target = Target.Python;
}

Expand Down
68 changes: 68 additions & 0 deletions org.lflang.tests/src/org/lflang/tests/runtime/RustTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2021, TU Dresden.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package org.lflang.tests.runtime;

import java.util.Properties;

import org.eclipse.xtext.xbase.lib.InputOutput;
import org.junit.jupiter.api.Test;

import org.lflang.Target;

/**
*
*/
public class RustTest extends TestBase {

public RustTest() {
super.target = Target.Rust;
}


@Override
public void runAsFederated() {
this.printTestHeader(TestBase.RUN_AS_FEDERATED_DESC);
InputOutput.println("N/A");
}


@Override
protected void addExtraLfcArgs(Properties args) {
// Set this environment variable if you develop the crate locally,
// it's more convenient. You'll have to delete test/Rust/src-gen/*
// to make a change (and checkout the Cargo.toml back).
String path = System.getenv("LOCAL_RUST_REACTOR_RT");
if (path != null) {
args.setProperty("external-runtime-path", path);
}
}


@Test
@Override
public void runGenericTests() {
super.runGenericTests();
}
}
30 changes: 27 additions & 3 deletions org.lflang.tests/src/org/lflang/tests/runtime/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.EnumSet;
Expand All @@ -29,6 +31,7 @@
import org.junit.jupiter.api.extension.ExtendWith;

import org.lflang.ASTUtils;
import org.lflang.CommonExtensionsKt;
import org.lflang.DefaultErrorReporter;
import org.lflang.FileConfig;
import org.lflang.LFRuntimeModule;
Expand Down Expand Up @@ -234,9 +237,25 @@ protected final void runTestsAndPrintResults(Target target, Predicate<TestCatego
}
}

public static void runSingleTestAndPrintResults(LFTest test) {
/**
* Run a test, print results on stderr.
*
* @param test Test case.
* @param testClass The test class that will execute the test. This is target-specific,
* it may provide some target-specific configuration. We pass a class
* and not a new instance because this method needs to ensure the object
* is properly injected, and so, it needs to control its entire lifecycle.
*/
public static void runSingleTestAndPrintResults(LFTest test, Class<? extends TestBase> testClass) {
Injector injector = new LFStandaloneSetup(new LFRuntimeModule()).createInjectorAndDoEMFRegistration();
TestBase runner = new TestBase(false) {};
TestBase runner;
try {
@SuppressWarnings("unchecked")
Constructor<? extends TestBase> constructor = (Constructor<? extends TestBase>) testClass.getConstructors()[0];
runner = constructor.newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException(e);
}
injector.injectMembers(runner);

Set<LFTest> tests = Set.of(test);
Expand Down Expand Up @@ -387,12 +406,17 @@ private void execute(LFTest test) {
switch (test.target) {
case C:
case CPP:
case Rust:
case CCPP: {
var binPath = test.fileConfig.binPath;
var binaryName = nameOnly;
if (test.target == Target.Rust) {
// rust binaries uses snake_case
binaryName = CommonExtensionsKt.camelToSnakeCase(binaryName);
}
// Adjust binary extension if running on Window
if (System.getProperty("os.name").startsWith("Windows")) {
binaryName = nameOnly + ".exe";
binaryName += ".exe";
}

var fullPath = binPath.resolve(binaryName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

public class TypeScriptTest extends TestBase {
TypeScriptTest() {
public TypeScriptTest() {
this.target = Target.TS;
}

Expand Down
1 change: 1 addition & 0 deletions org.lflang.ui/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="build/xtend/main"/>
oowekyala marked this conversation as resolved.
Show resolved Hide resolved
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="output" path="bin"/>
Expand Down
4 changes: 2 additions & 2 deletions org.lflang/src/org/lflang/ASTUtils.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ class ASTUtils {
* If the value of the parameter is a list of integers,
* return the sum of value in the list.
* The instantiations parameter is as in
* {@link initialValue(Parameter, List<Instantiation>}.
* {@link initialValue(Parameter, List<Instantiation>)}.
*
* @param parameter The parameter.
* @param instantiations The (optional) list of instantiations.
Expand Down Expand Up @@ -1506,7 +1506,7 @@ class ASTUtils {
* state variable.
* @return The inferred type, or "undefined" if none could be inferred.
*/
protected static def InferredType getInferredType(EList<Value> initList) {
static def InferredType getInferredType(List<Value> initList) {
if (initList.size == 1) {
// If there is a single element in the list, and it is a proper
// time value with units, we infer the type "time".
Expand Down
Loading