Skip to content

Commit

Permalink
Fix time error/readme
Browse files Browse the repository at this point in the history
  • Loading branch information
aquemaati committed May 17, 2024
1 parent 50ef454 commit 49a2a04
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TODO.txt
sign.js
same-amout.js

same-amount.js
sign.js
molecules-cells.js
repeat.js

.DS_Store
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ You have to create a hidden directory named "lamoul01" in your Home directory. B
(have to be done)
## Final step
go to your piscine directory and run this command :
```go install github.com/aquemaati/lamoul01@latest```
```go install github.com/aquemaati/lamoul01/cmd/lamoul01 ``
# How to use
Launch these commands and let lamoul test for you:
```lamoul01 js```
```lamoul01 go```
```lamoul01 go```
13 changes: 12 additions & 1 deletion cmd/lamoul01/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package main

import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"time"

"github.com/aquemaati/lamoul01/internal/watcher"
)
Expand Down Expand Up @@ -41,12 +43,21 @@ func main() {

func runJSTests(exName, folder, testPath string) {
fmt.Printf("🤪\033[34mRunning JavaScript tests for: %s\033[0m\n", exName)
cmd := exec.Command("node", testPath, folder, exName)

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

cmd := exec.CommandContext(ctx, "node", testPath, folder, exName)

cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

err := cmd.Run()
if ctx.Err() == context.DeadlineExceeded {
fmt.Printf("🤢\033[31mError: JavaScript tests for %s exceeded time limit of 10 seconds\033[0m\n", exName)
return
}

if err != nil {
fmt.Printf("🤢\033[31mError running JavaScript tests: %v\033[0m\n", err)
}
Expand Down

0 comments on commit 49a2a04

Please sign in to comment.