Skip to content

Commit

Permalink
yarn tests (#130)
Browse files Browse the repository at this point in the history
* add some ignored things

* use go 1.20

* go mod tidy

* fix deprecated stdlib APIs from minor version releases cause thats totally cool and normal

* fix deprecated flake output

* here wigo

* full nodejs which-language testing

* more tests

* another test, cleanup

* move some things around, fix some fails

* fix testremove logic

* test guessing

* better test layout

* better search testing

* better info testing

* better add testing

* better remove testing

* better lock testing

* better install testing

* better list testing

* better guess testing

* add package managers to devshell for testing

* exclude test suite from upm src

* skip test suites that dont have tests

* cleanup

* add test-suite to ci

* add nix to test-suite task

* share nix store, run make generated

* fix dependencies list i think

* bleh

* dont go run statik just run statik

* i really hope directly invoking statik in the makefile works

* remove statik

* fix vendorhash

* embed.FS has different expectations to statik.FS

* lint

* fix statik->embed paths

* get rid of statik

* tweak semaphore test task

* try with self-hosted agent

* remove some stuff from ci

* oops

* use nix container image

* oops

* change image pull secret

* try this instead

* only nodejs-yarn tests

* fix regex for reading org in package spec

* use just self-hosted

* install_nix script

* forgot to source nix

* forgot i dont need the brackets

* set semaphore cache backend

* set cache gcs bucket

* nocache

* make script more debuggable

* source the install_nix script

* publish test results

* go get gotestsum first

* try inline nix develop/shell

* use makefile for the tests

* fix golangci-lint invocation

* fix lint

* remove backend tests

* cleanup

* use correct semaphore configs

* fix merge
  • Loading branch information
cdmistman authored Oct 20, 2023
1 parent 4ec50c8 commit 9a5f808
Show file tree
Hide file tree
Showing 15 changed files with 1,878 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/backends/nodejs/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ var NodejsYarnBackend = api.LanguageBackend{
util.Die("yarn.lock: %s", err)
}
contents := string(contentsB)
r := regexp.MustCompile(`(?m)^"?([^@ \n]+).+:\n version "(.+)"$`)
r := regexp.MustCompile(`(?m)^"?((?:@[^@ \n]+\/)?[^@ \n]+).+:\n version "(.+)"$`)
pkgs := map[api.PkgName]api.PkgVersion{}
for _, match := range r.FindAllStringSubmatch(contents, -1) {
name := api.PkgName(match[1])
Expand Down
2 changes: 2 additions & 0 deletions test-suite/Add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ func TestAdd(t *testing.T) {

var pkgs []string
switch bt.Backend.Name {
case "nodejs-yarn":
fallthrough
case "bun":
pkgs = []string{"lodash", "react", "@replit/protocol"}

Expand Down
2 changes: 2 additions & 0 deletions test-suite/Guess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ func TestGuess(t *testing.T) {

tests := make(map[string]map[string][]string)
switch bt.Backend.Name {
case "nodejs-yarn":
fallthrough
case "bun":
for _, ext := range []string{"js", "jsx", "ts", "tsx"} {
_, ok := tests[ext]
Expand Down
2 changes: 2 additions & 0 deletions test-suite/Info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ func TestInfo(t *testing.T) {
bt.Start(t)

switch bt.Backend.Name {
case "nodejs-yarn":
fallthrough
case "bun":
doInfo(bt, "express", "@replit/crosis")

Expand Down
2 changes: 1 addition & 1 deletion test-suite/Install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestInstall(t *testing.T) {
for _, bt := range languageBackends {
bt.Start(t)

if bt.Backend.Name != "bun" {
if bt.Backend.Name != "bun" && bt.Backend.Name != "nodejs-yarn" {
t.Run(bt.Backend.Name, func(t *testing.T) {
t.Skip("no test")
})
Expand Down
2 changes: 2 additions & 0 deletions test-suite/List_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ func TestList(t *testing.T) {

var templatesToPackages map[string][]string
switch bt.Backend.Name {
case "nodejs-yarn":
fallthrough
case "bun":
templatesToPackages = map[string][]string{
"no-deps": {},
Expand Down
2 changes: 1 addition & 1 deletion test-suite/Lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func TestLock(t *testing.T) {
for _, bt := range languageBackends {
bt.Start(t)

if bt.Backend.Name != "bun" {
if bt.Backend.Name != "bun" && bt.Backend.Name != "nodejs-yarn" {
t.Run(bt.Backend.Name, func(t *testing.T) {
t.Skip("no test")
})
Expand Down
2 changes: 2 additions & 0 deletions test-suite/Remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ func TestRemove(t *testing.T) {

var pkgsToRemove map[string][]string
switch bt.Backend.Name {
case "nodejs-yarn":
fallthrough
case "bun":
pkgsToRemove = map[string][]string{
"one-dep": {"express"},
Expand Down
2 changes: 2 additions & 0 deletions test-suite/Search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ func TestSearch(t *testing.T) {
bt.Start(t)

switch bt.Backend.Name {
case "nodejs-yarn":
fallthrough
case "bun":
doSearch(bt, []searchTest{
{"express", "express"},
Expand Down
2 changes: 1 addition & 1 deletion test-suite/WhichLanguage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestWhichLanguage(t *testing.T) {
for _, bt := range languageBackends {
bt.Start(t)

if bt.Backend.Name != "bun" {
if bt.Backend.Name != "bun" && bt.Backend.Name != "nodejs-yarn" {
t.Run(bt.Backend.Name, func(t *testing.T) {
t.Skip("no test")
})
Expand Down
19 changes: 19 additions & 0 deletions test-suite/templates/nodejs-yarn/many-deps/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "upm-test-js-project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"enquirer": "2.4.1",
"eslint": "8.49.0",
"express": "4.18.2",
"svelte": "4.2.1",
"vite": "4.4.9",
"@codemirror/state": "6.2.1"
}
}
Loading

0 comments on commit 9a5f808

Please sign in to comment.