You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+27-39
Original file line number
Diff line number
Diff line change
@@ -99,93 +99,81 @@ dune build -w
99
99
100
100
> Please note that `dune` will not build the final `rescript` binaries. Use the aforementioned `ninja` workflow if you want to build, test and distribute the final product.
101
101
102
-
## Adding new Files
102
+
## Adding new Files to the Npm Package
103
103
104
104
To make sure that no files are added to or removed from the npm package inadvertently, an artifact list is kept at `packages/artifacts.txt`. During CI build, it is verified that only the files that are listed there are actually included in the npm package.
105
105
106
-
When adding a new file to the repository that should go into the npm package - e.g., a new stdlib module -, first compile and test everything locally. Next, run `./scripts/makeArtifactList.js` to update the artifact list and include the updated artifact list in your commit.
106
+
When adding a new file to the repository that should go into the npm package - e.g., a new stdlib module -, first compile and test everything locally. Then
107
107
108
-
## Running tests for independent ReScript files
108
+
-`node scripts/install -force-lib-rebuild` to copy library files into `lib/ocaml`
109
+
-`./scripts/makeArtifactList.js` to update the artifact list and include the updated artifact list in your commit.
109
110
110
-
The simplest way for running tests is to run your locally built compiler on separate ReScript files:
111
+
## Test the compiler
111
112
112
-
```sh
113
-
# Make sure to rebuild the compiler before running any tests (./scripts/ninja.js config / build etc)
114
-
./darwinarm64/bsc.exe myTestFile.res
115
-
```
116
-
117
-
**Different architectures:**
113
+
Make sure to build the compiler first following the instructions above.
118
114
119
-
-`darwinarm64/bsc.exe`: M1 Macs
120
-
-`darwin/bsc.exe`: Intel Macs
121
-
-`linux/bsc.exe`: Linux computers
122
-
123
-
### Testing the whole ReScript Package
124
-
125
-
If you'd like to bundle up and use your modified ReScript like an end-user, try:
115
+
### Single file
126
116
127
117
```sh
128
-
node scripts/install -force-lib-rebuild # make sure lib/ocaml is populated
129
-
130
-
npm uninstall -g rescript # a cache-busting uninstall is needed, but only for npm >=7
131
-
132
-
# This will globally install your local build via npm
133
-
RESCRIPT_FORCE_REBUILD=1 npm install -g .
118
+
./bsc myTestFile.res
134
119
```
135
120
136
-
Then you may initialize and build your ReScript project as usual:
We provide different test suites for different levels of the compiler and build system infrastructure. Always make sure to locally build your compiler before running any tests.
147
132
148
-
**Run Mocha tests for our runtime code:**
133
+
To run all tests:
134
+
135
+
```sh
136
+
npm test
137
+
```
138
+
139
+
**Run Mocha tests only (for our runtime code):**
149
140
150
141
This will run our `mocha` unit test suite defined in `jscomp/test`.
151
142
152
143
```
153
-
npx node scripts/ciTest.js -mocha
144
+
node scripts/ciTest.js -mocha
154
145
```
155
146
156
147
**Run build system test (integration tests):**
157
148
158
149
This will run the whole build system test suite defined in `jscomp/build_tests`.
159
150
160
151
```
161
-
# Make sure to globally install rescript via npm first
162
-
npm install -g .
163
-
164
-
npx node scripts/ciTest.js -bsb
152
+
node scripts/ciTest.js -bsb
165
153
```
166
154
167
155
**Run ounit tests:**
168
156
169
157
This will run unit tests for compiler related modules. The tests can be found in `jscomp/ounit_tests`.
170
158
171
159
```
172
-
npx node scripts/ciTest.js -ounit
160
+
node scripts/ciTest.js -ounit
173
161
```
174
162
175
-
## Contributing to the ReScript Runtime
163
+
## Contributing to the Runtime
176
164
177
-
Our runtime implementation is written in pure OCaml with some raw JS code embedded (`jscomp/runtime` directory).
165
+
The runtime implementation is written in OCaml with some raw JS code embedded (`jscomp/runtime` directory).
178
166
179
-
The goal is to implement the runtime **purely in OCaml**. This includes removing all existing occurrences of embedded raw JS code as well, and you can help!
167
+
The goal is to implement the runtime **purely in OCaml**. This includes removing all existing occurrences of embedded raw JS code as well whenever possible, and you can help!
180
168
181
169
Each new PR should include appropriate testing.
182
170
183
171
Currently all tests are located in the `jscomp/test` directory and you should either add / update test files according to your changes to the compiler.
184
172
185
173
There are currently two formats for test files:
186
174
187
-
1.Proper mocha test files with executed javascript test code
188
-
2. Plain `.ml` files which are only supposed to be compiled to JS (without any logic validation)
175
+
1.Mocha test files that run javascript test code
176
+
2. Plain `.ml` files to check the result of compilation to JS (expectation tests)
189
177
190
178
Below we will discuss on how to write, build and run these test files.
0 commit comments