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
+26-39Lines changed: 26 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -99,93 +99,80 @@ 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
+
```sh
135
+
npm test
136
+
```
137
+
138
+
**Run Mocha tests only (for our runtime code):**
149
139
150
140
This will run our `mocha` unit test suite defined in `jscomp/test`.
151
141
152
142
```
153
-
npx node scripts/ciTest.js -mocha
143
+
node scripts/ciTest.js -mocha
154
144
```
155
145
156
146
**Run build system test (integration tests):**
157
147
158
148
This will run the whole build system test suite defined in `jscomp/build_tests`.
159
149
160
150
```
161
-
# Make sure to globally install rescript via npm first
162
-
npm install -g .
163
-
164
-
npx node scripts/ciTest.js -bsb
151
+
node scripts/ciTest.js -bsb
165
152
```
166
153
167
154
**Run ounit tests:**
168
155
169
156
This will run unit tests for compiler related modules. The tests can be found in `jscomp/ounit_tests`.
170
157
171
158
```
172
-
npx node scripts/ciTest.js -ounit
159
+
node scripts/ciTest.js -ounit
173
160
```
174
161
175
-
## Contributing to the ReScript Runtime
162
+
## Contributing to the Runtime
176
163
177
-
Our runtime implementation is written in pure OCaml with some raw JS code embedded (`jscomp/runtime` directory).
164
+
The runtime implementation is written in OCaml with some raw JS code embedded (`jscomp/runtime` directory).
178
165
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!
166
+
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
167
181
168
Each new PR should include appropriate testing.
182
169
183
170
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
171
185
172
There are currently two formats for test files:
186
173
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)
174
+
1.Mocha test files that run javascript test code
175
+
2. Plain `.ml` files to check the result of compilation to JS (expectation tests)
189
176
190
177
Below we will discuss on how to write, build and run these test files.
0 commit comments