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

PNPM testrepo #112

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ jobs:
run: cargo build --release
- name: Run unit test
run: cargo test
- name: Install PNPM
run: npm i -g pnpm
- name: Install Yarn Dependencies
run: cd ./testrepo && yarn install
run: cd ./tests/testrepo_yarn && yarn install
- name: Install PNPM Dependencies
run: cd ./tests/testrepo_pnpm && pnpm install
- name: Run Test
run: ./tests/suite-ci.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Options:
- [NodeJS](https://nodejs.org/en/) - For running testscripts only
- [Yarn](https://yarnpkg.com/) or [Npm](https://www.npmjs.com/) - Npm probably comes with your node installation

1. `cd testrepo && yarn` (install dependencies for submodule)
1. `cd testrepo_yarn && yarn` (install dependencies for submodule)
2. `cargo run`

Running tests:
Expand Down
8 changes: 4 additions & 4 deletions benches/base_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::io::prelude::*;

fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("build-package-tree", |b| {
// Folder for the testrepo
// Folder for the testrepo_yarn
let folder = "walnut_monorepo";
let project_root = helpers::get_abs_path(folder);

Expand All @@ -19,9 +19,9 @@ fn criterion_benchmark(c: &mut Criterion) {
});

c.bench_function("clean-build-change-build", |b| {
// Folder for the testrepo
let folder = "testrepo";
let filename = "testrepo/packages/dep02/src/Dep02.res";
// Folder for the testrepo_yarn
let folder = "testrepo_yarn";
let filename = "testrepo_yarn/packages/dep02/src/Dep02.res";
// Clean the build
clean::clean(folder);
// Read the file we'll be mutating
Expand Down
31 changes: 16 additions & 15 deletions tests/compile.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#!/bin/bash

cd $(dirname $0)
source "./utils.sh"
cd ../testrepo
cd "$1" || exit

bold "Test: It should compile"

if rewatch clean &> /dev/null;
if rewatch clean
then
success "Repo Cleaned"
else
error "Error Cleaning Repo"
exit 1
fi

if rewatch &> /dev/null;
if rewatch build &> /dev/null
then
success "Repo Built"
else
Expand All @@ -24,7 +25,7 @@ fi

if git diff --exit-code ./;
then
success "Testrepo has no changes"
success "testrepo has no changes"
else
error "Build has changed"
exit 1
Expand All @@ -33,29 +34,29 @@ fi
node ./packages/main/src/Main.mjs > ./packages/main/src/output.txt

mv ./packages/main/src/Main.res ./packages/main/src/Main2.res
rewatch build --no-timing=true &> ../tests/snapshots/rename-file.txt
rewatch build --no-timing=true &> ../snapshots/rename-file-"$1".txt
mv ./packages/main/src/Main2.res ./packages/main/src/Main.res
rewatch build &> /dev/null
mv ./packages/main/src/ModuleWithInterface.resi ./packages/main/src/ModuleWithInterface2.resi
rewatch build --no-timing=true &> ../tests/snapshots/rename-interface-file.txt
rewatch build --no-timing=true &> ../snapshots/rename-interface-file-"$1".txt
mv ./packages/main/src/ModuleWithInterface2.resi ./packages/main/src/ModuleWithInterface.resi
rewatch build &> /dev/null
mv ./packages/main/src/ModuleWithInterface.res ./packages/main/src/ModuleWithInterface2.res
rewatch build --no-timing=true &> ../tests/snapshots/rename-file-with-interface.txt
rewatch build --no-timing=true &> ../snapshots/rename-file-with-interface-"$1".txt
mv ./packages/main/src/ModuleWithInterface2.res ./packages/main/src/ModuleWithInterface.res
rewatch build &> /dev/null

# when deleting a file that other files depend on, the compile should fail
rm packages/dep02/src/Dep02.res
rewatch build --no-timing=true &> ../tests/snapshots/remove-file.txt
rewatch build --no-timing=true &> ../snapshots/remove-file-"$1".txt
# replace the absolute path so the snapshot is the same on all machines
replace "s/$(pwd | sed "s/\//\\\\\//g")//g" ../tests/snapshots/remove-file.txt
replace "s/$(pwd | sed "s/\//\\\\\//g")//g" ../snapshots/remove-file-"$1".txt
git checkout -- packages/dep02/src/Dep02.res
rewatch build &> /dev/null

# it should show an error when we have a dependency cycle
echo 'Dep01.log()' >> packages/new-namespace/src/NS_alias.res
rewatch build --no-timing=true &> ../tests/snapshots/dependency-cycle.txt
rewatch build --no-timing=true &> ../snapshots/dependency-cycle-"$1".txt
git checkout -- packages/new-namespace/src/NS_alias.res
rewatch build &> /dev/null

Expand Down Expand Up @@ -88,8 +89,8 @@ else
fi

# see if the snapshots have changed
changed_snapshots=$(git ls-files --modified ../tests/snapshots)
if git diff --exit-code ../tests/snapshots &> /dev/null;
changed_snapshots=$(git ls-files --modified ../snapshots)
if git diff --exit-code ../snapshots &> /dev/null;
then
success "Snapshots are correct"
else
Expand All @@ -98,11 +99,11 @@ else
# and then cat their contents
printf "\n\n"
for file in $changed_snapshots; do
bold $file
bold "$file"
# show diff of file vs contents in git
git diff $file $file
git diff "$file" "$file"
printf "\n\n"
done

exit 1
fi
fi
2 changes: 1 addition & 1 deletion tests/lib/rewatch.lock
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57150
89511
9 changes: 5 additions & 4 deletions tests/lock.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash

cd $(dirname $0)
source "./utils.sh"
cd ../testrepo
cd "$1" || exit

bold "Test: It should lock - when watching"

sleep 1

if rewatch clean &> /dev/null;
then
success "Repo Cleaned"
Expand Down Expand Up @@ -41,7 +42,7 @@ success "Watcher Started"

sleep 1

if cat tmp.txt | grep 'Error while trying to get lock:' &> /dev/null;
if grep 'Error while trying to get lock:' tmp.txt &> /dev/null;
then
error "Lock not removed correctly"
exit_watcher
Expand Down
11 changes: 11 additions & 0 deletions tests/snapshots/dependency-cycle-testrepo_yarn.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[1/7]📦 Building package tree...[1/7] 📦 Built package tree in 0.00s
[2/7] 🕵️ Finding source files...[2/7] 🕵️ Found source files in 0.00s
[3/7] 📝 Reading compile state...[3/7] 📝 Read compile state 0.00s
[4/7] 🧹 Cleaning up previous build...[4/7] 🧹 Cleaned 0/10 0.00s
[5/7] 🧱 Parsed 1 source files in 0.00s
[6/7] ️🌴 Collected deps in 0.00s
[7/7] ️🛑 Compiled 0 modules in 0.00s

Can't continue... Found a circular dependency in your code:
NewNamespace.NS_alias -> Dep01 -> Dep02 -> NS -> NewNamespace.NS_alias
Error Building:  ️🛑 Error Running Incremental Build:  ️🛑 Failed to Compile. See Errors Above
Expand Down
24 changes: 24 additions & 0 deletions tests/snapshots/remove-file-testrepo_yarn.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[1/7]📦 Building package tree...[1/7] 📦 Built package tree in 0.00s
[2/7] 🕵️ Finding source files...[2/7] 🕵️ Found source files in 0.00s
[3/7] 📝 Reading compile state...[3/7] 📝 Read compile state 0.00s
[4/7] 🧹 Cleaning up previous build...[4/7] 🧹 Cleaned 1/10 0.00s
[5/7] 🧱 Parsed 0 source files in 0.00s
[6/7] ️🌴 Collected deps in 0.00s
[7/7] ️🛑 Compiled 1 modules in 0.00s

We've found a bug for you!
/packages/dep01/src/Dep01.res:3:9-17

1 │ let log = () => {
2 │ Js.log("02")
3 │ Dep02.log()
4 │ }
5 │

The module or file Dep02 can't be found.
- If it's a third-party dependency:
- Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in bsconfig.json?
- Did you include the file's directory to the "sources" in bsconfig.json?


Error Building:  ️🛑 Error Running Incremental Build:  ️🛑 Failed to Compile. See Errors Above
Expand Down
9 changes: 9 additions & 0 deletions tests/snapshots/rename-file-testrepo_yarn.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[1/7]📦 Building package tree...[1/7] 📦 Built package tree in 0.00s
[2/7] 🕵️ Finding source files...[2/7] 🕵️ Found source files in 0.00s
[3/7] 📝 Reading compile state...[3/7] 📝 Read compile state 0.00s
[4/7] 🧹 Cleaning up previous build...[4/7] 🧹 Cleaned 1/10 0.00s
[5/7] 🧱 Parsed 1 source files in 0.00s
[6/7] ️🌴 Collected deps in 0.00s
[7/7] 🤺 ️Compiled 1 modules in 0.00s

✨ Finished Compilation in 0.00s
Expand Down
10 changes: 10 additions & 0 deletions tests/snapshots/rename-file-with-interface-testrepo_yarn.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[1/7]📦 Building package tree...[1/7] 📦 Built package tree in 0.00s
[2/7] 🕵️ Finding source files...Warning: No implementation file found for interface file (skipping): src/ModuleWithInterface.resi
[2/7] 🕵️ Found source files in 0.00s
[3/7] 📝 Reading compile state...[3/7] 📝 Read compile state 0.00s
[4/7] 🧹 Cleaning up previous build...[4/7] 🧹 Cleaned 2/10 0.00s
[5/7] 🧱 Parsed 1 source files in 0.00s
[6/7] ️🌴 Collected deps in 0.00s
[7/7] 🤺 ️Compiled 1 modules in 0.00s

✨ Finished Compilation in 0.00s
Expand Down
10 changes: 10 additions & 0 deletions tests/snapshots/rename-interface-file-testrepo_yarn.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[1/7]📦 Building package tree...[1/7] 📦 Built package tree in 0.00s
[2/7] 🕵️ Finding source files...Warning: No implementation file found for interface file (skipping): src/ModuleWithInterface2.resi
[2/7] 🕵️ Found source files in 0.00s
[3/7] 📝 Reading compile state...[3/7] 📝 Read compile state 0.00s
[4/7] 🧹 Cleaning up previous build...[4/7] 🧹 Cleaned 1/10 0.00s
[5/7] 🧱 Parsed 1 source files in 0.00s
[6/7] ️🌴 Collected deps in 0.00s
[7/7] 🤺 ️Compiled 1 modules in 0.00s

✨ Finished Compilation in 0.00s
Expand Down
6 changes: 4 additions & 2 deletions tests/suffix.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/bash

cd $(dirname $0)
source "./utils.sh"
cd ../testrepo
cd "$1" || exit

bold "Test: It should support custom suffixes"

# Clean Repo
sleep 1
if rewatch clean &> /dev/null;
then
success "Repo Cleaned"
Expand Down
35 changes: 30 additions & 5 deletions tests/suite-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,38 @@ else
exit 1
fi

bold "Make sure the testrepo is clean"
if git diff --exit-code ../testrepo &> /dev/null;
bold "Make sure the testrepo_yarn is clean"
if git diff --exit-code ./testrepo_yarn &> /dev/null;
then
success "Testrepo has no changes"
success "testrepo_yarn has no changes"
else
error "Testrepo is not clean to start with"
error "testrepo_yarn is not clean to start with"
exit 1
fi

./compile.sh && ./watch.sh && ./lock.sh && ./suffix.sh
bold "Make sure the testrepo_pnpm is clean"
if git diff --exit-code ./testrepo_pnpm &> /dev/null;
then
success "testrepo_pnpm has no changes"
else
error "testrepo_pnpm is not clean to start with"
exit 1
fi

bold "Yarn Tests"
./compile.sh "testrepo_yarn" \
&& sleep 1 \
&& ./watch.sh "testrepo_yarn" \
&& sleep 1 \
&& ./lock.sh "testrepo_yarn" \
&& sleep 1 \
&& ./suffix.sh "testrepo_yarn";

bold "PNPM Tests"
./compile.sh "testrepo_pnpm" \
&& sleep 1 \
&& ./watch.sh "testrepo_pnpm" \
&& sleep 1 \
&& ./lock.sh "testrepo_pnpm" \
&& sleep 1 \
&& ./suffix.sh "testrepo_pnpm";
1 change: 1 addition & 0 deletions tests/suite.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
#
cd $(dirname $0)
./suite-ci.sh
File renamed without changes.
18 changes: 9 additions & 9 deletions testrepo/bsconfig.json → tests/testrepo_pnpm/bsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "testrepo",
"name": "testrepo_pnpm",
"sources": {
"dir": "src",
"subdirs": true
Expand All @@ -15,16 +15,16 @@
},
"suffix": ".mjs",
"pinned-dependencies": [
"@testrepo/main",
"@testrepo/dep01",
"@testrepo/dep02",
"@testrepo/new-namespace"
"@testrepo_pnpm/main",
"@testrepo_pnpm/dep01",
"@testrepo_pnpm/dep02",
"@testrepo_pnpm/new-namespace"
],
"bs-dependencies": [
"@testrepo/main",
"@testrepo/dep01",
"@testrepo/dep02",
"@testrepo/new-namespace"
"@testrepo_pnpm/main",
"@testrepo_pnpm/dep01",
"@testrepo_pnpm/dep02",
"@testrepo_pnpm/new-namespace"
],
"reason": {
"react-jsx": 3
Expand Down
20 changes: 20 additions & 0 deletions tests/testrepo_pnpm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "testrepo_pnpm",
"private": true,
"scripts": {
"build": "../target/release/rewatch build .",
"build:rescript": "rescript build -with-deps",
"watch": "../target/release/rewatch watch .",
"watch:rescript": "rescript watch -with-deps",
"clean": "../target/release/rewatch clean .",
"clean:rescript": "rescript clean"
},
"devDependencies": {
"@testrepo_pnpm/main": "workspace:*",
"@testrepo_pnpm/dep01": "workspace:*",
"@testrepo_pnpm/dep02": "workspace:*",
"@testrepo_pnpm/new-namespace": "workspace:*",
"@rolandpeelen/rewatch": "^1.0.1",
"rescript": "^11.1.0-rc.7"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@testrepo/dep02",
"name": "@testrepo_pnpm/dep01",
"sources": {
"dir": "src",
"subdirs": true
Expand All @@ -9,5 +9,5 @@
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": ["@testrepo/new-namespace"]
"bs-dependencies": ["@testrepo_pnpm/dep02"]
}
18 changes: 18 additions & 0 deletions tests/testrepo_pnpm/packages/dep01/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@testrepo_pnpm/dep01",
"version": "0.0.1",
"scripts": {
"res:build": "rescript",
"res:clean": "rescript clean",
"res:dev": "rescript build -w"
},
"keywords": [
"rescript"
],
"author": "",
"license": "MIT",
"dependencies": {
"@testrepo_pnpm/dep02": "workspace:*",
"rescript": "*"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Dep02 from "@testrepo/dep02/src/Dep02.mjs";
import * as Dep02 from "@testrepo_pnpm/dep02/src/Dep02.mjs";

function log() {
console.log("02");
Expand Down
Loading
Loading