Skip to content

Commit 16dc2e2

Browse files
committed
Update CONTRIBUTING.md
1 parent e5d2377 commit 16dc2e2

File tree

1 file changed

+27
-39
lines changed

1 file changed

+27
-39
lines changed

CONTRIBUTING.md

+27-39
Original file line numberDiff line numberDiff line change
@@ -99,93 +99,81 @@ dune build -w
9999

100100
> 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.
101101
102-
## Adding new Files
102+
## Adding new Files to the Npm Package
103103

104104
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.
105105

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
107107

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.
109110

110-
The simplest way for running tests is to run your locally built compiler on separate ReScript files:
111+
## Test the compiler
111112

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.
118114

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
126116

127117
```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
134119
```
135120

136-
Then you may initialize and build your ReScript project as usual:
121+
### Project
137122

138123
```sh
139-
rescript init my-project
140-
cd my-project
141-
npm run build
124+
node scripts/install -force-lib-rebuild ## populate lib/ocaml
125+
cd myProject
126+
npm install __path_to_this_repository__
142127
```
143128

144129
### Running Automatic Tests
145130

146131
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.
147132

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):**
149140

150141
This will run our `mocha` unit test suite defined in `jscomp/test`.
151142

152143
```
153-
npx node scripts/ciTest.js -mocha
144+
node scripts/ciTest.js -mocha
154145
```
155146

156147
**Run build system test (integration tests):**
157148

158149
This will run the whole build system test suite defined in `jscomp/build_tests`.
159150

160151
```
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
165153
```
166154

167155
**Run ounit tests:**
168156

169157
This will run unit tests for compiler related modules. The tests can be found in `jscomp/ounit_tests`.
170158

171159
```
172-
npx node scripts/ciTest.js -ounit
160+
node scripts/ciTest.js -ounit
173161
```
174162

175-
## Contributing to the ReScript Runtime
163+
## Contributing to the Runtime
176164

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).
178166

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!
180168

181169
Each new PR should include appropriate testing.
182170

183171
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.
184172

185173
There are currently two formats for test files:
186174

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)
189177

190178
Below we will discuss on how to write, build and run these test files.
191179

0 commit comments

Comments
 (0)