Skip to content

Commit 1059e18

Browse files
committed
Clean up contributing instructions.
1 parent 179ae9a commit 1059e18

File tree

1 file changed

+26
-39
lines changed

1 file changed

+26
-39
lines changed

CONTRIBUTING.md

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -99,93 +99,80 @@ 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 ## populare 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+
```sh
135+
npm test
136+
```
137+
138+
**Run Mocha tests only (for our runtime code):**
149139

150140
This will run our `mocha` unit test suite defined in `jscomp/test`.
151141

152142
```
153-
npx node scripts/ciTest.js -mocha
143+
node scripts/ciTest.js -mocha
154144
```
155145

156146
**Run build system test (integration tests):**
157147

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

160150
```
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
165152
```
166153

167154
**Run ounit tests:**
168155

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

171158
```
172-
npx node scripts/ciTest.js -ounit
159+
node scripts/ciTest.js -ounit
173160
```
174161

175-
## Contributing to the ReScript Runtime
162+
## Contributing to the Runtime
176163

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

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

181168
Each new PR should include appropriate testing.
182169

183170
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.
184171

185172
There are currently two formats for test files:
186173

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

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

0 commit comments

Comments
 (0)