netcreateorg / netcreate-itest

Developing the 2.0 version of NetCreate
https://github.com/netcreateorg/netcreate-2018
Other
0 stars 0 forks source link

Infrastructure: Module Architecture Stage 3 #134

Closed daveseah closed 4 months ago

daveseah commented 4 months ago

This PR adds the beginning of our testing framework as well as some other quality of life features:

0. INITIALIZING FOR TEST

This will install the new vitest package.

1. TRY THE TESTING SYSTEM

You'll see some information about the current test. There is currently only on, located in _ur/common/class-statemgr-test.ts. The testing system will find any ts file that ends with *-test.ts or starts with test-*.ts.

2. TEST NETCREATE and STATEMGR CLASS

3A. TEST AUTOMATIC REBUILD OF _UR CORE

3B. TEST AUTOMATIC REBUILD OF _UR ADDONS

4. WITNESS ERROR HANDLING CHANGES

5. TEST AUTOHOMING INTEGRATED TERMINAL

OTHER INFORMATION

benloh commented 4 months ago
  1. TEST AUTOMATIC REBUILD OF _UR CORE

Changing and saving _ur/common/class-statemgr.constructor() does not trigger a recompile. The VSC Terminal does not emit any messages after modifying the constructor.

  1. TEST AUTOHOMING INTEGRATED TERMINAL

When I split the terminal I see: screenshot_1422

npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.

npm ERR! A complete log of this run can be found in: /Users/loh/.npm/_logs/2024-02-13T00_51_08_567Z-debug-0.log
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v18.18.2 --silent` to unset it.
vsenv: setting default node v18.16.0

vsenv: adding './' to end of PATH for easier CLI execution in _ur directory!
       (applies only to this shell)
npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/loh/.npm/_logs/2024-02-13T00_51_11_158Z-debug-0.log
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v18.16.0 --silent` to unset it.
loh@clickr _ur % 
dsriseah commented 4 months ago

@Ben

Test 3 has now been expanded into two parts to resolve the issue that only _ur_addons was being watched. This has been expanded to cover _ur as well (in practice, no one should be touching _ur source files so messed up the test). Grab the latest push to mod-ur.3.

Test 5 this might be dependent on your machine architecture, plus there was a bug in the terminal string that was preventing it from being set correctly. Try pulling the latest version of the branch.

benloh commented 4 months ago

Test 3

After running npm run dev, I get stuck at: screenshot_1431

dsriseah commented 4 months ago

Doh, I forgot about the cheesy integration test in NetCreate for StateMgr` class; the method names have been conformed to camelCase standard. I thought no one was using StateMgr and forgot about this.

New commit pushed.

benloh commented 4 months ago

All the tests run now except for Test 5

screenshot_1432

benloh commented 4 months ago

Running nvm use --delete-prefix v18.18.2 --silent seemed to have fixed the error temporarily. But upon closing and re-opening the terminal, cd _ur, and then opening the split, the error happened again.

dsriseah commented 4 months ago

Running nvm use --delete-prefix v18.18.2 --silent seemed to have fixed the error temporarily.

Digging into this more, this issue is described as happening on systems with more than one version of node, yarn, or pnpm installed. The PREFIX shell variable is set to "" in the output, when it should be pointing to the nvm-managed node binary or not set at all... I believe this is a SHELL variable.

It's possible that your shell is set up in such as away that the PREFIX is being clobbered. you'll see the "command not found: node" that is what's causing this crash...?

I've pushed a change to attempt to diagnose the issue. It will check for the existence of the nodejs binary in your path and dump diagnostic info if it's not there. This won't fix things, but it might help get to the bottom of it. Worst case, this should at least cause the shell not to emit so many weird errors (and will still work)

TROUBLESHOOTING CHECKLIST

benloh commented 4 months ago

With the diagnostic, this is the error/messages: screenshot_1433

Maybe I need to redo my path?

And in case this is useful:

% which node
/Users/loh/.nvm/versions/node/v18.18.2/bin/node
dsriseah commented 4 months ago

Some thoughts: Every time the integrated terminal spawns a new shell, it does execute your .zshrc. I thought you had bash still set as your shell so it is a little surprising.

[0] Try opening the netcreate-itest.code-workspace file and changing this line from:

    "terminal.integrated.defaultProfile.osx": "x86 macos",

to

    "terminal.integrated.defaultProfile.osx": "generic macos",

Then close the workspace and reopen it.

[1] Perhaps there's something weird with your.zshrc that is not working, or you have multiple package managers installed globally (yarn) or have an old sudo or homebrew installed node.

[2] Diagnostic WITHOUT workspace to determine default behavior of your system

[3] Another possibility is that the newer behavior in VSCODE with restoring terminals is getting in the way. I have it turned off. The VSCODE setting can be found by searching for Persistent Session Revive; I have mine set to never.

[4] as a point of comparison, here's what my path looks like compared to yours:

/Users/dsri/.nvm/versions/node/v18.18.2/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:./:/Users/dsri/bin/:./:/Users/dsri/bin/:./:/Users/dsri/bin/

[5] Check the version of nvm:

nvm --version

mine is 0.39.5

[6] I'm wondering if your .zshrc is missing the NVM alias script, but I see that your NVM_HOME is set. This is the script that should be in your .zshrc at the END of the file

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

The nvm.sh script here is what's adding the correct PATH (you can see it in my PATH output at the beginning (see [4] above), whereas it seems to be entirely missing from your screenshot).

[7] Just to be sure, check these lines in your netcreate-itest.code-workspace file match this:

    "terminal.integrated.profiles.osx": {
      "x86 macos": {
        "path": "/usr/bin/arch",
        "args": [
          "-arch",
          "x86_64",
          "${env:SHELL}",
          "-i",
          "-c",
          "export VSCODE_TERM='x86 shell';cd ${workspaceFolder}; source .vscode/vs_env; exec ${env:SHELL}"
        ]
      },
      ...
    "terminal.integrated.defaultProfile.osx": "x86 macos",

If the above doesn't reveal anything, I'll rollback the change until I can get a look at your actual computer to see what's different about it. I wonder if Joshua is getting the same error.

benloh commented 4 months ago

The problem was my nvm version was outdated (0.35.3). Updating to 0.39.7 fixed the problem.